add more parameters
This commit is contained in:
parent
c89f91215c
commit
4b4290e087
2 changed files with 32 additions and 6 deletions
|
|
@ -391,13 +391,37 @@ const generic_params = [
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
['phaser'],
|
['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
|
* The amount the signal is affected by the phaser effect
|
||||||
*
|
*
|
||||||
* @name phaserdepth
|
* @name phaserdepth
|
||||||
* @param {number | Pattern} depth number between 0 and 1
|
* @param {number | Pattern} depth number between 0 and 1
|
||||||
* @example
|
* @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'],
|
['phaserdepth'],
|
||||||
|
|
|
||||||
|
|
@ -112,12 +112,13 @@ function getDelay(orbit, delaytime, delayfeedback, t) {
|
||||||
return delays[orbit];
|
return delays[orbit];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// each orbit will have its own lfo
|
||||||
const phaserLFOs = {};
|
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
|
//gain
|
||||||
const ac = getAudioContext();
|
const ac = getAudioContext();
|
||||||
const lfoGain = ac.createGain();
|
const lfoGain = ac.createGain();
|
||||||
lfoGain.gain.value = 2000;
|
lfoGain.gain.value = sweep;
|
||||||
|
|
||||||
//LFO
|
//LFO
|
||||||
if (phaserLFOs[orbit] == null) {
|
if (phaserLFOs[orbit] == null) {
|
||||||
|
|
@ -140,7 +141,7 @@ function getPhaser(orbit, t, speed = 1, depth = 0.5) {
|
||||||
const filter = ac.createBiquadFilter();
|
const filter = ac.createBiquadFilter();
|
||||||
filter.type = 'notch';
|
filter.type = 'notch';
|
||||||
filter.gain.value = 1;
|
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);
|
filter.Q.value = 2 - Math.min(Math.max(depth * 2, 0), 1.9);
|
||||||
|
|
||||||
lfoGain.connect(filter.detune);
|
lfoGain.connect(filter.detune);
|
||||||
|
|
@ -271,6 +272,8 @@ export const superdough = async (value, deadline, hapDuration) => {
|
||||||
//phaser
|
//phaser
|
||||||
phaser,
|
phaser,
|
||||||
phaserdepth = 0.75,
|
phaserdepth = 0.75,
|
||||||
|
phasersweep,
|
||||||
|
phasercenter,
|
||||||
//
|
//
|
||||||
coarse,
|
coarse,
|
||||||
crush,
|
crush,
|
||||||
|
|
@ -411,7 +414,6 @@ export const superdough = async (value, deadline, hapDuration) => {
|
||||||
coarse !== undefined && chain.push(getWorklet(ac, 'coarse-processor', { coarse }));
|
coarse !== undefined && chain.push(getWorklet(ac, 'coarse-processor', { coarse }));
|
||||||
crush !== undefined && chain.push(getWorklet(ac, 'crush-processor', { crush }));
|
crush !== undefined && chain.push(getWorklet(ac, 'crush-processor', { crush }));
|
||||||
shape !== undefined && chain.push(getWorklet(ac, 'shape-processor', { shape }));
|
shape !== undefined && chain.push(getWorklet(ac, 'shape-processor', { shape }));
|
||||||
// phaser !== undefined && chain.push(getWorklet(ac, 'phaser-processor', { phaser }));
|
|
||||||
|
|
||||||
compressorThreshold !== undefined &&
|
compressorThreshold !== undefined &&
|
||||||
chain.push(
|
chain.push(
|
||||||
|
|
@ -426,7 +428,7 @@ export const superdough = async (value, deadline, hapDuration) => {
|
||||||
}
|
}
|
||||||
// phaser
|
// phaser
|
||||||
if (phaser !== undefined && phaserdepth > 0) {
|
if (phaser !== undefined && phaserdepth > 0) {
|
||||||
const phaserFX = getPhaser(orbit, t, phaser, phaserdepth);
|
const phaserFX = getPhaser(orbit, t, phaser, phaserdepth, phasercenter, phasersweep);
|
||||||
chain.push(phaserFX);
|
chain.push(phaserFX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue