Skip to content

flucoma/flucoma-max#368 hacky fix #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion max-package/jsui/fluid.waveform~.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)');
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down