Access #0 in JavaScript

rjungemann's icon

Alright, so I have a buffer, "#0-mixer-1" which is inside a subpatcher. I want to populate the contents of buffer into waveform~. To do so, I would normally send a message like "set #0-mixer-1 1" to the first inlet of waveform~, BUT you can't put #0 inside of a message box.

So If I could figure out how to do that my problem would be solved. sprintf doesn't work, a bunch of other things I've tried don't work, so I thought I'd try JavaScript.

So I'm wondering, how can I access a patcher's #0 variable within JavaScript?

rjungemann's icon

Attached are the pertinent files. If you open up either MixerChannel or MixerChannel2 you will see that everything is prefixed with #0 except for everything referencing the buffers, because of the aforementioned waveform~ "set" problem.

5335.MixerChannel2.maxpat
Max Patch
rjungemann's icon

Is it not possible to access #0 from JavaScript?

Emmanuel Jourdan's icon

You can only get the #0 from a js object argument, but in your case you don't even need to. If you just prepend the #0, as you did for the send and receive, to the buffer related objects, it works fine.

Max Patch
Copy patch and select New From Clipboard in Max.

Mixer.maxpat would look like that:

rjungemann's icon

Oh yikes it works. Thanks for taking a look! I honestly tried to do something similar to what you did but I must have done something wrong. But when I embed your version of MixerChannel twice into my Mixer patch they are indeed completely independent which is what I wanted. Thanks!

And thanks for the tip about passing #0 to JS using an argument. I didn't think of that.

(If anyone is curious what I'm trying to do with this.... https://github.com/OpenEmu/OpenEmu/issues/546)