draw straight line when no analyser is defined yet

+ add todo for memory leak
This commit is contained in:
Felix Roos 2024-03-16 03:12:00 +01:00
parent dd78dc9606
commit cdc200e1da
2 changed files with 28 additions and 4 deletions

View file

@ -25,5 +25,11 @@ registerWidget('twist', (id, options = {}, pat) => {
registerWidget('osci', (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 });
});