add more parameters

This commit is contained in:
Jade Rowland 2023-11-07 22:52:39 -05:00
parent c89f91215c
commit 4b4290e087
2 changed files with 32 additions and 6 deletions

View File

@ -391,13 +391,37 @@ const generic_params = [
*
*/
['phaser'],
/**
* The frequency sweep range of the lfo for the phaser effect
*
* @name phasersweep
* @param {number | Pattern} phasersweep most useful values are between 0 and 4000
* @example
* run(8).scale("D:pentatonic").note().sound("sawtooth").release(0.5).phaser("2 8").phasersweep(800)
*
*/
['phasersweep'],
/**
* The center frequency of the phaser in HZ
*
* @name phasercenter
* @param {number | Pattern} centerfrequency most useful values are between 0 and 1
* @example
* run(8).scale("D:pentatonic").note().sound("sawtooth").release(0.5).phaser("2 8").phasercenter(2000)
*
*/
['phasercenter'],
/**
* The amount the signal is affected by the phaser effect
*
* @name phaserdepth
* @param {number | Pattern} depth number between 0 and 1
* @example
* run(8).scale("D:pentatonic").note().sound("sawtooth").release(0.5).phaser("2 8").phaserdepth(0.5)
* run(8).scale("D:pentatonic").note().sound("sawtooth").release(0.5).phaser("2 8").phasercenter(200)
*
*/
['phaserdepth'],

View File

@ -112,12 +112,13 @@ function getDelay(orbit, delaytime, delayfeedback, t) {
return delays[orbit];
}
// each orbit will have its own lfo
const phaserLFOs = {};
function getPhaser(orbit, t, speed = 1, depth = 0.5) {
function getPhaser(orbit, t, speed = 1, depth = 0.5, centerFrequency = 1000, sweep = 2000) {
//gain
const ac = getAudioContext();
const lfoGain = ac.createGain();
lfoGain.gain.value = 2000;
lfoGain.gain.value = sweep;
//LFO
if (phaserLFOs[orbit] == null) {
@ -140,7 +141,7 @@ function getPhaser(orbit, t, speed = 1, depth = 0.5) {
const filter = ac.createBiquadFilter();
filter.type = 'notch';
filter.gain.value = 1;
filter.frequency.value = 1000 + fOffset;
filter.frequency.value = centerFrequency + fOffset;
filter.Q.value = 2 - Math.min(Math.max(depth * 2, 0), 1.9);
lfoGain.connect(filter.detune);
@ -271,6 +272,8 @@ export const superdough = async (value, deadline, hapDuration) => {
//phaser
phaser,
phaserdepth = 0.75,
phasersweep,
phasercenter,
//
coarse,
crush,
@ -411,7 +414,6 @@ export const superdough = async (value, deadline, hapDuration) => {
coarse !== undefined && chain.push(getWorklet(ac, 'coarse-processor', { coarse }));
crush !== undefined && chain.push(getWorklet(ac, 'crush-processor', { crush }));
shape !== undefined && chain.push(getWorklet(ac, 'shape-processor', { shape }));
// phaser !== undefined && chain.push(getWorklet(ac, 'phaser-processor', { phaser }));
compressorThreshold !== undefined &&
chain.push(
@ -426,7 +428,7 @@ export const superdough = async (value, deadline, hapDuration) => {
}
// phaser
if (phaser !== undefined && phaserdepth > 0) {
const phaserFX = getPhaser(orbit, t, phaser, phaserdepth);
const phaserFX = getPhaser(orbit, t, phaser, phaserdepth, phasercenter, phasersweep);
chain.push(phaserFX);
}