Old 05-25-2020, 01:16 PM   #1
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default Help with code. Parameters resets on stop/play

Hi

The title sums it up. For some reason slider values resets to weird values on startup stop/start. At least thats what I think is happening. No idea why so suggestions are very welcome.

Thanks /Bo

Code:
//RMS code by SaulT

desc:RMS Compressor 0.14 Danerius

slider1:50<1,200,1>Compression Ratio %
//slider3:delta=0<0,1,{Stereo,MidSide}>Channel Routing
slider2:1<0,4,1{Less,Regular,More,Even More}>Fudge
slider3:3<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();

@slider
ratio = (250 * pow(0.94, slider1));
//leveler = xxx;
 
fudgefactor = (slider2 == 0 ? 0.25 :
              (slider2 == 1 ? 0.5 :
              (slider2 == 2 ? 0.75 :
              (slider2 == 3 ? 1 :
              0 ))));

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 )))))))))));
          
  rms0.RMS_set(notevalue * factor); // sets rms0 as RMS length

@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);
    );


@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+fudgefactor)/(ratio+s0)) - spl0;
  spl1 = spl1 * ((ratio+fudgefactor)/(ratio+s1)) - spl1;
  );(
  spl0 = spl0 * ((ratio+fudgefactor)/(ratio+s0));// * slider4;
  spl1 = spl1 * ((ratio+fudgefactor)/(ratio+s1));// * slider4;
  );
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 09:51 AM.


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