Skip to content

Commit

Permalink
move initStrudel onto the source prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
TodePond committed Feb 1, 2025
1 parent e69e012 commit b8e893b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/hydra.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b8e893b

Please sign in to comment.