From e6604491a921f40b278a4ea109abfbf6d47905ce Mon Sep 17 00:00:00 2001 From: "Lu[ke] Wilson" Date: Sun, 26 Jan 2025 12:21:26 +0000 Subject: [PATCH] add aliasbank function --- packages/superdough/superdough.mjs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index b61f4263..c0d5f0df 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -20,6 +20,18 @@ export function registerSound(key, onTrigger, data = {}) { soundMap.setKey(key, { onTrigger, data }); } +export function aliasBank(alias, bank) { + const _soundMap = soundMap.get(); + const soundsToAdd = {}; + for (const soundName in _soundMap) { + const [soundPrefix, soundSuffix] = soundName.split('_'); + if (soundPrefix == bank) { + soundsToAdd[`${alias}_${soundSuffix}`] = _soundMap[soundName]; + } + } + soundMap.set(soundsToAdd); +} + export function getSound(s) { return soundMap.get()[s]; }