music/daw/reaper/ SomeOfMyScripts


Automation to CC

desc: JDA MIDI to CC
//tags: MIDI processing routing

slider1:1<1,16,1>channel
slider2:1<0,127,1>CC number
slider3:0<0,127,1>CC value

in_pin:none
out_pin:none

@init

last = slider3;

@slider

chan = slider1 - 1;
cc = slider2;

@block

new = slider3;
(new != last ? (
  last = new;
  msg1 = 0xB0 | chan; 
  msg2 = cc;
  msg3 = new;
  msg23 = (msg3*256)|msg2;
  midisend(0,msg1,msg23);
));

Velocity To Modwheel

desc:Chalisque MIDI velocity to Modwheel
//tags: MIDI processing

@init

@block

// mod wheel is cc1
// so when we receive a noteon,
// echo the noteon to output,
// either echoing the velocity value, or setting
// it to a standard value
// rather than use controls
// I prefer to have multiple scripts
// so the only controls are the ones I want to automate
while (
    midirecv(mpos,msg1,msg23) ? (
        // message type
        m=msg1&240; // picks out the high nibble (the F in 0xFE)
        // channel
        c=msg1&15; // picks out the low nibble (the E in 0xFE)
        // velocity
        vel=(msg23/256)|0;
        // midi pitch
        note=msg23&127;
        // is it a note on (note on with vel=0 is note off)
        m == 9*16 && vel > 0 ? (
            // note on event
            // we want to change the message from
            // 9XYYZZ (note on, where X is channel, YY is pitch, ZZ velocity)
            // to
            // BX01ZZ (cc, X is channel, 1 is modwheel, ZZ value)
            ccmsg1=0xB0|c; // construct first byte
            ccmsg23=(msg23&0xff00)|1; // construct last 2 bytes
            midisend(mpos,msg1,msg23); // echo note on
            midisend(mpos,0xB0|c,ccval); // output modwheel
        ) : (
            midisend(mpos,msg1,msg23); // passthru
        );
    );
);