Skip to content

Commit

Permalink
fix: codeformat
Browse files Browse the repository at this point in the history
  • Loading branch information
felixroos committed Jan 18, 2025
1 parent 2c880e2 commit 345ef22
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
1 change: 0 additions & 1 deletion packages/core/controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ export const { cutoff, ctf, lpf, lp } = registerControl(['cutoff', 'resonance',
*/
export const { lplfo } = registerControl('lplfo');


/**
* Sets the lowpass filter envelope modulation depth.
* @name lpenv
Expand Down
29 changes: 22 additions & 7 deletions packages/superdough/helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,27 @@ export const getADSRValues = (params, curve = 'linear', defaultValues) => {
return [Math.max(a ?? 0, envmin), Math.max(d ?? 0, envmin), Math.min(sustain, envmax), Math.max(r ?? 0, releaseMin)];
};

export function createFilter(context, type, frequency, Q, att, dec, sus, rel, fenv, start, end, fanchor, model, drive, flfo) {
export function createFilter(
context,
type,
frequency,
Q,
att,
dec,
sus,
rel,
fenv,
start,
end,
fanchor,
model,
drive,
flfo,
) {
const curve = 'exponential';
const [attack, decay, sustain, release] = getADSRValues([att, dec, sus, rel], curve, [0.005, 0.14, 0, 0.1]);
let filter;
let frequencyParam,detuneParam;
let frequencyParam, detuneParam;
if (model === 'ladder') {
filter = getWorklet(context, 'ladder-processor', { frequency, q: Q, drive });
frequencyParam = filter.parameters.get('frequency');
Expand All @@ -126,7 +142,7 @@ export function createFilter(context, type, frequency, Q, att, dec, sus, rel, fe
filter.Q.value = Q;
filter.frequency.value = frequency;
frequencyParam = filter.frequency;
detuneParam = filter.detune
detuneParam = filter.detune;
}

// envelope is active when any of these values is set
Expand All @@ -142,10 +158,9 @@ export function createFilter(context, type, frequency, Q, att, dec, sus, rel, fe
if (fenv < 0) [min, max] = [max, min];
getParamADSR(frequencyParam, attack, decay, sustain, release, min, max, start, end, curve);
}
const hasLFO = detuneParam&&flfo !== undefined;
const hasLFO = detuneParam && flfo !== undefined;
if (hasLFO !== undefined) {
let lfo = getVibratoOscillator(detuneParam, {vib:flfo,vibmod:4}, start);

let lfo = getVibratoOscillator(detuneParam, { vib: flfo, vibmod: 4 }, start);
}
return filter;
}
Expand Down Expand Up @@ -248,7 +263,7 @@ export function applyFM(param, value, begin) {
duration,
} = value;
let modulator;
let stop = () => { };
let stop = () => {};

if (fmModulationIndex) {
const ac = getAudioContext();
Expand Down

0 comments on commit 345ef22

Please sign in to comment.