Forums > Javascript

Access #0 in JavaScript

March 30, 2013 | 7:28 am

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?


March 30, 2013 | 7:39 am

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.


March 30, 2013 | 8:33 pm

Is it not possible to access #0 from JavaScript?


March 30, 2013 | 10:19 pm

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.

Mixer.maxpat would look like that:

– Pasted Max Patch, click to expand. –

March 31, 2013 | 1:10 am

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)


Viewing 5 posts - 1 through 5 (of 5 total)