mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-19 09:38:38 +00:00
better code example
This commit is contained in:
parent
82cb4c8c11
commit
8d9be21c8a
@ -15,19 +15,31 @@ npm i superdough --save
|
|||||||
## Use
|
## Use
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { superdough, samples } from 'superdough';
|
import { superdough, samples, initAudioOnFirstClick, registerSynthSounds } from 'superdough';
|
||||||
// load samples from github
|
|
||||||
const init = samples('github:tidalcycles/Dirt-Samples/master');
|
const init = Promise.all([
|
||||||
|
initAudioOnFirstClick(),
|
||||||
|
samples('github:tidalcycles/Dirt-Samples/master'),
|
||||||
|
registerSynthSounds(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const loop = (t = 0) => {
|
||||||
|
// superdough(value, time, duration)
|
||||||
|
superdough({ s: 'bd', delay: 0.5 }, t);
|
||||||
|
superdough({ note: 'g1', s: 'sawtooth', cutoff: 600, resonance: 8 }, t, 0.125);
|
||||||
|
superdough({ note: 'g2', s: 'sawtooth', cutoff: 600, resonance: 8 }, t + 0.25, 0.125);
|
||||||
|
superdough({ s: 'hh' }, t + 0.25);
|
||||||
|
superdough({ s: 'sd', room: 0.5 }, t + 0.5);
|
||||||
|
superdough({ s: 'hh' }, t + 0.75);
|
||||||
|
};
|
||||||
|
|
||||||
// play some sounds when a button is clicked
|
|
||||||
document.getElementById('play').addEventListener('click', async () => {
|
document.getElementById('play').addEventListener('click', async () => {
|
||||||
await init;
|
await init;
|
||||||
superdough({ s: "bd", delay: .5 }, 0);
|
let t = 0.1;
|
||||||
superdough({ s: "sawtooth", cutoff: 600, resonance: 8 }, 0);
|
while (t < 16) {
|
||||||
superdough({ s: "hh" }, 0.25);
|
loop(t++);
|
||||||
superdough({ s: "sd", room: .5 }, 0.5);
|
}
|
||||||
superdough({ s: "hh" }, 0.75);
|
});
|
||||||
})
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user