anchored fenv, more logical with negative values

- defaulting to .5 for now...
This commit is contained in:
Felix Roos 2023-09-16 00:44:03 +02:00
parent ee314e9b03
commit df211c994d

View File

@ -87,14 +87,15 @@ export function createFilter(context, type, frequency, Q, attack, decay, sustain
// Apply ADSR to filter frequency // Apply ADSR to filter frequency
if (fenv !== 0) { if (fenv !== 0) {
let min = frequency; let anchor = 0.5;
let max = frequency * 2 ** Math.abs(fenv); let offset = fenv * anchor;
if (fenv < 0) { let min = 2 ** -offset;
// flip min max to keep range the same for negative envelope let max = 2 ** (fenv - offset);
// comment this out to flip the range as well... min *= frequency;
[min, max] = [max, min]; max *= frequency;
}
// console.log('min', min, 'max', max); //console.log('min', min, 'max', max);
min = clamp(min + frequency, 0, 20000); min = clamp(min + frequency, 0, 20000);
max = clamp(max + frequency, 0, 20000); max = clamp(max + frequency, 0, 20000);
getParamADSR(filter.frequency, attack, decay, sustain, release, min, max, start, end); getParamADSR(filter.frequency, attack, decay, sustain, release, min, max, start, end);