fixed
This commit is contained in:
parent
1d189763b2
commit
3d37c73103
3 changed files with 12 additions and 11 deletions
|
|
@ -464,9 +464,9 @@ export const { byteBeatExpression, bbexpr } = registerControl('byteBeatExpressio
|
||||||
* @name byteBeatStartTime
|
* @name byteBeatStartTime
|
||||||
* @synonyms bbst
|
* @synonyms bbst
|
||||||
*
|
*
|
||||||
* @param {number | Pattern} byteBeatStartTime in seconds
|
* @param {number | Pattern} byteBeatStartTime in samples (t)
|
||||||
* @example
|
* @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');
|
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);
|
let envGain = gainNode(1);
|
||||||
envGain = o.connect(envGain);
|
envGain = o.connect(envGain);
|
||||||
|
|
|
||||||
|
|
@ -811,11 +811,10 @@ class ByteBeatProcessor extends AudioWorkletProcessor {
|
||||||
super();
|
super();
|
||||||
this.port.onmessage = (event) => {
|
this.port.onmessage = (event) => {
|
||||||
let { codeText } = event.data;
|
let { codeText } = event.data;
|
||||||
const { startTimeSeconds, frequency } = event.data;
|
const { byteBeatStartTime } = event.data;
|
||||||
if (startTimeSeconds != null) {
|
if (byteBeatStartTime != null) {
|
||||||
const t = startTimeSeconds * sampleRate;
|
this.t = 0
|
||||||
this.t = t;
|
this.initialOffset = Math.floor(byteBeatStartTime)
|
||||||
this.t = (t / (sampleRate / 256)) * frequency;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Optimization pulled from dollchan.net: https://github.com/Chasyxx/EnBeat_NEW, it seemed important
|
//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.func = getByteBeatFunc(codeText);
|
||||||
};
|
};
|
||||||
|
this.initialOffset = null;
|
||||||
this.t = null;
|
this.t = null;
|
||||||
this.func = null;
|
this.func = null;
|
||||||
}
|
}
|
||||||
|
|
@ -878,13 +878,14 @@ class ByteBeatProcessor extends AudioWorkletProcessor {
|
||||||
for (let i = 0; i < output[0].length; i++) {
|
for (let i = 0; i < output[0].length; i++) {
|
||||||
const detune = getParamValue(i, params.detune);
|
const detune = getParamValue(i, params.detune);
|
||||||
const freq = applySemitoneDetuneToFrequency(getParamValue(i, params.frequency), detune / 100);
|
const freq = applySemitoneDetuneToFrequency(getParamValue(i, params.frequency), detune / 100);
|
||||||
let t = (this.t / (sampleRate / 256)) * freq;
|
let local_t = ((this.t / (sampleRate / 256)) * freq) + this.initialOffset
|
||||||
const funcValue = this.func(t);
|
const funcValue = this.func(local_t);
|
||||||
let signal = (funcValue & 255) / 127.5 - 1;
|
let signal = (funcValue & 255) / 127.5 - 1;
|
||||||
const out = signal * 0.2;
|
const out = signal * 0.2;
|
||||||
|
|
||||||
for (let c = 0; c < output.length; c++) {
|
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;
|
this.t = this.t + 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue