mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-13 14:26:58 -04:00
fixed
This commit is contained in:
@@ -464,9 +464,9 @@ export const { byteBeatExpression, bbexpr } = registerControl('byteBeatExpressio
|
||||
* @name byteBeatStartTime
|
||||
* @synonyms bbst
|
||||
*
|
||||
* @param {number | Pattern} byteBeatStartTime in seconds
|
||||
* @param {number | Pattern} byteBeatStartTime in samples (t)
|
||||
* @example
|
||||
* note("{c g a b c d}%16").s("bytebeat").bbexpr('t&t>>8').bbst("<0 300>")
|
||||
* note("c3!8".add("{0 0 12 0 7 5 3}%8")).s("bytebeat:5").bbst("<3 1>".mul(10000))._scope()
|
||||
*
|
||||
*/
|
||||
export const { byteBeatStartTime, bbst } = registerControl('byteBeatStartTime', 'bbst');
|
||||
|
||||
@@ -192,7 +192,7 @@ export function registerSynthSounds() {
|
||||
},
|
||||
);
|
||||
|
||||
o.port.postMessage({ codeText: byteBeatExpression, startTimeSeconds: byteBeatStartTime, frequency });
|
||||
o.port.postMessage({ codeText: byteBeatExpression, byteBeatStartTime, frequency });
|
||||
|
||||
let envGain = gainNode(1);
|
||||
envGain = o.connect(envGain);
|
||||
|
||||
@@ -811,11 +811,10 @@ class ByteBeatProcessor extends AudioWorkletProcessor {
|
||||
super();
|
||||
this.port.onmessage = (event) => {
|
||||
let { codeText } = event.data;
|
||||
const { startTimeSeconds, frequency } = event.data;
|
||||
if (startTimeSeconds != null) {
|
||||
const t = startTimeSeconds * sampleRate;
|
||||
this.t = t;
|
||||
this.t = (t / (sampleRate / 256)) * frequency;
|
||||
const { byteBeatStartTime } = event.data;
|
||||
if (byteBeatStartTime != null) {
|
||||
this.t = 0
|
||||
this.initialOffset = Math.floor(byteBeatStartTime)
|
||||
}
|
||||
|
||||
//Optimization pulled from dollchan.net: https://github.com/Chasyxx/EnBeat_NEW, it seemed important
|
||||
@@ -829,6 +828,7 @@ class ByteBeatProcessor extends AudioWorkletProcessor {
|
||||
|
||||
this.func = getByteBeatFunc(codeText);
|
||||
};
|
||||
this.initialOffset = null;
|
||||
this.t = null;
|
||||
this.func = null;
|
||||
}
|
||||
@@ -878,13 +878,14 @@ class ByteBeatProcessor extends AudioWorkletProcessor {
|
||||
for (let i = 0; i < output[0].length; i++) {
|
||||
const detune = getParamValue(i, params.detune);
|
||||
const freq = applySemitoneDetuneToFrequency(getParamValue(i, params.frequency), detune / 100);
|
||||
let t = (this.t / (sampleRate / 256)) * freq;
|
||||
const funcValue = this.func(t);
|
||||
let local_t = ((this.t / (sampleRate / 256)) * freq) + this.initialOffset
|
||||
const funcValue = this.func(local_t);
|
||||
let signal = (funcValue & 255) / 127.5 - 1;
|
||||
const out = signal * 0.2;
|
||||
|
||||
for (let c = 0; c < output.length; c++) {
|
||||
output[c][i] = clamp(out, -0.2, 0.2);
|
||||
//prevent speaker blowout via clipping if threshold exceeds
|
||||
output[c][i] = clamp(out, -0.4, 0.4);
|
||||
}
|
||||
this.t = this.t + 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user