OSC messages are sent twice

Discuss problems and solutions.
Post Reply
shr3d
Newbie
Posts: 10
Joined: 30 Jun 2015 12:31

OSC messages are sent twice

Post by shr3d »

Dear Liine Forum,

I have a short, and hopefully easy question. I'm not that familiar with Lemur and I'm looking into this for quite some time now, so I hope one of you can give me a solution.

It's actually very simple.

I'd like to have an array of buttons, radio-style meaning when I tap on one of the buttons, it will get highlighted, the previously highlighted button is set back. I also want to send different OSC messages for each button, that is because the Lemur surface will be used to controll Reaper, and as far as I know, Reaper cannot handle incoming float arrays that come with an OSC message (since this is what Lemur sends, e.g., we have 5 buttons, I tap on button 1, then it sends something like /myOSCmessage f[1.0 0.0 0.0 0.0 0.0]).

So, I came up with a litte workaround. I'm using the switch widget with 5 elements, behaviour is set to "radio". I have written a short script that takes care of the OSC message handling (and therefore I set the global OSC target for this widget to "None"). The script is added to the Switch widget.
Executed "on Expression x"

If I'm not wrong, x is an array of size(numberOfButtons). Similar to the example above, let's assume 2 buttons, i.e. x=[1.0, 0.0] for button 1, and x=[0.0, 1.0] for button 2

Then the script looks like this:

if(Switches.x[0] == 1.0){
oscout(0,'/selectSong01',1.0);
return;}

if(Switches.x[1] == 1.0){
oscout(0,'/selectSong02',1.0);
return;}

That works fine, it triggers the correct messages, but the OSC messages are sent twice, which I'd like to avoid (and which I actually don't understand why that happens). I tried the different trigger options for the OSC message (send if value changes from 0 to 1, from 1 to 0, etc.) but it seems that has no impact. It is always sent twice (like with press/release button). Then again, if I add e.g. "SelectSong.x[1] = 0.0;" in the if clause after the oscout, then I have in fact a pad function, and the message is sent only once.

Any ideas/insights/articles? Find the project file below.

Thanks a lot!
Dirk

PS: I hope this is not a duplicate thread, for some reason, the forum search does not work, when I type in "OSC" for example, it returns zero results ...
Attachments
test.jzml
Project file
(1.8 KiB) Downloaded 165 times
shr3d
Newbie
Posts: 10
Joined: 30 Jun 2015 12:31

Re: OSC messages are sent twice

Post by shr3d »

Solved, but with a different approach. Now directly grabbing the single values of the button state array and triggering dedicated OSC messages (so in fact, the same as with the "if else" script from the inital post, at least logically). Still would like to understand why the first approach does not work.

Find the solution below.

Cheers
Dirk
Attachments
test2.jzml
Solution
(2.54 KiB) Downloaded 167 times
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: OSC messages are sent twice

Post by Macciza »

heres another option assuming you are only ever sending value of 1
A script in the Switch ( on x)
decl sel=firstof(x)+1;
decl msg='/selectSong_0'+sel;
oscout(0,msg,1);

How did you work out first version to be sending twice? does not appear to do so looking at it in Max
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Post Reply