From 4b4290e0871eab7f83828d26644dc9c1d47c7f92 Mon Sep 17 00:00:00 2001 From: Jade Rowland Date: Tue, 7 Nov 2023 22:52:39 -0500 Subject: [PATCH] add more parameters --- packages/core/controls.mjs | 26 +++++++++++++++++++++++++- packages/superdough/superdough.mjs | 12 +++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index 58b027ba..4414219e 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -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'], diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index 3e63a55a..00e2f42c 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -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); }