Merge pull request 'Fix sounds example to work in the REPL' (#1851) from JesCoding/strudel:jescoding-patch-2 into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1851
This commit is contained in:
commit
5ee5d4f1b1
1 changed files with 31 additions and 29 deletions
|
|
@ -13,7 +13,7 @@ Let's take a closer look about how sounds are implemented in the webaudio output
|
|||
|
||||
All sounds are registered in the sound map, using the the `registerSound` function:
|
||||
|
||||
```ts
|
||||
```js
|
||||
function registerSound(
|
||||
name: string, // The name of the sound that should be given to `s`, e.g. `mysaw`
|
||||
// The function called by the scheduler to trigger the sound:
|
||||
|
|
@ -35,7 +35,9 @@ When `registerSound` is called, it registers `{ onTrigger, data }` under the giv
|
|||
|
||||
This might be a bit abstract, so here is a minimal example:
|
||||
|
||||
```js
|
||||
<MiniRepl
|
||||
client:idle
|
||||
tune={`
|
||||
registerSound(
|
||||
'mysaw',
|
||||
(time, value, onended) => {
|
||||
|
|
@ -61,8 +63,8 @@ registerSound(
|
|||
{ type: 'synth' },
|
||||
);
|
||||
// use the sound
|
||||
freq(220, 440, 330).s('mysaw');
|
||||
```
|
||||
freq("220 440 330").s('mysaw');`}
|
||||
/>
|
||||
|
||||
You can actually use this code in the [REPL](https://strudel.cc/) and it'll work.
|
||||
After evaluating the code, you should see `mysaw` in listed in the sounds tab.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue