mirror of
https://codeberg.org/uzu/strudel
synced 2026-08-16 01:49:52 -04:00
add prepare() to superdough
This commit is contained in:
@@ -265,19 +265,28 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '', option
|
||||
processSampleMap(
|
||||
sampleMap,
|
||||
(key, bank) =>
|
||||
registerSound(key, (t, hapValue, onended) => onTriggerSample(t, hapValue, onended, bank), {
|
||||
type: 'sample',
|
||||
samples: bank,
|
||||
baseUrl,
|
||||
prebake,
|
||||
tag,
|
||||
}),
|
||||
registerSound(
|
||||
key,
|
||||
(t, hapValue, onended) => onTriggerSample(t, hapValue, onended, bank),
|
||||
{
|
||||
type: 'sample',
|
||||
samples: bank,
|
||||
baseUrl,
|
||||
prebake,
|
||||
tag,
|
||||
},
|
||||
(hapValue) => onPrepareSample(hapValue, bank),
|
||||
),
|
||||
baseUrl,
|
||||
);
|
||||
};
|
||||
|
||||
const cutGroups = [];
|
||||
|
||||
export async function onPrepareSample(hapValue, bank, resolveUrl) {
|
||||
await getSampleBuffer(hapValue, bank, resolveUrl);
|
||||
}
|
||||
|
||||
export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||
let {
|
||||
s,
|
||||
|
||||
@@ -23,9 +23,10 @@ export function setMaxPolyphony(polyphony) {
|
||||
}
|
||||
export const soundMap = map();
|
||||
|
||||
export function registerSound(key, onTrigger, data = {}) {
|
||||
export function registerSound(key, onTrigger, data = {}, onPrepare = (() => {})) {
|
||||
key = key.toLowerCase().replace(/\s+/g, '_');
|
||||
soundMap.setKey(key, { onTrigger, data });
|
||||
soundMap.setKey(key, { onTrigger, data, onPrepare });
|
||||
|
||||
}
|
||||
|
||||
function aliasBankMap(aliasMap) {
|
||||
@@ -721,3 +722,15 @@ export const superdough = async (value, t, hapDuration) => {
|
||||
export const superdoughTrigger = (t, hap, ct, cps) => {
|
||||
superdough(hap, t - ct, hap.duration / cps, cps);
|
||||
};
|
||||
|
||||
export const prepare = (value) => {
|
||||
const {
|
||||
onPrepare,
|
||||
} = getSound(value.s);
|
||||
if (onPrepare) {
|
||||
if (value.bank && value.s) {
|
||||
value.s = `${value.bank}_${value.s}`;
|
||||
}
|
||||
onPrepare(value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user