From 7bbb653963ace62fdf7f5aba33600da576927d02 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sat, 22 Nov 2025 23:42:20 -0500 Subject: [PATCH] fixed --- packages/core/controls.mjs | 7 +++++++ packages/superdough/helpers.mjs | 28 +++++++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index 9a2be7f44..299169973 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -1294,6 +1294,8 @@ export const { fanchor } = registerControl('fanchor'); * * @name lprate * @param {number | Pattern} rate rate in hertz + * @example + * note("*16").s("sawtooth").lpf(600).lprate("<4 8 2 1>") */ export const { lprate } = registerControl('lprate'); @@ -1302,6 +1304,8 @@ export const { lprate } = registerControl('lprate'); * * @name lpsync * @param {number | Pattern} rate rate in cycles + * @example + * note("*16").s("sawtooth").lpf(600).lpsync("<4 8 2 1>") */ export const { lpsync } = registerControl('lpsync'); @@ -1310,7 +1314,10 @@ export const { lpsync } = registerControl('lpsync'); * * @name lpdepth * @param {number | Pattern} depth depth of modulation + * @example + * note("*16").s("sawtooth").lpf(600).lpdepth("<1 .5 1.8 0>") */ + export const { lpdepth } = registerControl('lpdepth'); /** diff --git a/packages/superdough/helpers.mjs b/packages/superdough/helpers.mjs index 7bca637f2..65f5cc36d 100644 --- a/packages/superdough/helpers.mjs +++ b/packages/superdough/helpers.mjs @@ -191,9 +191,6 @@ export function applyParameterModulators(audioContext, param, start, end, envelo const lfo = getParamLfo(audioContext, param, start, end, lfoValues); return { lfo, disconnect: () => lfo?.disconnect() }; } -function biloparExponential(x, k) { - return Math.sign(x) * 2 ** (Math.abs(x) * k); -} export function createFilter(context, start, end, params, cps, cycle) { let { frequency, @@ -233,7 +230,6 @@ export function createFilter(context, start, end, params, cps, cycle) { const offset = envAbs * anchor; let min = clamp(2 ** -offset * frequency, 0, 20000); let max = clamp(2 ** (envAbs - offset) * frequency, 0, 20000); - if (env < 0) [min, max] = [max, min]; getParamADSR(frequencyParam, attack, decay, sustain, release, min, max, start, end, 'exponential'); } @@ -243,17 +239,19 @@ export function createFilter(context, start, end, params, cps, cycle) { } const hasLFO = [depth, skew, shape, rate].some((v) => v !== undefined); if (hasLFO) { - depth = depth ?? 1 - - const mag = Math.abs(depth); - const sign = Math.sign(depth); - - const shaped = 2 ** (mag * (1 - dcoffset)); - const dp = clamp((sign * shaped * frequency) - frequency, -20000, 20000); - console.info(dp) + depth = depth ?? 1; const time = cycle / cps; - // let d = 2 ** -dcoffset - const lfoValues = { depth: dp, dcoffset, skew, shape, frequency: rate, min: 10, max: 20000, time }; + const lfoValues = { + depth: (depth ?? 1) * frequency, + dcoffset, + skew, + shape, + frequency: rate ?? cps, + min: -frequency + 30, + max: 20000 - frequency, + time, + curve: 1, + }; getParamLfo(context, frequencyParam, start, end, lfoValues); } @@ -403,7 +401,7 @@ export function applyFM(param, value, begin) { duration, } = value; let modulator; - let stop = () => { }; + let stop = () => {}; if (fmModulationIndex) { const ac = getAudioContext();