rename setSound to registerSound

This commit is contained in:
Felix Roos
2023-03-09 21:32:40 +01:00
parent ff1e6714c6
commit 6f5d096e6d
4 changed files with 10 additions and 11 deletions
@@ -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