docs
This commit is contained in:
parent
8a502e886e
commit
b4af840240
1 changed files with 21 additions and 21 deletions
|
|
@ -75,7 +75,12 @@ const waveshapes = {
|
||||||
return v - polyBlep(phase, dt);
|
return v - polyBlep(phase, dt);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
function getParamValue(block, param) {
|
||||||
|
if (param.length > 1) {
|
||||||
|
return param[block];
|
||||||
|
}
|
||||||
|
return param[0];
|
||||||
|
}
|
||||||
const waveShapeNames = Object.keys(waveshapes);
|
const waveShapeNames = Object.keys(waveshapes);
|
||||||
class LFOProcessor extends AudioWorkletProcessor {
|
class LFOProcessor extends AudioWorkletProcessor {
|
||||||
static get parameterDescriptors() {
|
static get parameterDescriptors() {
|
||||||
|
|
@ -364,7 +369,7 @@ function getUnisonDetune(unison, detune, voiceIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function applySemitoneDetuneToFrequency(frequency, detune) {
|
function applySemitoneDetuneToFrequency(frequency, detune) {
|
||||||
return frequency * Math.pow(2, detune / 12)
|
return frequency * Math.pow(2, detune / 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SuperSawOscillatorProcessor extends AudioWorkletProcessor {
|
class SuperSawOscillatorProcessor extends AudioWorkletProcessor {
|
||||||
|
|
@ -443,8 +448,7 @@ class SuperSawOscillatorProcessor extends AudioWorkletProcessor {
|
||||||
const isOdd = (n & 1) == 1;
|
const isOdd = (n & 1) == 1;
|
||||||
|
|
||||||
//applies unison "spread" detune in semitones
|
//applies unison "spread" detune in semitones
|
||||||
const freq = applySemitoneDetuneToFrequency(frequency, getUnisonDetune(voices, freqspread, n))
|
const freq = applySemitoneDetuneToFrequency(frequency, getUnisonDetune(voices, freqspread, n));
|
||||||
// const freq = frequency * Math.pow(2, getUnisonDetune(voices, freqspread, n) / 12);
|
|
||||||
let gainL = gain1;
|
let gainL = gain1;
|
||||||
let gainR = gain2;
|
let gainR = gain2;
|
||||||
// invert right and left gain
|
// invert right and left gain
|
||||||
|
|
@ -655,10 +659,7 @@ class PhaseVocoderProcessor extends OLAProcessor {
|
||||||
|
|
||||||
registerProcessor('phase-vocoder-processor', PhaseVocoderProcessor);
|
registerProcessor('phase-vocoder-processor', PhaseVocoderProcessor);
|
||||||
|
|
||||||
|
|
||||||
class PulseOscillatorProcessor extends AudioWorkletProcessor {
|
class PulseOscillatorProcessor extends AudioWorkletProcessor {
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.pi = _PI;
|
this.pi = _PI;
|
||||||
|
|
@ -671,7 +672,6 @@ class PulseOscillatorProcessor extends AudioWorkletProcessor {
|
||||||
this.envf = 0; // filtered envelope
|
this.envf = 0; // filtered envelope
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static get parameterDescriptors() {
|
static get parameterDescriptors() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|
@ -694,10 +694,11 @@ class PulseOscillatorProcessor extends AudioWorkletProcessor {
|
||||||
min: Number.EPSILON,
|
min: Number.EPSILON,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'detune',
|
name: 'detune',
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
min: Number.NEGATIVE_INFINITY,
|
min: Number.NEGATIVE_INFINITY,
|
||||||
max: Number.POSITIVE_INFINITY},
|
max: Number.POSITIVE_INFINITY,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'pulsewidth',
|
name: 'pulsewidth',
|
||||||
defaultValue: 1,
|
defaultValue: 1,
|
||||||
|
|
@ -708,22 +709,22 @@ class PulseOscillatorProcessor extends AudioWorkletProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
process(inputs, outputs, params) {
|
process(inputs, outputs, params) {
|
||||||
if (currentTime <= params.begin[0]) {
|
if (currentTime <= params.begin[0]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (currentTime >= params.end[0]) {
|
if (currentTime >= params.end[0]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const output = outputs[0];
|
const output = outputs[0];
|
||||||
let env = 1, dphi;
|
let env = 1,
|
||||||
let pw = clamp(params.pulsewidth[0], 0.01, 0.99) * _PI * 2
|
dphi;
|
||||||
let detune = params.detune[0];
|
|
||||||
let freq = applySemitoneDetuneToFrequency(params.frequency[0], detune /100)
|
|
||||||
|
|
||||||
for (let i = 0; i < (output[0].length ?? 0); i++) {
|
for (let i = 0; i < (output[0].length ?? 0); i++) {
|
||||||
|
const pw = clamp(getParamValue(i, params.pulsewidth), 0.01, 0.99) * _PI * 2;
|
||||||
|
const detune = getParamValue(i, params.detune);
|
||||||
|
const freq = applySemitoneDetuneToFrequency(getParamValue(i, params.frequency), detune / 100);
|
||||||
|
|
||||||
|
dphi = freq * (this.pi / (sampleRate * 0.5)); // phase increment
|
||||||
dphi = freq * (this.pi / (sampleRate * .5)); // phase increment
|
|
||||||
this.dphif += 0.1 * (dphi - this.dphif);
|
this.dphif += 0.1 * (dphi - this.dphif);
|
||||||
|
|
||||||
env *= 0.9998; // exponential decay envelope
|
env *= 0.9998; // exponential decay envelope
|
||||||
|
|
@ -744,12 +745,11 @@ class PulseOscillatorProcessor extends AudioWorkletProcessor {
|
||||||
// Second half-Tomisawa generator (with phase offset for pulse width)
|
// Second half-Tomisawa generator (with phase offset for pulse width)
|
||||||
let out1 = Math.cos(this.phi + this.B * this.Y1 + pw);
|
let out1 = Math.cos(this.phi + this.B * this.Y1 + pw);
|
||||||
this.Y1 = 0.5 * (out1 + this.Y1); // anti-hunting filter
|
this.Y1 = 0.5 * (out1 + this.Y1); // anti-hunting filter
|
||||||
|
|
||||||
for (let o = 0; o < output.length; o++) {
|
for (let o = 0; o < output.length; o++) {
|
||||||
// Combination of both oscillators with envelope applied
|
// Combination of both oscillators with envelope applied
|
||||||
output[o][i] = 0.15 * (out0 - out1) * this.envf;
|
output[o][i] = 0.15 * (out0 - out1) * this.envf;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true; // keep the audio processing going
|
return true; // keep the audio processing going
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue