Page 1 of 1

Switches, OSC, and bidirectionality--solutions and oddities!

Posted: 02 Mar 2013 02:41
by Hoopsville
Greetings all!

I am working on my first Project, a GUI to control my Plogue Bidule layout, which I'm using to host softsynths for live performance. I am working exclusively with OSC, which I am still getting used to.

I have been working on creating a patch change object, basically Switches with 8 rows, 16 columns, thus 128 buttons, one for each program change. Touching each one should select the corresponding Preset Number (of which there are 128) in an Int_Variable I have in Bidule.

So: in my Switches, I enable Radio Buttons, disable x, create an expression called num with a script firstof(x), and give num a custom OSC address of /Int_Variable_0/Preset_Number. This works just fine, and seems to be a standard basic way to do this sort of thing in Lemur.

But there's a wrinkle: I'd like to have bidirectionality, so that selecting a Preset in my Int_Variable also selects the appropriate Switch in Lemur, and this didn't seem to work out of the box. I can't articulate exactly why, but I guess it has something to do with the way firstof(x) works and the way in which Lemur handles Switches' on/off states internally.

Based on these vague suppositions, I figured I needed a script that would get the incoming OSC message and turn on the corresponding Switch, while turning off any other Switch that might be on. And after much trial and error, with much combing of these forums and more luck than understanding, I came up with something that seems to work. Here it is (don't laugh):

In Switches, create a script called pc, execution On OSC, with a custom address of /Int_Variable_0/Preset_Number and then:

Code: Select all

decl a=OSC_ARGS*127; 
Switches.x=0; 
Switches.x[a]=1;
Now, I strongly suspect that this is grievously inelegant, but it does seem to work; now when I sent a Preset change from my Int_Variable in Plogue, the corresponding Switch in Lemur goes on and the previously lit one goes off.

Here's how I see it: OSC_ARGS remains mysterious to me, but I eventually figured that I could set it equal to a to give me a variable representing the OSC message I wanted to lay hands on. The *127 turns it from a floating point to an integer (hope I'm using those terms correctly). So that's the decl a= part.

Then Switches.x=0 was the way I thought I would turn off the previously on Switch. I would imagine there is a much more elegant way to do it, though.

Finally, I used the declared variable a to set the correct Switch active.

Now there is another chapter to come, in which the whole house of cards collapses when I try to add some seemingly unrelated functionality. But I wanted to stop here for now, and ask for comments. What could I do to improve what I have so far? What am I overlooking? What mistaken assumptions have I made? Any comments, corrections, clarifications, etc would be greatly appreciated!

best regards,

H