bb
This commit is contained in:
parent
058cb36640
commit
b8d2d02466
4 changed files with 86 additions and 3 deletions
|
|
@ -767,7 +767,10 @@ registerProcessor('pulse-oscillator', PulseOscillatorProcessor);
|
|||
class ByteBeatProcessor extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
super();
|
||||
this.pi = _PI;
|
||||
this.bb = '0'
|
||||
this.port.onmessage = (event) => {
|
||||
this.bb = event.data;
|
||||
};
|
||||
}
|
||||
|
||||
static get parameterDescriptors() {
|
||||
|
|
@ -798,13 +801,20 @@ class ByteBeatProcessor extends AudioWorkletProcessor {
|
|||
if (currentTime >= params.end[0]) {
|
||||
return false;
|
||||
}
|
||||
const bb = this.bb
|
||||
|
||||
const f = Function('t', 'return ' + bb)
|
||||
|
||||
const output = outputs[0];
|
||||
|
||||
for (let i = 0; i < (output[0].length ?? 0); i++) {
|
||||
|
||||
let t = currentTime
|
||||
t *= sampleRate
|
||||
const signal = ((f(t)&255)/127.5 - 1)/4
|
||||
for (let o = 0; o < output.length; o++) {
|
||||
// Combination of both oscillators with envelope applied
|
||||
output[o][i] = 0.15 * (out0 - out1) * this.envf;
|
||||
output[o][i] = signal
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -812,4 +822,4 @@ class ByteBeatProcessor extends AudioWorkletProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
registerProcessor('byte-beat-processor', BeatBeatProcessor);
|
||||
registerProcessor('byte-beat-processor', ByteBeatProcessor);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue