mirror of
https://codeberg.org/uzu/strudel
synced 2026-08-01 05:27:18 -04:00
rename setSound to registerSound
This commit is contained in:
@@ -9,12 +9,12 @@ import { MiniRepl } from '../../docs/MiniRepl';
|
||||
|
||||
Let's take a closer look about how sounds are implemented in the webaudio output.
|
||||
|
||||
## Registering a sound via setSound
|
||||
## Registering a sound
|
||||
|
||||
All sounds are registered in the sound map, using the the `setSound` function:
|
||||
All sounds are registered in the sound map, using the the `registerSound` function:
|
||||
|
||||
```ts
|
||||
function setSound(
|
||||
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:
|
||||
(
|
||||
@@ -29,14 +29,14 @@ function setSound(
|
||||
);
|
||||
```
|
||||
|
||||
When `setSound` is called, it registers `{ onTrigger, data }` under the given `name` in a [nanostore map](https://github.com/nanostores/nanostores#maps).
|
||||
When `registerSound` is called, it registers `{ onTrigger, data }` under the given `name` in a [nanostore map](https://github.com/nanostores/nanostores#maps).
|
||||
|
||||
### Example
|
||||
|
||||
This might be a bit abstract, so here is a minimal example:
|
||||
|
||||
```js
|
||||
setSound(
|
||||
registerSound(
|
||||
'mysaw',
|
||||
(time, value, onended) => {
|
||||
let { freq } = value; // destructure control params
|
||||
|
||||
Reference in New Issue
Block a user