-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
173 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
.Thumb.db | ||
|
||
node_modules | ||
templates/esbuild/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package-lock=false | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>[app_name]</title> | ||
<script type="module" defer src="./build/index.js"></script> | ||
<link rel="stylesheet" type="text/css" href="./styles.css" /> | ||
</head> | ||
<body> | ||
|
||
</body> | ||
</html> |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"scripts": { | ||
"dev": "concurrently \"esbuild src/index.js --bundle --format=esm --watch --outdir=build\" \"serve\"" | ||
}, | ||
"devDependencies": { | ||
"concurrently": "^8.2.2", | ||
"esbuild": "^0.21.5", | ||
"serve": "^14.2.3" | ||
}, | ||
"dependencies": { | ||
"@ircam/sc-components": "^3.0.0-alpha.61", | ||
"lit": "^3.1.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { html, render } from 'lit'; | ||
import '@ircam/sc-components'; | ||
|
||
import resumeAudioContext from '../lib/resume-audio-context.js'; | ||
import loadAudioBuffer from '../lib/load-audio-buffer.js'; | ||
|
||
const audioContext = new AudioContext(); | ||
await resumeAudioContext(audioContext); | ||
|
||
const buffer = await loadAudioBuffer('./assets/sample.wav', audioContext.sampleRate); | ||
|
||
render(html` | ||
<h1>[app_name]</h1> | ||
<sc-bang | ||
@input=${e => { | ||
const src = audioContext.createBufferSource(); | ||
src.connect(audioContext.destination); | ||
src.buffer = buffer; | ||
src.start(); | ||
}} | ||
></sc-bang> | ||
`, document.body); | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# [app_name] | ||
|
||
Simple template for Web Audio demos and tests | ||
|
||
## Usage | ||
|
||
``` | ||
cd path/to/dir | ||
npx serve | ||
``` |
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const contexts = new Map(); | ||
|
||
export default async function loadAudioBuffer(pathname, sampleRate = 48000) { | ||
if (!contexts.has(sampleRate)) { | ||
const context = new OfflineAudioContext(1, 1, sampleRate); | ||
contexts.set(sampleRate, context); | ||
} | ||
|
||
const response = await fetch(pathname); | ||
const arrayBuffer = await response.arrayBuffer(); | ||
|
||
const context = contexts.get(sampleRate); | ||
const audioBuffer = await context.decodeAudioData(arrayBuffer); | ||
|
||
return audioBuffer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { html, render } from 'https://unpkg.com/lit-html'; | ||
|
||
export default async function resumeAudioContext(audioContext) { | ||
return new Promise(resolve => { | ||
render(html` | ||
<sc-button | ||
style="position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; font-size: 14px;" | ||
@release=${async () => { | ||
await audioContext.resume(); | ||
resolve(); | ||
}} | ||
>Resume context</sc-button> | ||
`, document.body); | ||
}); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
:root { | ||
--background-color: #181817; | ||
--font-color: #ffffff; | ||
--font-family: Consolas, monaco, monospace; | ||
--font-size: 62.5%; // such that 1rem == 10px | ||
} | ||
|
||
* { | ||
box-sizing: border-box; | ||
font-family: var(--font-family); | ||
} | ||
|
||
html, body { | ||
width: 100%; | ||
min-height: 100vh; | ||
background-color: var(--background-color); | ||
color: var(--font-color); | ||
} | ||
|
||
html { | ||
font-size: var(--font-size); | ||
} | ||
|
||
body { | ||
padding: 20px; | ||
margin: 0; | ||
} |