Page 1 of 1

Using radio buttons...

Posted: 03 Aug 2012 12:33
by wimek
I'm new to Lemur and struggling a bit with radio buttons. I'm trying to control my DSI Mopho with Lemur. Controls like oscillator frequency, glide, cut-off frequency etc. work like a charm. However, I can't get a set of radio buttons to control the wave shape of the oscillators...

To control the wave form of the Mopho it needs to receive CC 22, values 0..99. Where the wave form is defined as follows:

0 = off
1 = Saw
2 = Triangle
3 = Saw-Triangle
4..99 = pulse with different pulse width

I want to make a set of 4 radio buttons respectively sending the values 0, 1, 2 and 3 with CC 22 and a fader sending the values 4..99 with CC 22. The fader works, but when pushing the radio buttons it looks like that the radio buttons send out the values 0 and 3 in a pattern that I don't understand... I configured them using a switch the following way:

Message = B0 - Control CHange
Controller = 22 to 22
Value sets itself to: x[0..3]
change of value trigger message sending = any
scale = 0 to 3
channel = 1 to 1
columns = 1
rows = 4


Can anybody give me a hint for solving this problem?

Thanks,
Wim

Re: Using radio buttons...

Posted: 05 Aug 2012 22:44
by shimoda
It sounds as though the problem you are running into is that using x[0..3] is just giving a 0 or 1 for whatever radio button which is, in turn, being converted to either a 0 or 3 since the value returned will either be on or off. Essentially, Lemur is reporting that a 1 is returned from whichever radio button is pressed, doesn't really matter. What I would do is create a custom script, that runs On Expression. If your radio button was named Selector, and the pulse width named Fader, then my script would look something like:

if (Selector.x[0]==1) ctlout (1, 22, 0, 1);
if (Selector.x[1]==1) ctlout (1, 22, 1, 1);
if (Selector.x[2]==1) ctlout (1, 22, 2, 1);
if (Selector.x[3]==1) ctlout (1, 22, 3, 1);
if (Selector.x[4]==1) ctlout (1, 22, Fader.x*95+4, 1);

Re: Using radio buttons...

Posted: 06 Aug 2012 12:01
by axel_liine
shimoda wrote:It sounds as though the problem you are running into is that using x[0..3] is just giving a 0 or 1 for whatever radio button which is, in turn, being converted to either a 0 or 3 since the value returned will either be on or off. Essentially, Lemur is reporting that a 1 is returned from whichever radio button is pressed, doesn't really matter. What I would do is create a custom script, that runs On Expression. If your radio button was named Selector, and the pulse width named Fader, then my script would look something like:

if (Selector.x[0]==1) ctlout (1, 22, 0, 1);
if (Selector.x[1]==1) ctlout (1, 22, 1, 1);
if (Selector.x[2]==1) ctlout (1, 22, 2, 1);
if (Selector.x[3]==1) ctlout (1, 22, 3, 1);
if (Selector.x[4]==1) ctlout (1, 22, Fader.x*95+4, 1);
Note you can also use the 'firstof()' function which returns the index of the first enabled button in the Switches : 0 for the first, 1, for the second, etc.

Code: Select all

ctlout(1, 22, firstof(Selector.x), 1);

Re: Using radio buttons...

Posted: 06 Aug 2012 19:41
by shimoda
@axel: why didn't I think of that?!? I knew there was a simpler way...

Re: Using radio buttons...

Posted: 06 Aug 2012 20:17
by wimek
Thanks a lot guys!

I do understand your posts, but I'm still fighting a bit with the Lemor editor ... I do have a solid background in programming and software development but this environment is new for me. The editor says my syntax is OK, but at this moment my iPad is not sending any midi message when touching this radio button (the others work fine). I just need a bit of time to figure this out :-)

@axel: your statement seams to do exactly what I asked for. However, I think I can incorporate the fader with something like this:

Code: Select all

decl RadioVal;
RadioVal = firstof(OSC1wave.x);
if (RadioVal==4) ctlout(1, 22, OSC1pulse.x, 1);
else ctlout(1, 22, RadioVal, 1);

Re: Using radio buttons...

Posted: 06 Aug 2012 20:40
by axel_liine
The first argument to ctlout is the MIDI target to send the message. Usually that would be target zero, so :

Code: Select all

decl RadioVal;
RadioVal = firstof(OSC1wave.x);
if (RadioVal==4) ctlout(0, 22, OSC1pulse.x, 1);
else ctlout(0, 22, RadioVal, 1);

Re: Using radio buttons...

Posted: 06 Aug 2012 20:44
by wimek
wow, it works like a charm!

I had to set the target of the radio button switch to "none" and multiply the fader value by 95+4 as shimoda indicated. The script is now:

Code: Select all

decl RadioVal;
RadioVal = firstof(OSC1wave.x);
if (RadioVal==4) ctlout(0, 22, OSC1pulse.x*95+4, 1);
else ctlout(0, 22, RadioVal, 1);
The only thing I don't understand is why I have to multiply by 95+4 because I set the scale of the fader 4 to 99 ... I just expected that x would get a value in the range 4..99 :?:

B.t.w. is there a way to debug variables?

Thanks,
Wim

Re: Using radio buttons...

Posted: 06 Aug 2012 21:48
by shimoda
I think the reason is because the scale is for output directly out of the fader. You aren't sending directly from the fader using its own midi out. Instead, you are using the script to send CC messages with the fader.x as the value, that is why I scaled it that way in the script I posted.

Use monitors to help debug.

Re: Using radio buttons...

Posted: 06 Aug 2012 21:52
by wimek
@shimoda: I'll look into the monitors and thanks again!

:P