can now pass meta data to setSound
+ added types for synth and sample + list sample count for samples in sounds tab (as before)
This commit is contained in:
parent
b08a0b8102
commit
35ef26c013
4 changed files with 39 additions and 34 deletions
|
|
@ -15,8 +15,8 @@ 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) {
|
||||
soundMap.setKey(key, onTrigger);
|
||||
export function setSound(key, onTrigger, data = {}) {
|
||||
soundMap.setKey(key, { onTrigger, data });
|
||||
}
|
||||
export const resetLoadedSounds = () => soundMap.set({});
|
||||
|
||||
|
|
@ -166,7 +166,8 @@ export const webaudioOutput = async (hap, deadline, hapDuration, cps) => {
|
|||
if (source) {
|
||||
node = source(options);
|
||||
} else if (soundMap.get()[s]) {
|
||||
node = await soundMap.get()[s](options);
|
||||
const { onTrigger } = soundMap.get()[s];
|
||||
node = await onTrigger(options);
|
||||
} else {
|
||||
throw new Error(`sound ${s} not found! Is it loaded?`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue