Old 05-19-2020, 06:03 AM   #1
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 107
Default Adjustable Function for RMS Size

Hi

Im making a compressor and Ive borrowed SaulTs RMS code and its working great but having a hard time making it adjustable. Ive tried a bunch of different ways but none of them has worked.

So "200" is the paramater Id like to adjustable via the slider3 code. Any suggestions?
Code:
rms0.RMS_set(200);
Heres the rest of the code. Also... Why is Fudge showing a different number in the display window than what the slider numbers are?

/Thanks + best regards

Code:
//RMS code by SaulT
desc:RMS Compressor 0.13 Danerius

slider1:0<0,100,1>Ratio
//slider3:delta=0<0,1,{Stereo,MidSide}>Channel Routing
slider2:1<0.25,1,0.25{Less,Regular,More,Even More}>Fudge
slider3:5<0,10,1{1/1, 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256, 1/512, 1/1024)>Note Length
slider4:1<0,1,0.01>Outgain
slider5:0<0,1,1{Off,On}>Delta

@block
firstrun == 0 ? notecalc();

@init

function notecalc(slider)
  (
    notevalue = 240000/tempo;    
  );

function RMS_set(ms)
  instance(coeff, icoeff)
    (
      coeff = exp(-1/(ms * 0.001 * srate)); //Add tempo to this calculation
      icoeff = 1-coeff;
    );

function RMS(input)
  instance(rms_s, coeff, icoeff)
    (
      rms_s = (rms_s * this.coeff) + (icoeff * input * input); //Is "input" spl?
      sqrt(rms_s);
    );

rms0.RMS_set(200); // sets rms0 as RMS length

@slider
ratio = (100 * pow(0.93, slider1));

factor =  (slider3 ==  0 ? 1 : 
          (slider3 ==  1 ? 0.5 : 
          (slider3 ==  2 ? 0.25 : 
          (slider3 ==  3 ? 0.125 : 
          (slider3 ==  4 ? 0.0625 : 
          (slider3 ==  5 ? 0.03125 : 
          (slider3 ==  6 ? 0.015625 :
          (slider3 ==  7 ? 0.0078125 :
          (slider3 ==  8 ? 0.00390625 :
          (slider3 ==  9 ? 0.001953125 :
          (slider3 == 10 ? 0.0009765625 :
          0 )))))))))));

@sample

s0 = rms0.RMS(spl0); // s0 now contains the "rmslen" RMS of spl0
s1 = rms0.RMS(spl1); // s1 now contains the "rmslen" RMS of spl1

//Delta function in slider5 if/else borrowed from witti
slider5 > 0.5 ? (
  spl0 = spl0 * ((ratio+slider2)/(ratio+s0)) - spl0;
  spl1 = spl1 * ((ratio+slider2)/(ratio+s1)) - spl1;
  );(
  spl0 = spl0 * ((ratio+slider2)/(ratio+s0));
  spl1 = spl1 * ((ratio+slider2)/(ratio+s1));
  );

spl0 = spl0 * slider4;
spl1 = spl1 * slider4; 

@gfx 120 200
gfx_a = 1.0;
l = t = 20;
w = 60;
h = 120;
r = l + w;
b = t + h;

gfx_r = 1.0; gfx_g = gfx_b = 0.0;
gfx_x = l;
gfx_y = b;
level = 2 ^ log10(s0 + s1);
gfx_rectto(r, b - (s0 * h * 1.25));

gfx_r = gfx_g = gfx_b = 1.0;
gfx_x = l;
gfx_y = t;

gfx_x = 100; gfx_y = 20; 
gfx_drawnumber(tempo,0); gfx_drawstr(" BPM");

gfx_x = 100; gfx_y = 35; 
gfx_drawnumber(notevalue*factor,1); gfx_drawstr(" Milliseconds");

gfx_x = 100; gfx_y = 50; 
gfx_drawnumber(slider2,2); gfx_drawstr(" Fudge");
danerius is offline   Reply With Quote
Old 05-20-2020, 10:28 PM   #2
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 107
Default

Anyone...?
danerius is offline   Reply With Quote
Old 05-23-2020, 06:15 PM   #3
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 809
Default

Put “ rms0.RMS_set(200); ” inside the @slider section, replace 200 with sliderx.
SaulT is offline   Reply With Quote
Old 05-24-2020, 01:36 PM   #4
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 107
Default

Quote:
Originally Posted by SaulT View Post
Put “ rms0.RMS_set(200); ” inside the @slider section, replace 200 with sliderx.
Thanks SaulT. That did the trick

/Best regards
danerius is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:31 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.