View Single Post
Old 10-30-2016, 09:17 AM   #641
TBProAudio
Human being with feelings
 
TBProAudio's Avatar
 
Join Date: May 2014
Location: Germany
Posts: 643
Default

Quote:
Originally Posted by lb0 View Post
Hi TBPro - I've been trying out your jsfx and it works great. One thing I've noticed is that when activated - it takes over the value returned by the reaper.GetLastTouchedFX API - so I cannot 'learn' other parameters until I disable it. Is this fixable? I guess it's due to the slider _Automate bit (not up with JSFX lingo). Is this constantly outputting values? Can it be made to output a value only when the value is different from the last? (or is it all 'under the hood') - I'm wondering if this might fix the issue. I really don't know how it works TBH
Ok, lets try this:

vurmsmeter_JSFX

Code:
// This effect Copyright (C) 2016 and later TBProAudio
// License: GPL - http://www.gnu.org/licenses/gpl.html
//
// 1.0: initial release
// 2.0: Write automation data only if value has changed


desc: VU/RMS Meter 2.0 (TBProAudio)

slider1:0<-20,3,0.1>,-OUT:VU Left
slider2:0<-20,3,0.1>,-OUT:VU Right
slider3:0<-20,3,0.1>,-OUT:VU Stereo
slider4:0<-60,0,0.1>,-OUT:RMS Left
slider5:0<-60,0,0.1>,-OUT:RMS Right
slider6:0<-60,0,0.1>,-OUT:RMS Stereo

slider10:300<10,3000,1>Raise/Fall Time (ms)

@init
function dround(x, n)
local (scale)
(
  scale = pow(10.0, n);
  floor(x * scale + 0.5) / scale;
); 

function RMSQ_Reset()
(
  this.runave   = 0.0;
  this.runmax   = 0.0;
);

function RMSQ_Init(_rmswindow_s, _srate)
(
  this.rmscoef = pow(10,-1.0/(_rmswindow_s * _srate));
  this.Amp2DBFS = 6.0/log(2.0);
  
  this.RMSQ_Reset();
);

function RMSQ_Process(_in0, _in1)
(
  this.maxspl = (_in0 * _in0 + _in1 * _in1);
  this.runave = this.maxspl + this.rmscoef * (this.runave - this.maxspl);
  this.runmax = max(this.runmax, this.runave);
);

function RMSQ_Get()
(
  sqrt(this.runave);
);

function RMSQ_Get_dB()
(
  log(this.RMSQ_Get())*this.Amp2DBFS;
);

function RMSQ_GetMax()
(
  sqrt(this.runmax);
);

function RMSQ_GetMax_dB()
(
  log(this.RMSQ_GetMax())*this.Amp2DBFS;
);


function VUMeter_Reset()
(
  this.runave = 0.0;
  this.runmax   = 0.0;
);

function VUMeter_Init(_rmswindow_s, _srate)
(
  this.rmscoef = pow(10,-1.0/(_rmswindow_s * _srate));
  this.vu_factor = $PI/4;
  this.Amp2DBFS = 6.0/log(2.0);
  this.VUMeter_Reset();
);

function VUMeter_Process(_in0, _in1)
(
  this.maxspl = (abs(_in0) + abs(_in1));
  this.runave = this.maxspl + this.rmscoef * (this.runave - this.maxspl);
  this.runmax = max(this.runmax, this.runave);
);

function VUMeter_Get()
(
  this.runave*this.vu_factor;
);

function VUMeter_Get_dB()
(
  log(this.VUMeter_Get())*this.Amp2DBFS;
);

function VUMeter_GetMax()
(
  this.runmax*this.vu_factor;
);

function VUMeter_GetMax_dB()
(
  log(this.VUMeter_GetMax())*this.Amp2DBFS;
);

function SL_Reset()
(
  this.last_val = 0.0;
  this.binit = 0;
);

function SL_Init(_nr)
(
  this.nr = _nr;
  this.sl_reset();
);

function SL_Process(_val)
local(bupdate)
(
  
  (this.binit == 0) ?
  (
    this.binit = 1;
    this.last_val = _val;
  );
  
  (this.last_val != _val) ? 
  (
    slider(this.nr) = _val;
    slider_automate(slider(this.nr));
    this.bupdate = 1;
  ):
  (
    this.bupdate = 0;
  );
  
  this.last_val = _val;
);

  //Init
  
  SL1.SL_Init(1);
  SL2.SL_Init(2);
  SL3.SL_Init(3);

  SL4.SL_Init(4);
  SL5.SL_Init(5);
  SL6.SL_Init(6); 
    
@slider
  VUMeterS.VUMeter_Init(slider10/1000.0, srate);
  VUMeterL.VUMeter_Init(slider10/1000.0, srate);
  VUMeterR.VUMeter_Init(slider10/1000.0, srate);
  
  RMSL.RMSQ_Init(slider10/1000.0, srate);
  RMSR.RMSQ_Init(slider10/1000.0, srate);
  RMSS.RMSQ_Init(slider10/1000.0, srate);
@block
 
  SL1.SL_Process(dround(VUMeterL.VUMeter_Get_dB()+18,1));
  SL2.SL_Process(dround(VUMeterR.VUMeter_Get_dB()+18,1));
  SL3.SL_Process(dround(VUMeterS.VUMeter_Get_dB()+18,1));

  SL4.SL_Process(dround(RMSL.RMSQ_Get_dB(),1));
  SL5.SL_Process(dround(RMSR.RMSQ_Get_dB(),1));
  SL6.SL_Process(dround(RMSS.RMSQ_Get_dB(),1));    
    
@sample

  VUMeterL.VUMeter_Process(spl0,spl0);
  VUMeterR.VUMeter_Process(spl1,spl1);
  VUMeterS.VUMeter_Process(spl0,spl1);
  
  RMSL.RMSQ_Process(spl0,0);
  RMSR.RMSQ_Process(spl1,0);
  RMSS.RMSQ_Process(spl0,spl1);
And here is the matching VUMeter image file: VUMeterImgStrip.zip

Please let me know, if it helps.
Please to note that the JSFX script takes 2-3 sec to get vu/rms values stable to lowest possible if no audio...
__________________
www.tbproaudio.de

Last edited by TBProAudio; 10-30-2016 at 09:30 AM.
TBProAudio is offline   Reply With Quote