format
This commit is contained in:
parent
b8d2d02466
commit
65f1760fad
3 changed files with 11 additions and 18 deletions
|
|
@ -144,14 +144,13 @@ export function registerSynthSounds() {
|
|||
{ prebake: true, type: 'synth' },
|
||||
);
|
||||
|
||||
|
||||
registerSound(
|
||||
'bytebeat',
|
||||
(begin, value, onended) => {
|
||||
const ac = getAudioContext();
|
||||
let { byteBeatExpression } = value;
|
||||
|
||||
let { duration} = value;
|
||||
let { duration } = value;
|
||||
const [attack, decay, sustain, release] = getADSRValues(
|
||||
[value.attack, value.decay, value.sustain, value.release],
|
||||
'linear',
|
||||
|
|
@ -163,7 +162,6 @@ export function registerSynthSounds() {
|
|||
ac,
|
||||
'byte-beat-processor',
|
||||
{
|
||||
|
||||
begin,
|
||||
end,
|
||||
},
|
||||
|
|
@ -172,14 +170,13 @@ export function registerSynthSounds() {
|
|||
},
|
||||
);
|
||||
|
||||
|
||||
o.port.postMessage(byteBeatExpression);
|
||||
|
||||
let envGain = gainNode(1);
|
||||
envGain = o.connect(envGain);
|
||||
|
||||
getParamADSR(envGain.gain, attack, decay, sustain, release, 0, 1, begin, holdend, 'linear');
|
||||
|
||||
|
||||
let timeoutNode = webAudioTimeout(
|
||||
ac,
|
||||
() => {
|
||||
|
|
|
|||
|
|
@ -762,12 +762,10 @@ class PulseOscillatorProcessor extends AudioWorkletProcessor {
|
|||
|
||||
registerProcessor('pulse-oscillator', PulseOscillatorProcessor);
|
||||
|
||||
|
||||
|
||||
class ByteBeatProcessor extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
super();
|
||||
this.bb = '0'
|
||||
this.bb = '0';
|
||||
this.port.onmessage = (event) => {
|
||||
this.bb = event.data;
|
||||
};
|
||||
|
|
@ -801,20 +799,19 @@ class ByteBeatProcessor extends AudioWorkletProcessor {
|
|||
if (currentTime >= params.end[0]) {
|
||||
return false;
|
||||
}
|
||||
const bb = this.bb
|
||||
const bb = this.bb;
|
||||
|
||||
const f = Function('t', 'return ' + 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
|
||||
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] = signal
|
||||
output[o][i] = signal;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue