fileter envelopes

This commit is contained in:
Jade Rowland 2023-12-15 12:16:28 -07:00
parent 7da7554493
commit 9663c2ec85
4 changed files with 34 additions and 36 deletions

View file

@ -9,7 +9,7 @@ import './reverb.mjs';
import './vowel.mjs';
import { clamp, nanFallback } from './util.mjs';
import workletsUrl from './worklets.mjs?url';
import { createFilter, gainNode, getCompressor } from './helpers.mjs';
import { createFilter, gainNode, getADSRValues, getCompressor } from './helpers.mjs';
import { map } from 'nanostores';
import { logger } from './logger.mjs';
import { loadBuffer } from './sampler.mjs';
@ -269,26 +269,16 @@ export const superdough = async (value, deadline, hapDuration) => {
// low pass
cutoff,
lpenv,
lpattack = 0.01,
lpdecay = 0.01,
lpsustain = 1,
lprelease = 0.01,
resonance = 1,
// high pass
hpenv,
hcutoff,
hpattack = 0.01,
hpdecay = 0.01,
hpsustain = 1,
hprelease = 0.01,
hresonance = 1,
// band pass
bpenv,
bandf,
bpattack = 0.01,
bpdecay = 0.01,
bpsustain = 1,
bprelease = 0.01,
bandq = 1,
channels = [1, 2],
//phaser
@ -322,6 +312,7 @@ export const superdough = async (value, deadline, hapDuration) => {
compressorAttack,
compressorRelease,
} = value;
gain = nanFallback(gain, 1);
//music programs/audio gear usually increments inputs/outputs from 1, so imitate that behavior
@ -366,7 +357,15 @@ export const superdough = async (value, deadline, hapDuration) => {
// gain stage
chain.push(gainNode(gain));
const filterEnvDefaults = [0.01, 0.01, 1, 0.01];
if (cutoff !== undefined) {
const [lpattack, lpdecay, lpsustain, lprelease] = getADSRValues(
[value.lpattack, value.lpdecay, value.lpsustain, value.lprelease],
filterEnvDefaults,
);
console.log(lpattack, 'atta');
let lp = () =>
createFilter(
ac,
@ -389,6 +388,10 @@ export const superdough = async (value, deadline, hapDuration) => {
}
if (hcutoff !== undefined) {
const [hpattack, hpdecay, hpsustain, hprelease] = getADSRValues(
[value.hpattack, value.hpdecay, value.hpsustain, value.hprelease],
filterEnvDefaults,
);
let hp = () =>
createFilter(
ac,
@ -411,6 +414,10 @@ export const superdough = async (value, deadline, hapDuration) => {
}
if (bandf !== undefined) {
const [bpattack, bpdecay, bpsustain, bprelease] = getADSRValues(
[value.bpattack, value.bpdecay, value.bpsustain, value.bprelease],
filterEnvDefaults,
);
let bp = () =>
createFilter(
ac,