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

View file

@ -1,5 +1,5 @@
import { logger, toMidi, valueToMidi } from '@strudel.cycles/core';
import { getAudioContext, setSound } from './index.mjs';
import { getAudioContext, registerSound } from './index.mjs';
import { getEnvelope } from './helpers.mjs';
const bufferCache = {}; // string: Promise<ArrayBuffer>
@ -150,7 +150,7 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '', option
}),
);
}
setSound(key, (t, hapValue, onended) => onTriggerSample(t, hapValue, onended, value), {
registerSound(key, (t, hapValue, onended) => onTriggerSample(t, hapValue, onended, value), {
type: 'sample',
samples: value,
baseUrl,

View file

@ -1,10 +1,10 @@
import { fromMidi, toMidi } from '@strudel.cycles/core';
import { setSound } from './webaudio.mjs';
import { registerSound } from './webaudio.mjs';
import { getOscillator, gainNode, getEnvelope } from './helpers.mjs';
export function registerSynthSounds() {
['sine', 'square', 'triangle', 'sawtooth'].forEach((wave) => {
setSound(
registerSound(
wave,
(t, value, onended) => {
// destructure adsr here, because the default should be different for synths and samples

View file

@ -14,8 +14,7 @@ import { getFilter, gainNode } from './helpers.mjs';
import { map } from 'nanostores';
export const soundMap = map();
// onTrigger = ({ hap: Hap, t: number, deadline: number, duration: number, cps: number }) => AudioNode
export function setSound(key, onTrigger, data = {}) {
export function registerSound(key, onTrigger, data = {}) {
soundMap.setKey(key, { onTrigger, data });
}
export function getSound(s) {