Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* DUY Code: note remapper */
- /*
- * Parameters:
- * CHANNEL = channel to listen to 1-16 (1, default, 0 = on all channels (=omni))
- */
- RK002_DECLARE_PARAM(CHANNEL,1,0,16,1)
- RK002_DECLARE_PARAM(REMAPNOTE,1,0,127,65)
- // DECLARE_PARAM parameters can be stored in the cable and are accessible from the portal without the need to recompile
- // you can adjust them via the DUY 'details' button and a MIDI SysEx code can be used to set it as well:
- // parameter 0 = F0 00 21 23 00 02 48 00 [paramnr] 00 [val] 00 F7
- byte dChannel=0; // holds internal midi channel = 0-15
- // declare a list of notes to check:
- byte noteList[6]={65,67,69,71,72,74};
- bool RK002_onNoteOn(byte ch,byte key,byte velo){
- bool retval=true; // default = thru notes
- if((ch==16) || (ch==dChannel)){
- for(byte i=0;i<sizeof(noteList);i++){
- if(noteList[i]==key){
- retval=false; // don't send original note
- RK002_sendNoteOn(((8+i) % 15),RK002_paramGet(REMAPNOTE),velo); // send note to ch 9+foundnote in list
- // I added the % 15 in case you make a too-long notelist, this will wrap the midi channel to 0-15 range
- break; // exit loop key search
- }
- }
- }
- return retval;
- }
- // as in note on, but now for note off
- bool RK002_onNoteOff(byte ch,byte key,byte velo){
- bool retval=true; // default = thru notes
- if((ch==16) || (ch==dChannel)){
- for(byte i=0;i<sizeof(noteList);i++){
- if(noteList[i]==key){
- retval=false;
- RK002_sendNoteOff(((8+i) % 15),RK002_paramGet(REMAPNOTE),velo);
- break;
- }
- }
- }
- return retval;
- }
- // called on start and on param change from exchange portal
- void updateParams(){
- // need to decrement the parameter for readable - programming conversion; ch 0-15 = 1-16 un human read
- dChannel = (RK002_paramGet(CHANNEL)>0) ? RK002_paramGet(CHANNEL)-1 : 16;
- }
- void RK002_onParamSet(unsigned param_nr, int val){
- updateParams();
- }
- // initialize
- void setup()
- {
- updateParams();
- }
- // the main loop
- void loop()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement