View Single Post
Old 11-11-2019, 11:46 PM   #6
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,403
Default

As pushing it to the repository might take some days and I guess you are able to install it manually, here you are:
Code:
desc:MIDI  CC fluctuation
//tags: MIDI processing filter
//author: MSchnell


// these lines tell Reaper the effect has no audio input/output,
// which enables processing optimizations.
// MIDI-only FX should always have these lines.
in_pin:none
out_pin:none


slider1:  0<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Midi Channel 
slider2:  16<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}>CC
slider3:  0.5<0,1,0.01>Delta wide (^1)
slider4:  0<0,1,0.01>Delta mid (^3)
slider5:  1<0,1,0.01>Delta narrow (^5)
slider6:  0.1<0,0.1,0.01>Hold speed
slider7:  0.9<0,1,0.001>Hold mix 
slider8:  0.1<0,1,0.001>Speed (Roughness) 
slider9:  0.01<0,1,0.01>Result wide (^1)
slider10: 0.01<0,1,0.01>Result mid (^3)
slider11: 0.01<0,1,0.01>Result narrow (^5)
slider12: 0.0001<0,0.1,0.0001>maximum step
slider13: 1<0,10,0.1>gain
slider14: 0<-1,1,0.1>bias

slider20: 0<-1,1,0.01>Delta
slider21: 0<-1,1,0.01>Hold
slider22: 0<-1,1,0.01>Delta with Hold
slider23: 0<-1,1,0.01>Result raw
slider24: 0<-1,1,0.01>Result -1 ... 1
slider25: 0<0,16383,1>Result Midi (0 ... 16383)


@init
  CC_MSG      =  0xB0; // 11;  
  s  = 0;
  h  = 0;
  result= 0;
  msg31 = -1;
  msg32 = -1;
  offset = 0;
  _p = 0;
  _result = 0;
  _delta  = 2560;
  memset(_result, 8192, 2560);
  memset(_delta,  0,    2560);
  
@slider
  msg1  = CC_MSG + slider1;
  msg21 = slider2;
  msg22 = msg21 + 32;
  
  a1 = slider3;
  a3 = slider4;
  a5 = slider5;
  aa = a1 + a3 + a5;
  aa > 1 ? (
    a1 /= aa;
    a3 /= aa;
    a5 /= aa;
  );
  
  s_h  = slider6;
  v_h  = slider7;
  
  sp = slider8;
  sp = exp(sp*log(200)) / 200;
  
  s1 = slider9;
  s3 = slider10;
  s5 = slider11;
  ss = s1 + s3 + s5;
  ss > 1 ? (
    s1 /= ss;
    s3 /= ss;
    s5 /= ss;
  );
  s1 *= sp;
  
  ms   = slider12;
  gain = slider13;
  bias = slider14;
  
  


@block 
  r  = rand();
  v1 = r*2 - 1;
  v2 = v1*v1;
  v3 = v1*v2;
  v5 = v3*v2;
  va = a1*v1 +a3*v3 + a5*v5;
  slider20 = va;
  
/*
  va > h + hyst ? (
    h = va;
    va = -va;                 // avoid exeeding ly ar jump
   ) : (
    va < h - hyst ? (
      h = va;
      va = -va;               // avoid exeeding ly ar jump
    );  
  );
*/
  r = rand();
  r < s_h ? ( 
    h = va;
    va = -va;               // avoid exeeding ly ar jump    
  );
  
  slider21 = h;
  
  vh = (1-v_h)*va + v_h*h;
  slider22 = vh;
  _delta[_p] = vh;
  
  s += sp*vh;
  
  s < -1 ? s = -1;
  s >  1 ? s =  1;

  d1 = s;
  d2 = s*s;
  d3 = d2*s;
  d5 = d3*d2;
  s -= d1*s1;
  s -= d3*s3;
  s -= d5*s5;
  
  result < s-ms ? (
     result += ms;
    ) : result > s + ms ? (
      result -= ms;
   ) : ( 
    result = s;
  );  
  
  slider23 = result;

  result_1 = result * gain + bias;
  result_1 < -1 ? result_1 = -1;
  result_1 >  1 ? result_1 =  1;
  
  slider24 = result_1;
  
  
  
  _m = (result_1 + 1) / 2;  
  m  = (_m * 16384) | 0; 
  m  > 16383 ? m = 16383;
  slider25 = m;
  m1 = (m / 128) | 0;
  m2 = m - 128 * m1; 

  msg31 != m1 ? (
    msg31 = m1;
    midisend(offset, msg1, msg21, msg31);    
  );
  msg32 != m2 ? (
    msg32 = m2;
    midisend(offset, msg1, msg22, msg32);    
  );
  
  _p >= _w ? _p = 0 : _p += 1;
  _result[_p] = m;

@sample  

@gfx 640 400
  _w = gfx_w;  
  _w > 2560 ? _w = 2560;    // HDMI
  gfx_r=gfx_g=gfx_b=0; gfx_a=1;
  gfx_x=gfx_y=0;
  gfx_rectto(gfx_w, gfx_h);
  _a = 0;
  _min = 16384;
  _max = 0;
  _pp = 0;
  loop (_w,
    _y = _result[_pp];
    _a += _y;
    _min > _y ? _min = _y;
    _max < _y ? _max = _y;
    _pp += 1;
  );
  _a /= _w;
  _min = 8192 - _min;
  _max = _max - 8192;
  _max < _min ? _max = _min;
  _fact = gfx_h / _max / 2;
  _offs = gfx_h /2;
  _offs += 8192*_fact;


  _min_d = 1;
  _max_d = -1;
  _pp = 0;
  loop (_w,
    _y = _delta[_pp];
//    _a += _y;
    _min_d > _y ? _min_d = _y;
    _max_d > _y ? _max_d = _y;
    _pp += 1;
  );
//  _a /= _w;
  _min_d = - _min_d;
  _max_d < _min_d ? _max_d = _min_d;
  _fact_d = gfx_h / _max_d / 2;
  _offs_d = gfx_h /2;


  _y = gfx_h / 2;
  gfx_x = 0;
  gfx_y = _y;
  gfx_r=gfx_g=gfx_b=0.5; 
  gfx_lineto(_w-1, _y); 
 
  _y = _offs - _a * _fact;
  gfx_x = 0;
  gfx_y = _y;
  gfx_g = 0; 
  gfx_r = 1; 
  gfx_lineto(_w-1, _y); 
  
  
  gfx_b = 0.75; gfx_r=gfx_g=0; 
  _x = 0;
  gfx_x = 0;
  _pp = _p-1;
  _y = _offs - _delta[_pp] * _fact_d;
  gfx_y = _y;
  loop (_w-1,
    _x += 1;
    _pp += 1;
    _pp > _w ? _pp = 0;    
    _y = _offs_d - _delta[_pp] * _fact_d;
    gfx_lineto(_x, _y);
  );  
  
  gfx_b = 0; gfx_r=gfx_g=1; 
  _x = 0;
  gfx_x = 0;
  _pp = _p-1;
  _y = _offs - _result[_pp] * _fact;
  gfx_y = _y;
  loop (_w-1,
    _x += 1;
    _pp += 1;
    _pp > _w ? _pp = 0;    
    _y = _offs - _result[_pp] * _fact;
    gfx_lineto(_x, _y);
  );
...

Last edited by mschnell; 11-12-2019 at 12:09 AM.
mschnell is offline   Reply With Quote