mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 21:58:37 +00:00
add docs and allow arrays of aliases
This commit is contained in:
parent
7222c29c55
commit
fd68ad9bde
@ -24,13 +24,25 @@ export function aliasBankMap(aliasMap) {
|
|||||||
const soundDictionary = soundMap.get();
|
const soundDictionary = soundMap.get();
|
||||||
for (const key in soundDictionary) {
|
for (const key in soundDictionary) {
|
||||||
const [bank, suffix] = key.split('_');
|
const [bank, suffix] = key.split('_');
|
||||||
if (aliasMap[bank]) {
|
const aliasValue = aliasMap[bank];
|
||||||
soundDictionary[`${aliasMap[bank]}_${suffix}`] = soundDictionary[key];
|
if (aliasValue) {
|
||||||
|
if (typeof aliasValue === 'string') {
|
||||||
|
soundDictionary[`${aliasValue}_${suffix}`] = soundDictionary[key];
|
||||||
|
} else if (Array.isArray(aliasValue)) {
|
||||||
|
for (const alias of aliasValue) {
|
||||||
|
soundDictionary[`${alias}_${suffix}`] = soundDictionary[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
soundMap.set({ ...soundDictionary });
|
soundMap.set({ ...soundDictionary });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register an alias for a bank of sounds. Optionally accepts a map of banks to aliases.
|
||||||
|
* @param {string} bank - The bank to alias
|
||||||
|
* @param {string} alias - The alias to use for the bank
|
||||||
|
*/
|
||||||
export function aliasBank(...args) {
|
export function aliasBank(...args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user