sounds list can now filter out defaults

This commit is contained in:
Felix Roos 2023-03-08 00:33:21 +01:00
parent 35ef26c013
commit cee08ea67d
7 changed files with 76 additions and 22 deletions

View file

@ -105,7 +105,7 @@ export const getLoadedBuffer = (url) => {
*
*/
export const samples = async (sampleMap, baseUrl = sampleMap._base || '') => {
export const samples = async (sampleMap, baseUrl = sampleMap._base || '', options = {}) => {
if (typeof sampleMap === 'string') {
if (sampleMap.startsWith('github:')) {
let [_, path] = sampleMap.split('github:');
@ -123,12 +123,13 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '') => {
}
return fetch(sampleMap)
.then((res) => res.json())
.then((json) => samples(json, baseUrl || json._base || base))
.then((json) => samples(json, baseUrl || json._base || base, options))
.catch((error) => {
console.error(error);
throw new Error(`error loading "${sampleMap}"`);
});
}
const { prebake } = options;
Object.entries(sampleMap).forEach(([key, value]) => {
if (typeof value === 'string') {
value = [value];
@ -149,7 +150,12 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '') => {
}),
);
}
setSound(key, (options) => onTriggerSample(options, value), { type: 'sample', samples: value });
setSound(key, (options) => onTriggerSample(options, value), {
type: 'sample',
samples: value,
baseUrl,
prebake,
});
});
};

View file

@ -32,7 +32,7 @@ export function registerSynthSounds() {
//chain.push(adsr);
return o.connect(g).connect(adsr);
},
{ type: 'synth' },
{ type: 'synth', prebake: true },
);
});
}