retrokits

RK002 Simple Control Change remap example

Jun 14th, 2022 (edited)
1,055
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* DUY Code: ARP Arpeggio example */
  2.  
  3. /*
  4.  * short example for remapping a CC (with a configurable midi channel)
  5.  * PARAMETERS:
  6.  * MIDICHN :0=16 (0=omni, 1-16 (1=default))
  7.  */
  8.  
  9. RK002_DECLARE_PARAM(MIDICHN,1,0,16,1); // accessable parameter/range via portal
  10. byte midichn = 0; // holds internal midi working channel
  11.  
  12. // handler for param changes
  13. void updateParams()
  14. {
  15.   if(RK002_paramGet(MIDICHN)==0){ // is omni setting?
  16.     midichn=16; // 16 is all channels
  17.   }else{ // minus 1 for internal midi channel 0=15
  18.       midichn = RK002_paramGet(MIDICHN) - 1;
  19.   }
  20. }
  21.  
  22. // called automatically on paramchange in portal
  23. void RK002_onParamChange(unsigned param_nr, int param_val)
  24. {
  25.   updateParams();
  26. }
  27.  
  28.  
  29. bool RK002_onControlChange(byte chn, byte cc, byte ccvalue)
  30. {
  31.   bool thru = true; // pass original parameter yes/no?
  32.   if ((chn == midichn) || (midichn==16)) // are we in working channel?
  33.   {
  34.     if(cc==10){
  35.       // remap cc 10 to cc 18
  36.       RK002_sendControlChange(chn,18,ccvalue);
  37.       // add more if you want here
  38.     }
  39.     if(cc==11){
  40.       // remap cc 11 to cc 19
  41.            RK002_sendControlChange(chn,19,ccvalue);
  42.       // add more if you want here
  43.     }
  44.     thru=false; // omit original CC
  45.   }
  46.   return thru;
  47. }
  48.  
  49. void setup()
  50. {
  51.   updateParams(); // set/load user conf. parameters
  52. }
  53.  
  54. void loop()
  55. {
  56. }
  57.  
Add Comment
Please, Sign In to add comment