From b8e893b6ce395b8599010a8d29ec165f3f71b7fa Mon Sep 17 00:00:00 2001 From: "Lu[ke] Wilson" Date: Sat, 1 Feb 2025 17:28:21 +0000 Subject: [PATCH] move initStrudel onto the source prototype --- src/hydra.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/hydra.js b/src/hydra.js index db59dc4..a74e283 100644 --- a/src/hydra.js +++ b/src/hydra.js @@ -34,6 +34,7 @@ export class HydraSession { } window.H = this._hydra; + const HydraSource = this._hydra.s[0].constructor; // Enable using strudel style mini-patterns for argument control on Hydra. // strudel needs to be loaded first, otherwise this will cause warnings, and rendering will not @@ -57,19 +58,17 @@ export class HydraSession { // initialized a streaming canvas with the strudel draw context canvas // this allows us to use the strudel output - window.initStrudel = (s) => { + HydraSource.prototype.initStrudel = function () { if (window.parent.strudel == undefined) return; const canvas = window.parent.strudel.draw.getDrawContext().canvas; canvas.style.display = 'none'; - s.init({ src: canvas }); + this.init({ src: canvas }); }; window.useStrudelCanvas = () => { - throw Error("'useStrudelCanvas' has been renamed to 'initStrudel'"); + throw Error("'useStrudelCanvas(s0)' has been renamed to 's0.initStrudel'"); }; - // console.log(hydra); - const clamp = (num, min, max) => Math.min(Math.max(num, min), max); // Enables Hydra to use Strudel frequency data