From 65f1760fad44fdd8a452448a327dc6b9065780ca Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Tue, 20 May 2025 21:45:14 +0100 Subject: [PATCH] format --- packages/core/controls.mjs | 5 ++--- packages/superdough/synth.mjs | 7 ++----- packages/superdough/worklets.mjs | 17 +++++++---------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index 94f034480..5e0c450d6 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -446,19 +446,18 @@ export const { coarse } = registerControl('coarse'); export const { drive } = registerControl('drive'); /** - * Allows you to set the output channels on the interface + * Create byte beats with custom expressions * * @name byteBeatExpression * @synonyms bbexpr * * @param {number | Pattern} byteBeatExpression pattern the output channels * @example - * note("e a d b g").channels("3:4") + * s("bytebeat").bbexpr('t*(t>>15^t>>66)') * */ export const { byteBeatExpression, bbexpr } = registerControl('byteBeatExpression', 'bbexpr'); - /** * Allows you to set the output channels on the interface * diff --git a/packages/superdough/synth.mjs b/packages/superdough/synth.mjs index 63c5a0b37..dd2c92451 100644 --- a/packages/superdough/synth.mjs +++ b/packages/superdough/synth.mjs @@ -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, () => { diff --git a/packages/superdough/worklets.mjs b/packages/superdough/worklets.mjs index bd52e3233..8d14ac445 100644 --- a/packages/superdough/worklets.mjs +++ b/packages/superdough/worklets.mjs @@ -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; } }