This commit is contained in:
Jade (Rose) Rowland
2025-11-22 23:42:20 -05:00
parent 30e672a027
commit 7bbb653963
2 changed files with 20 additions and 15 deletions
+7
View File
@@ -1294,6 +1294,8 @@ export const { fanchor } = registerControl('fanchor');
*
* @name lprate
* @param {number | Pattern} rate rate in hertz
* @example
* note("<c c c# c c c4>*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("<c c c# c c c4>*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("<c c c# c c c4>*16").s("sawtooth").lpf(600).lpdepth("<1 .5 1.8 0>")
*/
export const { lpdepth } = registerControl('lpdepth');
/**
+13 -15
View File
@@ -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();