diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index 2ff2089df..a9d7cc266 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -1319,6 +1319,18 @@ export const { lpsync } = registerControl('lpsync'); */ export const { lpdepth } = registerControl('lpdepth'); +/** + * Depth of the LFO for the lowpass filter, in HZ + * + * @name lpdepthfrequency + * @synonyms + * lpdethfreq + * @param {number | Pattern} depth depth of modulation + * @example + * note("*16").s("sawtooth").lpf(600).lpdepthfrequency("<200 500 100 0>") + */ + +export const { lpdepthfrequency } = registerControl('lpdepthfrequency', 'lpdepthfreq'); /** * Shape of the LFO for the lowpass filter @@ -1368,6 +1380,19 @@ export const { bpsync } = registerControl('bpsync'); */ export const { bpdepth } = registerControl('bpdepth'); +/** + * Depth of the LFO for the bandpass filter, in HZ + * + * @name bpdepthfrequency + * @synonyms + * bpdethfreq + * @param {number | Pattern} depth depth of modulation + * @example + * note("*16").s("sawtooth").lpf(600).bpdepthfrequency("<200 500 100 0>") + */ + +export const { bpdepthfrequency } = registerControl('bpdepthfrequency', 'bpdepthfreq'); + /** * Shape of the LFO for the bandpass filter * @@ -1414,7 +1439,20 @@ export const { hpsync } = registerControl('hpsync'); * @name hpdepth * @param {number | Pattern} depth depth of modulation */ -export const { hpdepth } = registerControl('hpdepth'); +export const { hpdepth, hpdepthfreq } = registerControl('hpdepth'); + +/** + * Depth of the LFO for the hipass filter, in hz + * + * @name hpdepthfrequency + * @synonyms + * hpdethfreq + * @param {number | Pattern} depth depth of modulation + * @example + * note("*16").s("sawtooth").lpf(600).hpdepthfrequency("<200 500 100 0>") + */ + +export const { hpdepthfrequency } = registerControl('hpdepthfrequency', 'hpdepthfreq'); /** * Shape of the LFO for the highpass filter diff --git a/packages/superdough/helpers.mjs b/packages/superdough/helpers.mjs index 11427dc5b..ad11f595c 100644 --- a/packages/superdough/helpers.mjs +++ b/packages/superdough/helpers.mjs @@ -201,12 +201,14 @@ export function createFilter(context, start, end, params, cps, cycle) { q = 1, drive = 0.69, depth, + depthfrequency, dcoffset = -0.5, skew, shape, rate, sync, } = params; + let frequencyParam, filter; if (model === 'ladder') { filter = getWorklet(context, 'ladder-processor', { frequency, q, drive }); @@ -237,12 +239,13 @@ export function createFilter(context, start, end, params, cps, cycle) { if (sync != null) { rate = cps * sync; } - const hasLFO = [depth, skew, shape, rate].some((v) => v !== undefined); + const hasLFO = [depth, depthfrequency, skew, shape, rate].some((v) => v !== undefined); if (hasLFO) { depth = depth ?? 1; const time = cycle / cps; + const modDepth = depthfrequency ?? (depth ?? 1) * frequency; const lfoValues = { - depth: (depth ?? 1) * frequency, + depth: modDepth, dcoffset, skew, shape, diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index 4e1a145c0..e3177c7d6 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -553,6 +553,7 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) rate: 'lprate', sync: 'lpsync', depth: 'lpdepth', + depthfrequency: 'lpdepthfrequency', shape: 'lpshape', dcoffset: 'lpdc', skew: 'lpskew', @@ -581,13 +582,14 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) rate: 'hprate', sync: 'hpsync', depth: 'hpdepth', + depthfrequency: 'hpdepthfrequency', shape: 'hpshape', dcoffset: 'hpdc', skew: 'hpskew', }; const hpParams = pickAndRename(value, hpMap); hpParams.type = 'highpass'; - let hp = () => createFilter(ac, t, end, hpParams, cps); + let hp = () => createFilter(ac, t, end, hpParams, cps, cycle); chain.push(hp()); if (ftype === '24db') { chain.push(hp()); @@ -609,13 +611,14 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) rate: 'bprate', sync: 'bpsync', depth: 'bpdepth', + depthfrequency: 'bpdepthfrequency', shape: 'bpshape', dcoffset: 'bpdc', skew: 'bpskew', }; const bpParams = pickAndRename(value, bpMap); bpParams.type = 'bandpass'; - let bp = () => createFilter(ac, t, end, bpParams, cps); + let bp = () => createFilter(ac, t, end, bpParams, cps, cycle); chain.push(bp()); if (ftype === '24db') { chain.push(bp());