Send MIDI CC x 5 (js reaper script)

Discussion in 'Reaper' started by nikon, Jun 6, 2014.

  1. nikon

    nikon Platinum Record

    Joined:
    Oct 6, 2012
    Messages:
    954
    Likes Received:
    169
    I found this usefull js script MIDI_CC_SENDER for Reaper

    http://stash.reaper.fm/v/5113/midi_cc_sender.png

    http://stash.reaper.fm/v/5099/midi_cc_sender

    and I develop the same thing but with 5 controls (as I don't know and don't read js reference I do this in the old way of copying :))

    As I don't own modwheel on my midi keyboard, this is very usefull with Orchestral type of Kontakt libraries like CineSamples etc...

    Just add this midi sender in front of Kontakt.

    Code should like this:

    Code:
    // ============================================================================
    // The program:
    // ============================================================================
    
    
    // intialize the GUI
    // ----------------------------------------------------------------------------
    
    // set a little text description of the JS script
    desc:MIDI 5 CC sender (automate me!)
    
    // define sliders
    
    // control 1 (modwheel)
    slider1:1<0,127,1{0 Bank Sel M,1 Mod Wheel M,2 Breath M,3,4 Foot P M,5 Porta M,6 Data Entry M,7 Vol M,8 Balance M,9,10 Pan M,11 Expression M,12 Ctrl 1 M,13 Ctrl 2 M,14,15,16 GP Slider 1,17 GP Slider 2,18 GP Slider 3,19 GP Slider 4,20,21,22,23,24,25,26,27,28,29,30,31,32 Bank Sel L,33 Mod Wheel L,34 Breath L,35,36 Foot P L,37 Porta L,38 Data Entry L,39 Vol L,40 Balance L,41,42 Pan L,43 Expression L,44 Ctrl 1 L,45 Ctrl 2 L,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64 Hold P sw,65 Porta sw,66 Sustenuto sw,67 Soft P sw,68 Legato P sw,69 Hold 2 P sw,70 S.Variation,71 S.Timbre,72 Release,73 Attack,74 Cutoff,75 Decay,76 S.Ctrl 7,77 S.Ctrl 8,78 S.Ctrl 9,79 S.Ctrl 10,80 GP B.1 sw,81 GP B.2 sw,82 GP B.3 sw,83 GP B.4 sw,84,85,86,87,88,89,90,91 Effects Lv,92 Trem Lv,93 Chorus Lv,94 Celeste Lv,95 Phaser Lv,96 Data B. Inc,97 Data B. Dec,98 NRP L,99 NRP M,100 RP L,101 RP M,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127}>CC Controller
    
    slider2:0<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>MIDI channel
    
    slider3:127<0,127,1>value
    
    // control 2 (expression)
    slider4:11<0,127,1{0 Bank Sel M,1 Mod Wheel M,2 Breath M,3,4 Foot P M,5 Porta M,6 Data Entry M,7 Vol M,8 Balance M,9,10 Pan M,11 Expression M,12 Ctrl 1 M,13 Ctrl 2 M,14,15,16 GP Slider 1,17 GP Slider 2,18 GP Slider 3,19 GP Slider 4,20,21,22,23,24,25,26,27,28,29,30,31,32 Bank Sel L,33 Mod Wheel L,34 Breath L,35,36 Foot P L,37 Porta L,38 Data Entry L,39 Vol L,40 Balance L,41,42 Pan L,43 Expression L,44 Ctrl 1 L,45 Ctrl 2 L,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64 Hold P sw,65 Porta sw,66 Sustenuto sw,67 Soft P sw,68 Legato P sw,69 Hold 2 P sw,70 S.Variation,71 S.Timbre,72 Release,73 Attack,74 Cutoff,75 Decay,76 S.Ctrl 7,77 S.Ctrl 8,78 S.Ctrl 9,79 S.Ctrl 10,80 GP B.1 sw,81 GP B.2 sw,82 GP B.3 sw,83 GP B.4 sw,84,85,86,87,88,89,90,91 Effects Lv,92 Trem Lv,93 Chorus Lv,94 Celeste Lv,95 Phaser Lv,96 Data B. Inc,97 Data B. Dec,98 NRP L,99 NRP M,100 RP L,101 RP M,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127}>CC Controller
    
    slider5:0<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>MIDI channel
    
    slider6:0<0,127,1>value
    
    // control 3 (breath)
    slider7:2<0,127,1{0 Bank Sel M,1 Mod Wheel M,2 Breath M,3,4 Foot P M,5 Porta M,6 Data Entry M,7 Vol M,8 Balance M,9,10 Pan M,11 Expression M,12 Ctrl 1 M,13 Ctrl 2 M,14,15,16 GP Slider 1,17 GP Slider 2,18 GP Slider 3,19 GP Slider 4,20,21,22,23,24,25,26,27,28,29,30,31,32 Bank Sel L,33 Mod Wheel L,34 Breath L,35,36 Foot P L,37 Porta L,38 Data Entry L,39 Vol L,40 Balance L,41,42 Pan L,43 Expression L,44 Ctrl 1 L,45 Ctrl 2 L,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64 Hold P sw,65 Porta sw,66 Sustenuto sw,67 Soft P sw,68 Legato P sw,69 Hold 2 P sw,70 S.Variation,71 S.Timbre,72 Release,73 Attack,74 Cutoff,75 Decay,76 S.Ctrl 7,77 S.Ctrl 8,78 S.Ctrl 9,79 S.Ctrl 10,80 GP B.1 sw,81 GP B.2 sw,82 GP B.3 sw,83 GP B.4 sw,84,85,86,87,88,89,90,91 Effects Lv,92 Trem Lv,93 Chorus Lv,94 Celeste Lv,95 Phaser Lv,96 Data B. Inc,97 Data B. Dec,98 NRP L,99 NRP M,100 RP L,101 RP M,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127}>CC Controller
    
    slider8:0<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>MIDI channel
    
    slider9:0<0,127,1>value
    
    // control 4 (foot)
    slider10:4<0,127,1{0 Bank Sel M,1 Mod Wheel M,2 Breath M,3,4 Foot P M,5 Porta M,6 Data Entry M,7 Vol M,8 Balance M,9,10 Pan M,11 Expression M,12 Ctrl 1 M,13 Ctrl 2 M,14,15,16 GP Slider 1,17 GP Slider 2,18 GP Slider 3,19 GP Slider 4,20,21,22,23,24,25,26,27,28,29,30,31,32 Bank Sel L,33 Mod Wheel L,34 Breath L,35,36 Foot P L,37 Porta L,38 Data Entry L,39 Vol L,40 Balance L,41,42 Pan L,43 Expression L,44 Ctrl 1 L,45 Ctrl 2 L,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64 Hold P sw,65 Porta sw,66 Sustenuto sw,67 Soft P sw,68 Legato P sw,69 Hold 2 P sw,70 S.Variation,71 S.Timbre,72 Release,73 Attack,74 Cutoff,75 Decay,76 S.Ctrl 7,77 S.Ctrl 8,78 S.Ctrl 9,79 S.Ctrl 10,80 GP B.1 sw,81 GP B.2 sw,82 GP B.3 sw,83 GP B.4 sw,84,85,86,87,88,89,90,91 Effects Lv,92 Trem Lv,93 Chorus Lv,94 Celeste Lv,95 Phaser Lv,96 Data B. Inc,97 Data B. Dec,98 NRP L,99 NRP M,100 RP L,101 RP M,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127}>CC Controller
    
    slider11:0<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>MIDI channel
    
    slider12:0<0,127,1>value
    
    // control 5 (portamento)
    slider13:5<0,127,1{0 Bank Sel M,1 Mod Wheel M,2 Breath M,3,4 Foot P M,5 Porta M,6 Data Entry M,7 Vol M,8 Balance M,9,10 Pan M,11 Expression M,12 Ctrl 1 M,13 Ctrl 2 M,14,15,16 GP Slider 1,17 GP Slider 2,18 GP Slider 3,19 GP Slider 4,20,21,22,23,24,25,26,27,28,29,30,31,32 Bank Sel L,33 Mod Wheel L,34 Breath L,35,36 Foot P L,37 Porta L,38 Data Entry L,39 Vol L,40 Balance L,41,42 Pan L,43 Expression L,44 Ctrl 1 L,45 Ctrl 2 L,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64 Hold P sw,65 Porta sw,66 Sustenuto sw,67 Soft P sw,68 Legato P sw,69 Hold 2 P sw,70 S.Variation,71 S.Timbre,72 Release,73 Attack,74 Cutoff,75 Decay,76 S.Ctrl 7,77 S.Ctrl 8,78 S.Ctrl 9,79 S.Ctrl 10,80 GP B.1 sw,81 GP B.2 sw,82 GP B.3 sw,83 GP B.4 sw,84,85,86,87,88,89,90,91 Effects Lv,92 Trem Lv,93 Chorus Lv,94 Celeste Lv,95 Phaser Lv,96 Data B. Inc,97 Data B. Dec,98 NRP L,99 NRP M,100 RP L,101 RP M,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127}>CC Controller
    
    slider14:0<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>MIDI channel
    
    slider15:0<0,127,1>value
    
    
    // initialize constants
    // ----------------------------------------------------------------------------
    @init
    CC_MESG_MIN = 176;  // a CC message on MIDI channel 1
    BYTE_SIZE   = 256;  // size of an 8-bit byte
    offset      = 0;    // sample offset for midisend
    
    send_cc_1     = 0;    // trigger 1
    last_value_1  = 0;    // last known CC value
    
    send_cc_2     = 0;    // trigger 2
    last_value_2  = 0;    // last known CC value
    
    send_cc_3     = 0;    // trigger 3
    last_value_3  = 0;    // last known CC value
    
    send_cc_4     = 0;    // trigger 4
    last_value_4  = 0;    // last known CC value
    
    send_cc_5     = 0;    // trigger 5
    last_value_5  = 0;    // last known CC value
    
    // link each slider with a variable
    // ----------------------------------------------------------------------------
    @slider
    cc_1      = slider1;
    channel_1 = slider2;
    value_1   = slider3;
    ( value_1 != last_value_1 )? send_cc = 1;
    
    cc_2      = slider4;
    channel_2 = slider5;
    value_2   = slider6;
    ( value_2 != last_value_2 )? send_cc = 1;
    
    cc_3      = slider7;
    channel_3 = slider8;
    value_3   = slider9;
    ( value_3 != last_value_3 )? send_cc = 1;
    
    cc_4      = slider10;
    channel_4 = slider11;
    value_4   = slider12;
    ( value_4 != last_value_4 )? send_cc = 1;
    
    cc_5      = slider13;
    channel_5 = slider14;
    value_5   = slider15;
    ( value_5 != last_value_5 )? send_cc = 1;
    
    
    // the main loop 
    // ----------------------------------------------------------------------------
    @block
    send_cc ?
    (
    // send the message 1
    msg1 = channel_1 + CC_MESG_MIN;
    msg23 = cc_1 + ( value_1 * BYTE_SIZE );  
    midisend( offset, msg1, msg23 ); 
    send_cc_1 = 0;
    last_value_1 = value_1;
    
    // send the message 2
    msg1 = channel_2 + CC_MESG_MIN;
    msg23 = cc_2 + ( value_2 * BYTE_SIZE );  
    midisend( offset, msg1, msg23 ); 
    send_cc_2 = 0;
    last_value_2 = value_2;
    
    // send the message 3
    msg1 = channel_3 + CC_MESG_MIN;
    msg23 = cc_3 + ( value_3 * BYTE_SIZE );  
    midisend( offset, msg1, msg23 ); 
    send_cc_3 = 0;
    last_value_3 = value_3;
    
    // send the message 4
    msg1 = channel_4 + CC_MESG_MIN;
    msg23 = cc_4 + ( value_4 * BYTE_SIZE );  
    midisend( offset, msg1, msg23 ); 
    send_cc_4 = 0;
    last_value_4 = value_4;
    
    // send the message 5
    msg1 = channel_5 + CC_MESG_MIN;
    msg23 = cc_5 + ( value_5 * BYTE_SIZE );  
    midisend( offset, msg1, msg23 ); 
    send_cc_5 = 0;
    last_value_5 = value_5;
    )
    
    
     
  2.  
  3. junh1024

    junh1024 Rock Star

    Joined:
    Jul 28, 2011
    Messages:
    1,396
    Likes Received:
    433
    Does this work?

    instead of


    ( value_1 != last_value_1 )? send_cc = 1;

    should be

    ( value_1 != last_value_1 )? send_cc_1 = 1; //and etc?

    Also, instead of


    Code:
    send_cc ?
    (
    // send the message 1
    blabla
    
    // send the message 2
    etc
    )
    


    should be
    Code:
    
    send_cc_1?
    (
    // send the message 1
    )
    
    
    send_cc_2?
    (
    // send the message 2
    )
    
    
    
    perhaps?
     
  4. nikon

    nikon Platinum Record

    Joined:
    Oct 6, 2012
    Messages:
    954
    Likes Received:
    169
    No, it won't work, but I don't get it ?! I put script which actualy work. I'm not asking for help :)
     
Loading...
Loading...