From 75b6f59212d301e50ee01a33e7647a44ae4657ca Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sun, 20 Jul 2025 23:26:17 -0400 Subject: [PATCH 1/5] fix --- packages/superdough/superdough.mjs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index f3e04a04..96cf3f67 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -363,6 +363,22 @@ export function getLfo(audioContext, begin, end, properties = {}) { }); } +// export function getLfo(audioContext, time, end, properties = {}) { +// return getWorklet(audioContext, 'lfo-processor', { +// frequency: 1, +// depth: 1, +// skew: 0, +// phaseoffset: 0, +// time, +// begin: time, +// end, +// shape: 1, +// dcoffset: -0.5, +// ...properties, +// }); +// } + + export function getSyncedLfo(audioContext, time, end, cps, cycle, properties = {}) { const frequency = cycle / cps; From 9416f317d4a19446411f9e3e9db98cb030e8baf2 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sun, 20 Jul 2025 23:29:01 -0400 Subject: [PATCH 2/5] fixing... --- packages/superdough/superdough.mjs | 54 ++++++++++++------------- packages/superdough/worklets.mjs | 65 +++++++++++++++++++++++++++++- 2 files changed, 91 insertions(+), 28 deletions(-) diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index 96cf3f67..a591df0f 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -343,41 +343,41 @@ function getDelay(orbit, delaytime, delayfeedback, t, channels) { return delays[orbit]; } -export function getLfo(audioContext, begin, end, properties = {}) { - const { shape = 0, ...props } = properties; - const { dcoffset = -0.5, depth = 1 } = properties; - return getWorklet(audioContext, 'lfo-processor', { - frequency: 1, - depth, - skew: 0, - phaseoffset: 0, - time: begin, - begin, - end, - shape: getModulationShapeInput(shape), - dcoffset, - min: dcoffset - depth * 0.5, - max: dcoffset + depth * 0.5, - curve: 1, - ...props, - }); -} - -// export function getLfo(audioContext, time, end, properties = {}) { +// export function getLfo(audioContext, begin, end, properties = {}) { +// const { shape = 0, ...props } = properties; +// const { dcoffset = -0.5, depth = 1 } = properties; // return getWorklet(audioContext, 'lfo-processor', { // frequency: 1, -// depth: 1, +// depth, // skew: 0, // phaseoffset: 0, -// time, -// begin: time, +// time: begin, +// begin, // end, -// shape: 1, -// dcoffset: -0.5, -// ...properties, +// shape: getModulationShapeInput(shape), +// dcoffset, +// min: dcoffset - depth * 0.5, +// max: dcoffset + depth * 0.5, +// curve: 1, +// ...props, // }); // } +export function getLfo(audioContext, time, end, properties = {}) { + return getWorklet(audioContext, 'lfo-processor', { + frequency: 1, + depth: 1, + skew: 0, + phaseoffset: 0, + time, + begin: time, + end, + shape: 1, + dcoffset: -0.5, + ...properties, + }); +} + export function getSyncedLfo(audioContext, time, end, cps, cycle, properties = {}) { const frequency = cycle / cps; diff --git a/packages/superdough/worklets.mjs b/packages/superdough/worklets.mjs index b4b36f6c..25dae03c 100644 --- a/packages/superdough/worklets.mjs +++ b/packages/superdough/worklets.mjs @@ -81,7 +81,70 @@ function getParamValue(block, param) { } return param[0]; } -const waveShapeNames = Object.keys(waveshapes); +// const waveShapeNames = Object.keys(waveshapes); +// class LFOProcessor extends AudioWorkletProcessor { +// static get parameterDescriptors() { +// return [ +// { name: 'time', defaultValue: 0 }, +// { name: 'end', defaultValue: 0 }, +// { name: 'frequency', defaultValue: 0.5 }, +// { name: 'skew', defaultValue: 0.5 }, +// { name: 'depth', defaultValue: 1 }, +// { name: 'phaseoffset', defaultValue: 0 }, +// { name: 'shape', defaultValue: 0 }, +// { name: 'dcoffset', defaultValue: 0 }, +// ]; +// } + +// constructor() { +// super(); +// this.phase; +// } + +// incrementPhase(dt) { +// this.phase += dt; +// if (this.phase > 1.0) { +// this.phase = this.phase - 1; +// } +// } + +// process(inputs, outputs, parameters) { +// // eslint-disable-next-line no-undef +// if (currentTime >= parameters.end[0]) { +// return false; +// } + +// const output = outputs[0]; +// const frequency = parameters['frequency'][0]; + +// const time = parameters['time'][0]; +// const depth = parameters['depth'][0]; +// const skew = parameters['skew'][0]; +// const phaseoffset = parameters['phaseoffset'][0]; + +// const dcoffset = parameters['dcoffset'][0]; +// const shape = waveShapeNames[parameters['shape'][0]]; + +// const blockSize = output[0].length ?? 0; + +// if (this.phase == null) { +// this.phase = _mod(time * frequency + phaseoffset, 1); +// } +// // eslint-disable-next-line no-undef +// const dt = frequency / sampleRate; +// for (let n = 0; n < blockSize; n++) { +// for (let i = 0; i < output.length; i++) { +// const modval = (waveshapes[shape](this.phase, skew) + dcoffset) * depth; +// output[i][n] = modval; +// } +// this.incrementPhase(dt); +// } + +// return true; +// } +// } +// registerProcessor('lfo-processor', LFOProcessor); +// const waveShapeNames = Object.keys(waveshapes); class LFOProcessor extends AudioWorkletProcessor { static get parameterDescriptors() { return [ From ccf2a6de52c7a595188c3404e82735f50bb5ed85 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sun, 20 Jul 2025 23:38:16 -0400 Subject: [PATCH 3/5] fixing.. --- packages/superdough/superdough.mjs | 54 +++++++++++++++--------------- packages/superdough/worklets.mjs | 2 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index a591df0f..96cf3f67 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -343,41 +343,41 @@ function getDelay(orbit, delaytime, delayfeedback, t, channels) { return delays[orbit]; } -// export function getLfo(audioContext, begin, end, properties = {}) { -// const { shape = 0, ...props } = properties; -// const { dcoffset = -0.5, depth = 1 } = properties; -// return getWorklet(audioContext, 'lfo-processor', { -// frequency: 1, -// depth, -// skew: 0, -// phaseoffset: 0, -// time: begin, -// begin, -// end, -// shape: getModulationShapeInput(shape), -// dcoffset, -// min: dcoffset - depth * 0.5, -// max: dcoffset + depth * 0.5, -// curve: 1, -// ...props, -// }); -// } - -export function getLfo(audioContext, time, end, properties = {}) { +export function getLfo(audioContext, begin, end, properties = {}) { + const { shape = 0, ...props } = properties; + const { dcoffset = -0.5, depth = 1 } = properties; return getWorklet(audioContext, 'lfo-processor', { frequency: 1, - depth: 1, + depth, skew: 0, phaseoffset: 0, - time, - begin: time, + time: begin, + begin, end, - shape: 1, - dcoffset: -0.5, - ...properties, + shape: getModulationShapeInput(shape), + dcoffset, + min: dcoffset - depth * 0.5, + max: dcoffset + depth * 0.5, + curve: 1, + ...props, }); } +// export function getLfo(audioContext, time, end, properties = {}) { +// return getWorklet(audioContext, 'lfo-processor', { +// frequency: 1, +// depth: 1, +// skew: 0, +// phaseoffset: 0, +// time, +// begin: time, +// end, +// shape: 1, +// dcoffset: -0.5, +// ...properties, +// }); +// } + export function getSyncedLfo(audioContext, time, end, cps, cycle, properties = {}) { const frequency = cycle / cps; diff --git a/packages/superdough/worklets.mjs b/packages/superdough/worklets.mjs index 25dae03c..c9948916 100644 --- a/packages/superdough/worklets.mjs +++ b/packages/superdough/worklets.mjs @@ -144,7 +144,7 @@ function getParamValue(block, param) { // } // } // registerProcessor('lfo-processor', LFOProcessor); -// const waveShapeNames = Object.keys(waveshapes); +const waveShapeNames = Object.keys(waveshapes); class LFOProcessor extends AudioWorkletProcessor { static get parameterDescriptors() { return [ From b2f90ecb3ba2fa47fba6cca63afa027df4cd7bb1 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sun, 20 Jul 2025 23:56:30 -0400 Subject: [PATCH 4/5] fix def skew --- packages/superdough/superdough.mjs | 9 ++++++--- packages/superdough/synth.mjs | 2 +- packages/superdough/worklets.mjs | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index 96cf3f67..f9e8a1b8 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -346,10 +346,10 @@ function getDelay(orbit, delaytime, delayfeedback, t, channels) { export function getLfo(audioContext, begin, end, properties = {}) { const { shape = 0, ...props } = properties; const { dcoffset = -0.5, depth = 1 } = properties; - return getWorklet(audioContext, 'lfo-processor', { + const lfoprops = { frequency: 1, depth, - skew: 0, + skew: .5, phaseoffset: 0, time: begin, begin, @@ -360,7 +360,10 @@ export function getLfo(audioContext, begin, end, properties = {}) { max: dcoffset + depth * 0.5, curve: 1, ...props, - }); + } + + console.info(lfoprops) + return getWorklet(audioContext, 'lfo-processor', lfoprops); } // export function getLfo(audioContext, time, end, properties = {}) { diff --git a/packages/superdough/synth.mjs b/packages/superdough/synth.mjs index 88e14e5a..a95ba9df 100644 --- a/packages/superdough/synth.mjs +++ b/packages/superdough/synth.mjs @@ -279,7 +279,7 @@ export function registerSynthSounds() { getParamADSR(envGain.gain, attack, decay, sustain, release, 0, 1, begin, holdend, 'linear'); let lfo; if (pwsweep != 0) { - lfo = getLfo(ac, begin, end, { frequency: pwrate, depth: pwsweep }); + lfo = getLfo(ac, begin, end, { frequency: pwrate, depth: pwsweep, skew: .5, dcoffset: 0 }); lfo.connect(o.parameters.get('pulsewidth')); } let timeoutNode = webAudioTimeout( diff --git a/packages/superdough/worklets.mjs b/packages/superdough/worklets.mjs index c9948916..df3c445a 100644 --- a/packages/superdough/worklets.mjs +++ b/packages/superdough/worklets.mjs @@ -185,6 +185,8 @@ class LFOProcessor extends AudioWorkletProcessor { return true; } + + const output = outputs[0]; const frequency = parameters['frequency'][0]; From 66828e17d30946b217942e7a89af7a1fe6903642 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Mon, 21 Jul 2025 01:11:04 -0400 Subject: [PATCH 5/5] working --- packages/core/cyclist.mjs | 4 +- packages/core/logger.mjs | 6 +++ packages/core/repl.mjs | 4 +- packages/superdough/superdough.mjs | 25 ++-------- packages/superdough/synth.mjs | 2 +- packages/superdough/worklets.mjs | 74 +++--------------------------- 6 files changed, 21 insertions(+), 94 deletions(-) diff --git a/packages/core/cyclist.mjs b/packages/core/cyclist.mjs index fec81954..ad096103 100644 --- a/packages/core/cyclist.mjs +++ b/packages/core/cyclist.mjs @@ -5,7 +5,7 @@ This program is free software: you can redistribute it and/or modify it under th */ import createClock from './zyklus.mjs'; -import { logger } from './logger.mjs'; +import { errorLogger, logger } from './logger.mjs'; export class Cyclist { constructor({ @@ -76,7 +76,7 @@ export class Cyclist { } }); } catch (e) { - logger(`[cyclist] error: ${e.message}`); + errorLogger(e); onError?.(e); } }, diff --git a/packages/core/logger.mjs b/packages/core/logger.mjs index e13bf86c..635505c5 100644 --- a/packages/core/logger.mjs +++ b/packages/core/logger.mjs @@ -4,6 +4,12 @@ let debounce = 1000, lastMessage, lastTime; +export function errorLogger(e, origin = 'cyclist') { + //TODO: add some kind of debug flag that enables this while in dev mode + // console.error(e) + logger(`[${origin}] error: ${e.message}`); +} + export function logger(message, type, data = {}) { let t = performance.now(); if (lastMessage === message && t - lastTime < debounce) { diff --git a/packages/core/repl.mjs b/packages/core/repl.mjs index aeaa6418..47231af4 100644 --- a/packages/core/repl.mjs +++ b/packages/core/repl.mjs @@ -1,7 +1,7 @@ import { NeoCyclist } from './neocyclist.mjs'; import { Cyclist } from './cyclist.mjs'; import { evaluate as _evaluate } from './evaluate.mjs'; -import { logger } from './logger.mjs'; +import { errorLogger, logger } from './logger.mjs'; import { setTime } from './time.mjs'; import { evalScope } from './evaluate.mjs'; import { register, Pattern, isPattern, silence, stack } from './pattern.mjs'; @@ -256,6 +256,6 @@ export const getTrigger = await hap.context.onTrigger(hap, getTime(), cps, t); } } catch (err) { - logger(`[cyclist] error: ${err.message}`, 'error'); + errorLogger(err, 'getTrigger'); } }; diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index f9e8a1b8..7d90eb15 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -349,39 +349,22 @@ export function getLfo(audioContext, begin, end, properties = {}) { const lfoprops = { frequency: 1, depth, - skew: .5, + skew: 0.5, phaseoffset: 0, time: begin, begin, end, shape: getModulationShapeInput(shape), dcoffset, - min: dcoffset - depth * 0.5, - max: dcoffset + depth * 0.5, + min: dcoffset * depth, + max: dcoffset * depth + depth, curve: 1, ...props, - } + }; - console.info(lfoprops) return getWorklet(audioContext, 'lfo-processor', lfoprops); } -// export function getLfo(audioContext, time, end, properties = {}) { -// return getWorklet(audioContext, 'lfo-processor', { -// frequency: 1, -// depth: 1, -// skew: 0, -// phaseoffset: 0, -// time, -// begin: time, -// end, -// shape: 1, -// dcoffset: -0.5, -// ...properties, -// }); -// } - - export function getSyncedLfo(audioContext, time, end, cps, cycle, properties = {}) { const frequency = cycle / cps; diff --git a/packages/superdough/synth.mjs b/packages/superdough/synth.mjs index a95ba9df..88e14e5a 100644 --- a/packages/superdough/synth.mjs +++ b/packages/superdough/synth.mjs @@ -279,7 +279,7 @@ export function registerSynthSounds() { getParamADSR(envGain.gain, attack, decay, sustain, release, 0, 1, begin, holdend, 'linear'); let lfo; if (pwsweep != 0) { - lfo = getLfo(ac, begin, end, { frequency: pwrate, depth: pwsweep, skew: .5, dcoffset: 0 }); + lfo = getLfo(ac, begin, end, { frequency: pwrate, depth: pwsweep }); lfo.connect(o.parameters.get('pulsewidth')); } let timeoutNode = webAudioTimeout( diff --git a/packages/superdough/worklets.mjs b/packages/superdough/worklets.mjs index df3c445a..e7928a48 100644 --- a/packages/superdough/worklets.mjs +++ b/packages/superdough/worklets.mjs @@ -81,69 +81,7 @@ function getParamValue(block, param) { } return param[0]; } -// const waveShapeNames = Object.keys(waveshapes); -// class LFOProcessor extends AudioWorkletProcessor { -// static get parameterDescriptors() { -// return [ -// { name: 'time', defaultValue: 0 }, -// { name: 'end', defaultValue: 0 }, -// { name: 'frequency', defaultValue: 0.5 }, -// { name: 'skew', defaultValue: 0.5 }, -// { name: 'depth', defaultValue: 1 }, -// { name: 'phaseoffset', defaultValue: 0 }, -// { name: 'shape', defaultValue: 0 }, -// { name: 'dcoffset', defaultValue: 0 }, -// ]; -// } -// constructor() { -// super(); -// this.phase; -// } - -// incrementPhase(dt) { -// this.phase += dt; -// if (this.phase > 1.0) { -// this.phase = this.phase - 1; -// } -// } - -// process(inputs, outputs, parameters) { -// // eslint-disable-next-line no-undef -// if (currentTime >= parameters.end[0]) { -// return false; -// } - -// const output = outputs[0]; -// const frequency = parameters['frequency'][0]; - -// const time = parameters['time'][0]; -// const depth = parameters['depth'][0]; -// const skew = parameters['skew'][0]; -// const phaseoffset = parameters['phaseoffset'][0]; - -// const dcoffset = parameters['dcoffset'][0]; -// const shape = waveShapeNames[parameters['shape'][0]]; - -// const blockSize = output[0].length ?? 0; - -// if (this.phase == null) { -// this.phase = _mod(time * frequency + phaseoffset, 1); -// } -// // eslint-disable-next-line no-undef -// const dt = frequency / sampleRate; -// for (let n = 0; n < blockSize; n++) { -// for (let i = 0; i < output.length; i++) { -// const modval = (waveshapes[shape](this.phase, skew) + dcoffset) * depth; -// output[i][n] = modval; -// } -// this.incrementPhase(dt); -// } - -// return true; -// } -// } -// registerProcessor('lfo-processor', LFOProcessor); const waveShapeNames = Object.keys(waveshapes); class LFOProcessor extends AudioWorkletProcessor { static get parameterDescriptors() { @@ -185,8 +123,6 @@ class LFOProcessor extends AudioWorkletProcessor { return true; } - - const output = outputs[0]; const frequency = parameters['frequency'][0]; @@ -194,11 +130,12 @@ class LFOProcessor extends AudioWorkletProcessor { const depth = parameters['depth'][0]; const skew = parameters['skew'][0]; const phaseoffset = parameters['phaseoffset'][0]; - const min = parameters['min'][0]; - const max = parameters['max'][0]; + const curve = parameters['curve'][0]; const dcoffset = parameters['dcoffset'][0]; + const min = parameters['min'][0]; + const max = parameters['max'][0]; const shape = waveShapeNames[parameters['shape'][0]]; const blockSize = output[0].length ?? 0; @@ -210,8 +147,9 @@ class LFOProcessor extends AudioWorkletProcessor { const dt = frequency / sampleRate; for (let n = 0; n < blockSize; n++) { for (let i = 0; i < output.length; i++) { - const modval = (waveshapes[shape](this.phase, skew) + dcoffset) * depth; - output[i][n] = clamp(Math.pow(modval, curve), min, max); + let modval = (waveshapes[shape](this.phase, skew) + dcoffset) * depth; + modval = Math.pow(modval, curve); + output[i][n] = clamp(modval, min, max); } this.incrementPhase(dt); }