From ef2ee0969ade3aa331616c1b37e5daf069edcd33 Mon Sep 17 00:00:00 2001 From: Aria Date: Sat, 13 Dec 2025 14:59:14 -0600 Subject: [PATCH] Restore old lfo to avoid unifying right now --- packages/superdough/helpers.mjs | 24 +++++++++++++++++++++++- packages/superdough/superdough.mjs | 10 ++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/packages/superdough/helpers.mjs b/packages/superdough/helpers.mjs index 19064954..3b704cae 100644 --- a/packages/superdough/helpers.mjs +++ b/packages/superdough/helpers.mjs @@ -109,7 +109,29 @@ export function getEnvelope(audioContext, properties = {}) { return getWorklet(audioContext, 'envelope-processor', properties); } -export function getLfo(audioContext, properties = {}) { +export function getLfo(audioContext, begin, end, properties = {}) { + const { shape = 0, ...props } = properties; + const { dcoffset = -0.5, depth = 1 } = properties; + const lfoprops = { + frequency: 1, + depth, + skew: 0.5, + phaseoffset: 0, + time: begin, + begin, + end, + shape: getModulationShapeInput(shape), + dcoffset, + min: dcoffset * depth, + max: dcoffset * depth + depth, + curve: 1, + ...props, + }; + + return getWorklet(audioContext, 'lfo-processor', lfoprops); +} + +export function getCustomLfo(audioContext, properties = {}) { // Extract some params we need for deriving other params const { shape = 0, ...props } = properties; const lfoprops = { diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index 6fcc9cec..04e383c4 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -443,7 +443,7 @@ function _getTargetParamsForControl(control, nodes, subControl) { return { targetParams: audioParams, paramName }; } -function connectLFO(idx, params, nodeTracker, value) { +function connectLFO(idx, params, nodeTracker) { const { rate = 1, sync, cps, cycle, control = 'lfo', subControl, depth = 1, depthabs, ...filteredParams } = params; const { targetParams, paramName } = _getTargetParamsForControl(control, nodeTracker, subControl); const currentValue = targetParams[0].value; @@ -457,13 +457,13 @@ function connectLFO(idx, params, nodeTracker, value) { min, max, }; - const lfoNode = getLfo(getAudioContext(), modParams); + const lfoNode = getCustomLfo(getAudioContext(), modParams); nodeTracker[`lfo${idx}`] = [lfoNode]; targetParams.forEach((t) => lfoNode.connect(t)); return lfoNode; } -function connectEnvelope(idx, params, nodeTracker, value) { +function connectEnvelope(idx, params, nodeTracker) { const { control, subControl, acurve, dcurve, rcurve, depth = 1, depthabs, ...filteredParams } = params; const { targetParams, paramName } = _getTargetParamsForControl(control, nodeTracker, subControl); const currentValue = targetParams[0].value; @@ -997,7 +997,6 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) end: endWithRelease, }, nodes, - value, ); audioNodes.push(lfo); } @@ -1012,14 +1011,13 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) end: endWithRelease, }, nodes, - value, ); audioNodes.push(env); } } if (value.bmod) { for (const p of value.bmod) { - const { toCleanup } = connectBusModulator({ ...p, begin: t, end: endWithRelease }, nodes, value); + const { toCleanup } = connectBusModulator({ ...p, begin: t, end: endWithRelease }, nodes); audioNodes.push(...toCleanup); } }