From ee01b4a3a03e1c34ca08f11c05b13f46f675692b Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sun, 3 Mar 2024 18:57:30 -0500 Subject: [PATCH] working on it --- packages/superdough/synth.mjs | 1 - packages/superdough/worklets.mjs | 87 ++------------------------------ 2 files changed, 4 insertions(+), 84 deletions(-) diff --git a/packages/superdough/synth.mjs b/packages/superdough/synth.mjs index a6a553b5..50f2f0f4 100644 --- a/packages/superdough/synth.mjs +++ b/packages/superdough/synth.mjs @@ -57,7 +57,6 @@ export function registerSynthSounds() { 'better-oscillator', { frequency: freq, - wave: i, begin, end, }, diff --git a/packages/superdough/worklets.mjs b/packages/superdough/worklets.mjs index a05c9dbd..6517ed89 100644 --- a/packages/superdough/worklets.mjs +++ b/packages/superdough/worklets.mjs @@ -167,35 +167,11 @@ class BetterOscillatorProcessor extends AudioWorkletProcessor { min: 0, }, - { - name: 'phase', - defaultValue: 0, - max: 1, - min: 0, - }, - - { - name: 'duty', - defaultValue: 0.5, - min: 0, - max: 1, - }, { name: 'frequency', defaultValue: 440, min: Number.EPSILON, }, - { - name: 'wave', - defaultValue: 3, - min: 0, - max: 3, - }, - { - name: 'sync', - defaultValue: 0, - min: 0, - }, ]; } process(input, outputs, params) { @@ -219,10 +195,11 @@ class BetterOscillatorProcessor extends AudioWorkletProcessor { adj = isOdd ? n * detune : -((n - 1) * detune); } this.freq[n] = frequency + adj * 0.01 * frequency; - // if (isOdd) { - // this.balance[n][0] = - // } this.balance[n] = isOdd ? 1 - spread : spread; + + // for (let i = 0; i < output[0].length; i++) { + + // } } for (let i = 0; i < output[0].length; i++) { @@ -233,11 +210,7 @@ class BetterOscillatorProcessor extends AudioWorkletProcessor { const osc = polySaw(this.phase[n], this.freq[n] / sampleRate); outL = outL + osc * (1 - this.balance[n]); outR = outR + osc * this.balance[n]; - - // out = out + polySaw(this.phase[n], this.freq[n] / sampleRate); - this.phase[n] = this.phase[n] ?? Math.random(); - this.phase[n] += dt; if (this.phase[n] > 1.0) { @@ -247,60 +220,8 @@ class BetterOscillatorProcessor extends AudioWorkletProcessor { output[0][i] = outL; output[1][i] = outR; - // for (let c = 0; c < output.length; c++) { - // let modifier = c === 0 ? 1 - spread : spread; - // output[c][i] = out * modifier; - // } - // for (let c = 0; c < outputs.length; c++) { - // outputs[c][0][i] = out; - // } } return true; - - // for (let z = 0; z < outputs.length; z++) { - // const out = outputs[z][0]; - // const outlen = out.length; - // const freq = params.frequency.length === 1; - // const phase = params.phase.length === 1; - // const wave = params.wave.length === 1; - // const duty = params.duty.length === 1; - // const sync = params.sync.length === 1; - - // let back = 0; - // for (let x = 0; x < outlen; x++) { - // this.sync_phase = this.prev_sync_phase % (params.sync[sync ? 0 : x] / sampleRate); - // if (params.sync[sync ? 0 : x] !== 0 && this.prev_sync_phase >= params.sync[sync ? 0 : x] / sampleRate) { - // this.phase = 0; - // back = x; - // } - // this.prev_sync_phase = this.sync_phase; - // const main = (params.frequency[freq ? 0 : x] * (x - back)) / sampleRate; - // // noise - // if (params.wave[wave ? 0 : x] >= 4) { - // out[x] = Math.random() * 2 - 1; - // } else if (params.wave[wave ? 0 : x] >= 3) { - // // sine wave made using bulit-in Math.sin - // out[x] = Math.sin((main + this.phase + params.phase[phase ? 0 : x]) * 2 * Math.PI); - // // sawtooth wave using linear piecewise floor - // } else if (params.wave[wave ? 0 : x] >= 2) { - // // out[x] = polySaw(this.phase, main); - // const dt = main + params.phase[phase ? 0 : x]; - // out[x] = 2 * saw(this.phase + dt) - 1; - // console.log(polyBlep(this.phase, dt)); - // // pulse wave using difference of phase shifted saws and variable DC threshold - // } else if (params.wave[wave ? 0 : x] >= 1) { - // const temp = main + this.phase + params.phase[phase ? 0 : x]; - // out[x] = saw(temp) - saw(temp + params.duty[duty ? 0 : x]) > 0 ? 1 : -1; - // // triangle wave using absolute value of amplitude shifted sawtooth wave - // } else if (params.wave[wave ? 0 : x] >= 0) { - // out[x] = 4 * Math.abs(saw(main + this.phase + params.phase[phase ? 0 : x]) - 1 / 2) - 1; - // } - // this.prev_sync_phase += 1 / sampleRate; - // } - // this.phase += (params.frequency[freq ? 0 : outlen - 1] * outlen) / sampleRate; - // this.phase %= sampleRate; - // return true; - // } } }