diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index 4c5f40c8..bedb4a25 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -100,6 +100,22 @@ const generic_params = [ 'attack', 'a pattern of numbers to specify the attack time (in seconds) of an envelope applied to each sample.', ], + + /** + * Select the sound bank to use. To be used together with `s`. The bank name (+ "_") will be prepended to the value of `s`. + * + * @name bank + * @param {string | Pattern} bank the name of the bank + * @example + * s("bd sd").bank('RolandTR909') // = s("RolandTR909_bd RolandTR909_sd") + * + */ + [ + 'f', + 'bank', + 'selects sound bank to use', + ], + // TODO: find out how this works? /* * Envelope decay time = the time it takes after the attack time to reach the sustain level. diff --git a/packages/webaudio/webaudio.mjs b/packages/webaudio/webaudio.mjs index ffcdd1a2..58d6871c 100644 --- a/packages/webaudio/webaudio.mjs +++ b/packages/webaudio/webaudio.mjs @@ -246,6 +246,7 @@ export const webaudioOutput = async (hap, deadline, hapDuration) => { let { freq, s, + bank, sf, clip = 0, // if 1, samples will be cut off when the hap ends n = 0, @@ -281,6 +282,9 @@ export const webaudioOutput = async (hap, deadline, hapDuration) => { gain *= velocity; // legacy fix for velocity // the chain will hold all audio nodes that connect to each other const chain = []; + if (bank && s) { + s = `${bank}_${s}`; + } if (typeof s === 'string') { [s, n] = splitSN(s, n); } diff --git a/repl/src/prebake.mjs b/repl/src/prebake.mjs index 89cc891a..6321d761 100644 --- a/repl/src/prebake.mjs +++ b/repl/src/prebake.mjs @@ -4979,8 +4979,4 @@ Pattern.prototype.piano = function () { const pan = panwidth(Math.min(midi / maxPan, 1), 0.5); return { ...value, pan: (value.pan || 1) * pan }; }); -}; - -Pattern.prototype.soundbank = function (name) { - return this.fmap((v) => ({ ...v, s: `${name}_${v.s}` })); -}; +}; \ No newline at end of file