Page 1 of 1

Menu programming for dummies

Posted: 21 Nov 2012 21:08
by base9
Hi,

I'm new in the big lemur world.
I've a problem with a menu item and asking for some help.
Maybe the solution is easy but I don't understand it with my newbee skills.

Problem:
I've a template with knobs, button, sliders and one menu. All is fine but the menu item
doesn't work.

I've mapped the menu in lemur to the ableton vstplugin menu. In this synth plugin I have a menu with
6 entries to choose the different engines of the synth.

When I check the ableton midi info statusline then this midi mapping
for the synth engine is waiting for:

Engine 1 = 0.166
Engine 2 = 0.333
Engine 3 = 0.5
Engine 4 = 0.666
Engine 5 = 0.833
Engine 6 = 1.0

My question is how can I use the menu item with 6 entries and send for every choosen entry the different parameter, see list above?
Or is the menu item not the right way to solve the problem?

Best regards,
Werner

Re: Menu programming for dummies

Posted: 22 Nov 2012 09:34
by electrofux
Create a script that creates midi out messages for every value of the "selection" variable.

If (selection==0)

{
ctlout(0,23,10,1);
}
else if ....

I am no pro on this but it worked for me. You lose bidirectional functions though which you have to porgram back in via an additional Midi Script.

Re: Menu programming for dummies

Posted: 22 Nov 2012 21:35
by base9
Thanks for the hint.

my script for the menu has "execution: on expression X"

if(x==0) {
ctlout (0,7,10,1);
}
if(x==1) {
ctlout (0,7,20,1);
}


Then I tried it on my ipad. I monitored the recieved messages on the mac.
time source message ch data
22:20:19.146 From Alesis iO Dock Control 1 $07 $01
22:20:20.656 From Alesis iO Dock Control 1 $07 $02
22:20:22.119 From Alesis iO Dock Control 1 $07 $03
22:20:23.593 From Alesis iO Dock Control 1 $07 $04
22:20:28.774 From Alesis iO Dock Control 1 $07 $00

I don't understand the midi messages.
my script should only test the selection for x=0 and x=1 but why is the menu item sending midi messages for selection 2-4 of my menuitem?
I thought that the script should send midi message for menu item 0 und 1 but not for 2,3 and 4.

Any help is much appreciated.

Thanks,
Werner

Re: Menu programming for dummies

Posted: 23 Nov 2012 07:43
by Softcore
Make sure "selection" midi out is not enabled in the midi mapping settings of the menu object - do not assign any midi target to it! ;)

Also, your script should be expression on "selection" not "x" - there is no "x" defined in the menu object (as described in the post above by Electroflux) - if you look carefully, the "x" after the "on Expression" setting MUST be red in your script - i.e. its not accepted - type "selection" (no "s) and you 'll see it turn to black, i.e. its accepted.


Although, for some reason I suspect that still it wont work as intended. Usually synths expect values ranging from 0 to 127 - and not from 0 to 1 as you mentioned. In the case of values which have a different range, again usually, the host or the plug in itself "maps" the 0 to 127 range to the range needed by the parameter (think for example midi messages for volume faders, you still need a range from 0 to 127 to control them, although this range is irrelevant to the actual values of the volume fader).

So, long story short, if again it doesnt work, I suspect you will have to change your scripts so that:

(the logic:
count of posible selections = 6
128/6 = 21,333)

So you will be needing for selection "Engine 1" (menu item index 0) an output of a value anything between 0 - 21,333, for selection "Engine 2" (menu item index 1) an out of anything between 21,4 - 42,666, selection "Engine 3" (menu item index 2) between 42,7 - 63,999 and so on!

To give an example, assuming midi target 0, CC number 10 and midi channel 1

if (selection==0) ctlout(0, 10, 15, 0);
else if (selection==1) ctlout(0, 10, 25, 0);
else if (selection==2) ctlout(0, 10, 50, 0);
.....and so on!

P.S. On second thought, the above might also not work!

By reading what you wrote here:
Engine 1 = 0.166
Engine 2 = 0.333
Engine 3 = 0.5
Engine 4 = 0.666
Engine 5 = 0.833
Engine 6 = 1.0
It might be needed to multiply each of these values expected with 127 to get the actual values needed to be sent! Agian, all this is assuming the plug in expects plain 'ol 0 - 127 ranged midi messages to "map" to the selections - if Im mistaking then you stick to the quoted actual values.

P.S. 2 - another, easiest approach would be to write no scripts at all and "tinker" with the range of sent messages natively in Ableton Live - open the midi mappings window, click on the mapped menu and you will see the range Ableton expects to receive by default - perhaps by reducing that range from 0 to 5, everything will work as expected without any need for additional scripting.

;)

Re: Menu programming for dummies

Posted: 23 Nov 2012 14:37
by Macciza
Hi
Try a Custom MIDI in your Menu with a value of (127/6)*selection
or even just selection and choos scale 0 to 127
Should work . . . I think . . .
The numbers look right
Cheers
MM

Re: Menu programming for dummies

Posted: 26 Nov 2012 21:05
by base9
@Softcore
@Macciza

Thank you very much for the detailed tipps. :mrgreen:
Now my template is running. I had several bugs in template and script.

1. problem: selection was mapped to midi target not to "none".
2. problem: script has expression on "x" not on "selection".
3. problem: ctlout has not the correct values.

the script:
if (selection==0) ctlout(0, 7, 15, 1);
else if (selection==1) ctlout(0, 7, 25, 1);
else if (selection==2) ctlout(0, 7, 50, 1);
else if (selection==3) ctlout(0, 7, 75, 1);
else if (selection==4) ctlout(0, 7, 100 , 1);
else if (selection==5) ctlout(0, 7, 125 , 1);

Now I can finish my Cyclop template :)

Thanks,
Werner

Re: Menu programming for dummies

Posted: 26 Nov 2012 21:27
by Softcore
Great news and Im glad you came back to post feedback!