create free running lfos for different orbits

This commit is contained in:
Jade Rowland 2023-11-07 22:09:53 -05:00
parent 2e4d28b910
commit 65d07dbff2

View file

@ -112,18 +112,25 @@ function getDelay(orbit, delaytime, delayfeedback, t) {
return delays[orbit]; return delays[orbit];
} }
function getPhaser(speed = 1, depth = 0.5) { const phaserLFOs = {};
function getPhaser(orbit, t, speed = 1, depth = 0.5) {
//gain //gain
const ac = getAudioContext(); const ac = getAudioContext();
const lfoGain = ac.createGain(); const lfoGain = ac.createGain();
lfoGain.gain.value = 2000; lfoGain.gain.value = 2000;
//lfo TODO: set the lfo phase relative to current cycle to create "free running" effect //LFO
const lfo = ac.createOscillator(); if (phaserLFOs[orbit] == null) {
lfo.frequency.value = speed; phaserLFOs[orbit] = ac.createOscillator();
lfo.type = 'sine'; phaserLFOs[orbit].frequency.value = speed;
lfo.start(); phaserLFOs[orbit].type = 'sine';
lfo.connect(lfoGain); phaserLFOs[orbit].start();
}
phaserLFOs[orbit].connect(lfoGain);
if (phaserLFOs[orbit].frequency.value != speed) {
phaserLFOs[orbit].frequency.setValueAtTime(speed, t);
}
//filters //filters
const numStages = 2; //num of filters in series const numStages = 2; //num of filters in series
@ -419,7 +426,7 @@ export const superdough = async (value, deadline, hapDuration) => {
} }
// phaser // phaser
if (phaser !== undefined && phaserdepth > 0) { if (phaser !== undefined && phaserdepth > 0) {
const phaserFX = getPhaser(phaser, phaserdepth); const phaserFX = getPhaser(orbit, t, phaser, phaserdepth);
chain.push(phaserFX); chain.push(phaserFX);
} }