View Single Post
Old 09-10-2016, 10:29 AM   #18
Time Waster
Human being with feelings
 
Time Waster's Avatar
 
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,643
Default

I have added a new operation to the CC Mixer module. I called it 'Overlay'. It just takes the maximum value of the two CC inputs. I also fixed a graphics bug. I will get around to uploading it to the stashb ut in the meantime, here is the revised code:

Code:
version: 1.1.0
desc:ReaRack - CC Mixer
author: Malcolm Smith
changelog: Added the Overlay operation option. Fixed a graphics bug.

/*Version 1.0.0 (2/9/2016) Initial release.
  Version 1.1.0 (9/9/2016) Added the Overlay operation option. Fixed a graphics bug.

 Copyright(C) 2016 and later, Malcolm Smith (username 'Time Waster' on REAPER forums).
 License: LGPL - http://www.gnu.org/licenses/lgpl.html
*/

slider1:20<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 S.Release,73 S.Attack,74 S.Brightness,75 S.Ctrl 6,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 Input 1
slider2:21<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 S.Release,73 S.Attack,74 S.Brightness,75 S.Ctrl 6,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 Input 2
slider3:22<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 S.Release,73 S.Attack,74 S.Brightness,75 S.Ctrl 6,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 Output
slider4:0<0,15,1{All,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>MIDI Output Channel
slider5:1<0,1>Input 1 Limit
slider6:1<0,1>Input 2 Limit
slider7:0<0,2,1{Multiply,Add,Overlay}>Operation

in_pin:none
out_pin:none

@slider
ccIn1 = slider1;
ccIn2 = slider2;
ccOut = slider3;
chanOut = slider4-1;
lev1 = slider5;
lev2 = slider6;
op = slider7;

@block

while (midirecv(offset, msg1, msg2, msg3))
(
  // Extract message type
  modstatus = msg1;
  status = msg1 & $xF0;
  //Is it not a controller event?
  status != $xB0 ? midisend(offset, msg1, msg2, msg3);//Pass thru
  //Is it not either input CC?
  msg2 != cc1in || cc2in ? midisend(offset, msg1, msg2, msg3);//Pass thru 
  // Is it a controller event?
  // Is it the right CC for input 1? 
  status == $xB0 &&  msg2 == ccIn1 ? 
    (
    val1 = msg3;
    ccIn1 != ccOut ? midisend(offset, msg1, msg2, msg3);           
    );            
  // Is it a controller event?
  // Is it the right CC for input 2?
  //channel == chanIn2 && 
  status == $xB0 && msg2 == ccIn2 ? 
    (
     val2 = msg3;
     ccIn2 != ccOut ? midisend(offset, msg1, msg2, msg3);            
    );
);
op == 0 ?
  (
  // Multiply values together
  val1att = (1-(lev1*(1-(val1/127))));
  val2att = (1-(lev2*(1-(val2/127))));
  val3 = floor((127*(val1att*val2att))+0.5);
  );
op == 1 ? 
  (
  // Add values together
  val1att = (val1*lev1)/127; //used @gfx
  val2att = (val2*lev2)/127; //used @gfx
  val3 = floor((min((val1*lev1)+(val2*lev2),127))+0.5);
  );
op == 2 ?    
  (
  // Overlay Values
  val1att = (val1*lev1)/127; //used @gfx
  val2att = (val2*lev2)/127; //used @gfx
  val3 = floor((max(val1*lev1,val2*lev2))+0.5);
  );
//Send new CC message
chanout == -1 ? (
  n = 0;
  loop(16,
  midisend(offset,$xB0+n,ccOut,val3);
  n += 1;
  );
):(
  midisend(offset,$xB0+chanOut,ccOut,val3);
);

@gfx 400 180

gfx_r = 0;
gfx_g = 1;
gfx_b = 0;
gfx_a = 1;
////////////////////input 1 meter///////////////////
gfx_x=50;
gfx_y=25+127;
gfx_lineto(50,(25+127)-(val1att*127));
gfx_lineto(60,(25+127)-(val1att*127));
gfx_lineto(60,(25+127));
////////////////////input 2 meter///////////////////
gfx_x=150;
gfx_y=25+127;
gfx_lineto(150,(25+127)-(val2att*127));
gfx_lineto(160,(25+127)-(val2att*127));
gfx_lineto(160,(25+127));
////////////////////output meter////////////////////
gfx_x=250;
gfx_y=25+127;
gfx_lineto(250,(25+127)-val3);
gfx_lineto(260,(25+127)-val3);
gfx_lineto(260,(25+127));
////////////////////////level lines/////////////////
gfx_r = 1;
gfx_g = 0;
gfx_a = 0.5;
gfx_x = 25;
gfx_y = 25;
gfx_lineto(25+(260),25);
gfx_x = 25;
gfx_y = 25+127;
gfx_lineto(25+(260),25+127);
gfx_x=50;
op == 0 ?
(
gfx_y=25+127-(127-(lev1*127));
gfx_lineto(100,25+127-(127-(lev1*127)));
gfx_x=150;
gfx_y=25+127-(127-(lev2*127));
gfx_lineto(200,25+127-(127-(lev2*127)));
)
:
(
gfx_y=25+127-(lev1*127);
gfx_lineto(100,25+127-(lev1*127));
gfx_x=150;
gfx_y=25+127-(lev2*127);
gfx_lineto(200,25+127-(lev2*127));
);
////////////////////////text////////////////////////
gfx_a =1;
gfx_x = 13;
gfx_y = 20;
gfx_drawstr("1");
gfx_x = 13;
gfx_y = 20+127;
gfx_drawstr("0");
gfx_x = 25+265;
gfx_y = 20;
gfx_drawstr("(127)");
gfx_x = 25+265;
gfx_y = 20+127;
gfx_drawstr("(0)");
gfx_a = 1;
op == 0 ?
(
gfx_x=65;
gfx_y=25+117-(127-(lev1*127));
gfx_drawstr("Min.");
gfx_x=165;
gfx_y=25+117-(127-(lev2*127));
gfx_drawstr("Min.");
)
:
(
gfx_x=65;
gfx_y=25+117-(lev1*127);
gfx_drawstr("Max.");
gfx_x=165;
gfx_y=25+117-(lev2*127);
gfx_drawstr("Max.");
);
gfx_r = 0;
gfx_g = 1;
gfx_a = 1;

gfx_x = 35;
gfx_y = 30+127;
gfx_drawstr("Input 1  ");
op == 0 ? gfx_drawstr("x"):gfx_drawstr("+");
gfx_drawstr("  Input 2   =  Output");
__________________
Mal, aka The Wasters of Time
Mal's JSFX: ReaRack2 Modular Synth
Time Waster is offline   Reply With Quote