simplify
This commit is contained in:
parent
40de717cc9
commit
7f86eac8f1
1 changed files with 5 additions and 10 deletions
|
|
@ -82,22 +82,17 @@ export function createFilter(context, type, frequency, Q, attack, decay, sustain
|
||||||
const filter = context.createBiquadFilter();
|
const filter = context.createBiquadFilter();
|
||||||
filter.type = type;
|
filter.type = type;
|
||||||
filter.Q.value = Q;
|
filter.Q.value = Q;
|
||||||
frequency = Math.max(frequency, 20);
|
|
||||||
filter.frequency.value = frequency;
|
filter.frequency.value = frequency;
|
||||||
|
|
||||||
// Apply ADSR to filter frequency
|
// Apply ADSR to filter frequency
|
||||||
if (fenv !== 0) {
|
if (fenv !== 0) {
|
||||||
let anchor = 0.5;
|
const anchor = 0.5;
|
||||||
let offset = fenv * anchor;
|
const offset = fenv * anchor;
|
||||||
let min = 2 ** -offset;
|
|
||||||
let max = 2 ** (fenv - offset);
|
|
||||||
min *= frequency;
|
|
||||||
max *= frequency;
|
|
||||||
|
|
||||||
min = clamp(min, 0, 20000);
|
const min = clamp(2 ** -offset * frequency, 0, 20000);
|
||||||
max = clamp(max, 0, 20000);
|
const max = clamp(2 ** (fenv - offset) * frequency, 0, 20000);
|
||||||
|
|
||||||
console.log('min', min, 'max', max);
|
// console.log('min', min, 'max', max);
|
||||||
|
|
||||||
getParamADSR(filter.frequency, attack, decay, sustain, release, min, max, start, end);
|
getParamADSR(filter.frequency, attack, decay, sustain, release, min, max, start, end);
|
||||||
return filter;
|
return filter;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue