FantomXR Posted February 8, 2015 Report Posted February 8, 2015 (edited) Hey people, with the help of TK a while ago and a few modifications this code allows you to send program changes in conjunction with buttons... in my case I used buttons from Marquardt type 6425 with numeric keycaps (you can get them at conrad). When TK wrote this code it had the limitation that I was just able to send prg.chg. to a maximum of 127 which is the midi standard. In my case I needed more! My software listens on all channels for prg.chg. So I added a little math to it and now it sends automatically 0-127 prg.chg. on chn.1, 0-127 on chn. 2 and 0-127 on chn.3 depending on the value you type in. If you give him f.e. 128, it sends prg.chg. 0 on chn. 2. If you enter 383, it sends prg.chg. 127 on chn.3 and so on. So, here we go. This could you want to paste into an NGR.-file: if ^section == 0 exit endif # should the PC value be cleared? if LED:2001 == 2 set LED:2000 0 set LED:2001 0 LCD "@(1:1:5)&b " endif # keypad buttons # '1' button if ^section == 1 if LED:2000 <= 38 set LED:2000 [LED:2000 * 10] set LED:2000 [LED:2000 + 1] # indicate a valid number set LED:2001 1 endif exit endif # '2' button if ^section == 2 if LED:2000 <= 38 set LED:2000 [LED:2000 * 10] set LED:2000 [LED:2000 + 2] # indicate a valid number set LED:2001 1 endif exit endif # '3' button if ^section == 3 if LED:2000 <= 38 set LED:2000 [LED:2000 * 10] set LED:2000 [LED:2000 + 3] # indicate a valid number set LED:2001 1 endif exit endif # '4' button if ^section == 4 if LED:2000 <= 37 set LED:2000 [LED:2000 * 10] set LED:2000 [LED:2000 + 4] # indicate a valid number set LED:2001 1 endif exit endif # '5' button if ^section == 5 if LED:2000 <= 37 set LED:2000 [LED:2000 * 10] set LED:2000 [LED:2000 + 5] # indicate a valid number set LED:2001 1 endif exit endif # '6' button if ^section == 6 if LED:2000 <= 37 set LED:2000 [LED:2000 * 10] set LED:2000 [LED:2000 + 6] # indicate a valid number set LED:2001 1 endif exit endif # '7' button if ^section == 7 if LED:2000 <= 37 set LED:2000 [LED:2000 * 10] set LED:2000 [LED:2000 + 7] # indicate a valid number set LED:2001 1 endif exit endif # '8' button if ^section == 8 if LED:2000 <= 37 set LED:2000 [LED:2000 * 10] set LED:2000 [LED:2000 + 8] # indicate a valid number set LED:2001 1 endif exit endif # '9' button if ^section == 9 if LED:2000 <= 37 set LED:2000 [LED:2000 * 10] set LED:2000 [LED:2000 + 9] # indicate a valid number set LED:2001 1 endif exit endif # '0' button if ^section == 10 if LED:2000 <= 38 set LED:2000 [LED:2000 * 10] # indicate a valid number set LED:2001 1 endif exit endif # EXEC button if ^section == 11 # valid number? if LED:2001 == 1 if LED:2000 <= 127 send ProgramChange OUT1 1 LED:2000 # next entry will reset the number set LED:2001 2 endif if LED:2000 > 127 if LED:2000 <= 255 send ProgramChange OUT1 2 LED:2000 # next entry will reset the number set LED:2001 2 endif endif if LED:2000 > 255 if LED:2000 <= 383 send ProgramChange OUT1 3 LED:2000 # next entry will reset the number set LED:2001 2 endif endif endif exit endif # CLEAR button if ^section == 12 set LED:2000 0 set LED:2001 0 exit endif Of course you need to add also a little code into a NGC.-File: # start script with ^section == 1..10 for digit button 1, 2, 3, 4, ..., 9, 0 EVENT_BUTTON id=50 type=Meta meta=RunSection:1 button_mode=OnOnly EVENT_BUTTON id=62 type=Meta meta=RunSection:2 button_mode=OnOnly EVENT_BUTTON id=58 type=Meta meta=RunSection:3 button_mode=OnOnly EVENT_BUTTON id=49 type=Meta meta=RunSection:4 button_mode=OnOnly EVENT_BUTTON id=61 type=Meta meta=RunSection:5 button_mode=OnOnly EVENT_BUTTON id=57 type=Meta meta=RunSection:6 button_mode=OnOnly EVENT_BUTTON id=52 type=Meta meta=RunSection:7 button_mode=OnOnly EVENT_BUTTON id=64 type=Meta meta=RunSection:8 button_mode=OnOnly EVENT_BUTTON id=60 type=Meta meta=RunSection:9 button_mode=OnOnly EVENT_BUTTON id=63 type=Meta meta=RunSection:10 button_mode=OnOnly # Sende program change EVENT_BUTTON id=59 type=Meta meta=RunSection:11 button_mode=OnOff fwd_id=LED:50 # Clear EVENT_BUTTON id=51 type=Meta meta=RunSection:12 button_mode=OnOnly # this is a dummy event which stores and displays the program change value EVENT_LED id=2000 value=0 lcd_pos=1:1:1 label="&bPrgChange: @(1:5:5)%3d" # this dummy event is set when the next keypress should clear the LED:2000 value EVENT_LED id=2001 value=0 lcd_pos=1:1:2 label="^pcstate" DebounceCtr 255 Please adjust the ids to your needs. If you are working with a display, here are the correct lables: COND_LABEL pcstate COND =0 "" COND =1 "" COND =2 "@(1:1:5)&bSent" I hope you like it! :-) Thanks! Chris Edited February 8, 2015 by FantomXR
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now