diff --git a/max-package/jsui/fluid.waveform~.js b/max-package/jsui/fluid.waveform~.js index 67b441a..1bfc19c 100644 --- a/max-package/jsui/fluid.waveform~.js +++ b/max-package/jsui/fluid.waveform~.js @@ -269,7 +269,7 @@ function getBuffer(name) function bufexists(name) { var b = getBuffer(name) - if (b.framecount() === -1 || b === null) return false + if (b === null || b.framecount() === -1) return false return true } @@ -296,6 +296,16 @@ function err(msg) error('fluid.waveform~: ' + msg + '\n') } +function checkalllayers() { + alllayers.forEach(function (source) + { + if (!bufexists(source)) { + err('buffer' + ' "' + source + '" ' + 'no longer exists'); + clear(); //calling clear does fix the buffer renaming bug but it's hacky + } + }) +} + function addlayer(type, source, r, g, b, a) { if (!type || !source) err('layer must have a type (symbol) and a source (buffer name)'); @@ -329,6 +339,7 @@ function addlayer(type, source, r, g, b, a) // discern if a new or existing layer if (index < 0) { // new + checkalllayers(); var l = new LayerSpec(); l.type = translatedType; l.source = source; @@ -453,6 +464,7 @@ function addmarkers(source, reference) const index = find(source); if (index < 0) { + checkalllayers(); var l = new MarkersSpec(source, reference) //markerdata,fs,referenceLength) l.type = 'markers'; markerlayers.push(l);