diff --git a/packages/codemirror/widget.mjs b/packages/codemirror/widget.mjs index c2c1653b..f98dcf89 100644 --- a/packages/codemirror/widget.mjs +++ b/packages/codemirror/widget.mjs @@ -96,7 +96,6 @@ export function registerWidget(type, fn) { function getCanvasWidget(id, options = {}) { const { width = 500, height = 60, pixelRatio = window.devicePixelRatio } = options; let canvas = document.getElementById(id) || document.createElement('canvas'); - console.log('canvas', canvas); canvas.width = width * pixelRatio; canvas.height = height * pixelRatio; canvas.style.width = width + 'px'; @@ -105,25 +104,19 @@ function getCanvasWidget(id, options = {}) { return canvas; } -registerWidget('roll', (id, options = {}, pat) => { +registerWidget('_pianoroll', (id, options = {}, pat) => { const ctx = getCanvasWidget(id, options).getContext('2d'); return pat.pianoroll({ fold: 1, ...options, ctx, id }); }); -registerWidget('twist', (id, options = {}, pat) => { +registerWidget('_spiral', (id, options = {}, pat) => { options = { width: 200, height: 200, size: 36, ...options }; const ctx = getCanvasWidget(id, options).getContext('2d'); return pat.spiral({ ...options, ctx, id }); }); -registerWidget('osci', (id, options = {}, pat) => { +registerWidget('_scope', (id, options = {}, pat) => { options = { width: 500, height: 60, pos: 0.5, scale: 1, ...options }; const ctx = getCanvasWidget(id, options).getContext('2d'); - // TODO: find way to clear previous analysers to avoid memory leak - // .scope passes id to Pattern.analyze, which is picked up by superdough - // .. which calls getAnalyserById(analyze), creating a new analyzer (+buffer) for that key - // the id here is the col number where the osci function ends (as passed by the transpiler) - // effectively, this means for each evaluation of .osci on a unique col, a new analyser will be created - // the problem is that the old ones will never get deleted.. this might pile up some memory return pat.scope({ ...options, ctx, id }); }); diff --git a/packages/widgets/Claviature.jsx b/packages/widgets/Claviature.jsx index dc216d56..584dd09d 100644 --- a/packages/widgets/Claviature.jsx +++ b/packages/widgets/Claviature.jsx @@ -27,7 +27,7 @@ customElement('strudel-claviature', { options: '{}' }, (props, { element }) => { ); }); -registerWidget('claviature', (id, options = {}, pat) => { +registerWidget('_claviature', (id, options = {}, pat) => { options = { range: ['A0', 'C8'], scaleY: 1, scaleY: 0.5, scaleX: 0.5, ...options }; const height = (options.upperHeight + options.lowerHeight) * options.scaleY; const el = getSolidWidget('strudel-claviature', id, { ...options, height });