View Single Post
Old 01-05-2020, 06:23 PM   #9
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,264
Default

K.


Try this and LMK:


Code:
desc: LT VU Meter Deluxe (Summed)
//tags: analysis visualization metering
//author: Liteon hacked by ashcat_lt 

slider1:300<0,1000,1>Meter Time(ms)
slider2:0<0,2,1{Left,Sum,Maximum}>Channel 
slider3:-18<-24,-9,0.1>Calibrate (0VU = xdbFS)
slider4:0<-24,24,0.1>Gain (db)
slider5:0<0,2,1{RMS,Average,Slew}>Detector
slider6:0<0,1,1>AutoGain (0=run, 1=grab)

in_pin:left input
in_pin:right input
out_pin:left output
out_pin:right output


@init
//rp - right channel y pading, r - radius
rp = 261;
r = 200;
yl = yr = ylt = yrt = 74;
xl = xr = 66;
ms  = slider1;
cs = 0;


function ratiotodb (x)
( x = 20 * log10 (x););

function dbtoratio (x)
( x = 10 ^(x/20););


function RMS_set(rms_ms)
  instance(coeff, icoeff)
(
  coeff = exp(-1/(rms_ms / 1000 * srate));
  icoeff = 1-coeff;
);


function set_logistic_limit (x)
  instance (limit, scale)
  (this.limit = x;
   this.scale = 1/x;);

function slew_set(rms_ms, calib)
  instance(slew)
(
  this.slew = (1000 * calib) / (srate * rms_ms);
  this.set_logistic_limit (this.slew);
);

function RMS(input)
  instance(rms_s, coeff, icoeff)
(
  rms_s = (rms_s * coeff) + (icoeff * input * input);
  sqrt(rms_s);
);

function average(input)
  instance(ave_s, coeff, icoeff)
(
  ave_s = (ave_s * coeff) + (icoeff * abs(input));
);


function logistic (x)
  instance(limit)
  (log_input = x * this.scale;
   log_curve = 1 / (1 + exp (-2 * log_input));
   log_shifted = 2 * log_curve - 1;
   log_outuput = this.limit * log_shifted;);

function slew(input)
  instance(slew_s, slew)
(
  input = abs(input);
  diff = input - slew_s;
  slew_s += this.logistic (diff);
);



@slider
rms_ms = slider1;
rms0.RMS_set(rms_ms);
calibrate = dbtoratio (slider3);
rms0.slew_set (rms_ms, calibrate);
gain = dbtoratio (slider4);




@block

  rmsl_gfx = ratiotodb(rms_in);
  slider6 == 1 ? 
    (gaindiff = min((slider3 - (rmsl_gfx - slider4)), 24)):
    (last6 == 1 ? slider4 = gaindiff);
  last6 = slider6;
  
  ool = min (6, max (-60, (rmsl_gfx  - slider3)));
  
  //get x from exp scale
  xlt = floor(exp(log(1.055)*2.1*ool)*285);
  
  //get y from x and radius - r     
  l=sqrt(sqr(r)+sqr(212-xlt));
  h=((l-r)*r/l);
  m=sqrt(sqr(l-r)-sqr(h));
  ylt=35+h;
  xlt < 212 ? xlt=xlt+m : xlt=xlt-m;
  
  //update x,y,out
  old_xl < xlt ? (xl = min(max(xlt,66),375); yl = ylt; );
  bscnt = pvl = pvr = 0;
;
//limit x
xl = min(max(xl,66),375);

olt = ratiotodb(peaksample);

@sample
spl0 *= gain;
spl1 *= gain;

slider2 == 0 ?
  (rms_in_0 = spl0;);
slider2 == 1 ?
  (rms_in_0 = (spl0 + spl1)/2) ;
slider2 == 2 ?
  (rms_in_0 = max(spl0, spl1)) ;

slider5 == 0 ? 
  (rms_in = rms0.RMS(rms_in_0));
slider5 == 1 ? 
  (rms_in = rms0.average(rms_in_0));
slider5 == 2 ? 
  (rms_in = rms0.slew(rms_in_0));  


peaksample = max (peaksample, rms_in_0);

@gfx 425 240

// override drawing functions for graphical window scaling
gsc = min(gfx_w/425,gfx_h/240); igsc = 1.0/gsc;
gxo = max(0,  gfx_w/2 - gfx_h*425/240/2);
function gfx_lineto(x,y,aa) ( gfx_x*=gsc; gfx_y*=gsc; gfx_x+=gxo; gfx_lineto(x*gsc+gxo,y*gsc,aa); gfx_x-=gxo; gfx_x*=igsc; gfx_y*=igsc; );
function gfx_rectto(x,y)(gfx_x*=gsc; gfx_y*=gsc; gfx_x+=gxo; gsc>.5 ? gfx_rectto(x*gsc+gxo,y*gsc); gfx_x-=gxo;  gfx_x*=igsc; gfx_y*=igsc;);
function gfx_drawnumber(y,x) (
  gsc>.5 ? (
    gsc<.7 && x>1 ? x=1;
    gfx_x*=gsc; gfx_y*=gsc; gfx_x+=gxo; gfx_drawnumber(y,x); gfx_x-=gxo;  gfx_x*=igsc; gfx_y*=igsc; 
  );
);
function gfx_drawchar(x) ( gfx_x*=gsc; gfx_y*=gsc; gfx_x+=gxo; gsc>.5 ? gfx_drawchar(x); gfx_x-=gxo; gfx_x*=igsc; gfx_y*=igsc; );


//**************************************************************** left
//red scale
gfx_r =  gfx_a = 1;
gfx_g = gfx_b =0;
gfx_x = 283;
gfx_y = 28;
gfx_drawnumber(0,0);
gfx_x = 370;
gfx_y = 55;
gfx_drawnumber(3,0);
gfx_x = 405;
gfx_y = 57;
gfx_drawchar($'+');
gfx_x = 283;
gfx_y = 38;
gfx_lineto(269,76,0.5);
gfx_x = 311;
gfx_y = 43;
gfx_lineto(293,80,1);
gfx_x = 342;
gfx_y = 51;
gfx_lineto(318,85,1);
gfx_x = 370;
gfx_y = 65;
gfx_lineto(344,93,0.5);

//white scale
gfx_r = gfx_g = gfx_b = 1;
gfx_a = 1;
gfx_x = 12;
gfx_y = 60;
gfx_drawchar($'-');
gfx_x = 41;
gfx_y = 53;
gfx_drawnumber(20,0);
gfx_x = 80;
gfx_y = 37;
gfx_drawnumber(10,0);
gfx_x = 125;
gfx_y = 29;
gfx_drawnumber(7,0);
gfx_x = 157;
gfx_y = 25;
gfx_drawnumber(5,0);
gfx_x = 198;
gfx_y = 24;
gfx_drawnumber(3,0);
gfx_x = 56;
gfx_y = 63;
gfx_lineto(82,92,0.5);
gfx_x = 95;
gfx_y = 47;
gfx_lineto(119,82,0.5);
gfx_x = 130;
gfx_y = 39;
gfx_lineto(146,77,0.5);
gfx_x = 145;
gfx_y = 37;
gfx_lineto(158,75,1);
gfx_x = 162;
gfx_y = 35;
gfx_lineto(171,74,0.5);
gfx_x = 180;
gfx_y = 34;
gfx_lineto(187,74,1);
gfx_x = 202;
gfx_y = 34;
gfx_lineto(204,72,0.5);
gfx_x = 227;
gfx_y = 34;
gfx_lineto(223,73,1);
gfx_x = 253;
gfx_y = 35;
gfx_lineto(245,73,1);

//vu box border
gfx_r = gfx_g = gfx_b = 0.75;
gfx_a = 1;
gfx_x = 198;
gfx_y = 108;
gfx_rectto(241,139);
//vu box
gfx_a = 1;
gfx_r = 0.5;
gfx_g = gfx_b = 0.1;
gfx_x = 200;
gfx_y = 110;
gfx_rectto(239,137);
//vu text
gfx_r = gfx_g = gfx_b = 0.85;
gfx_a = 1;
gfx_x = 212;
gfx_y = 120;
gfx_drawchar($'V');
gfx_drawchar($'U');

//meter
olt > 0 ? (
  gfx_r = 1; 
  gfx_g = gfx_b = 0;
) : (
  gfx_r = gfx_g = gfx_b = 1;
);
gfx_a = 1;
gfx_x = 212;
gfx_y = 236;
gfx_lineto(xl,yl,1);
gfx_x = 211;
gfx_y = 236;
gfx_lineto(xl-1,yl,1);
gfx_x = 210;
gfx_y = 236;
gfx_lineto(xl-2,yl,1);

//big border
gfx_r = gfx_g = gfx_b = 0.55;
gfx_a = 1;
gfx_x = 0;
gfx_y = 179;
gfx_rectto(425,180);
//big box 1
gfx_r = 0.1;
gfx_g = 0.2; 
gfx_b = 0.39;
gfx_a = 1;
gfx_x = 0;
gfx_y = 180;
gfx_rectto(425,261);
//big box 2 
gfx_r = gfx_g = gfx_b = 1;
gfx_a = 0.1;
gfx_x = 0;
gfx_y = 180;
gfx_rectto(425,190);
//big box 3
gfx_r = gfx_g = gfx_b = 0;
gfx_a = 0.3;
gfx_x = 0;
gfx_y = 245;
gfx_rectto(425,261);
//ch textbox1
gfx_r = gfx_g = gfx_b = 0;
gfx_a = 1;
gfx_x = 350;
gfx_y = 210;
gfx_rectto(415,227);
//ch textbox2
gfx_r = gfx_g = gfx_b = 0;
gfx_a = 1;
gfx_x = 250;
gfx_y = 210;
gfx_rectto(315,227);
//ch text
gfx_r = gfx_g = gfx_b = 1;
gfx_a = 1;
gfx_x = 20;
gfx_y = 215;
gfx_drawchar($'L');
gfx_drawchar($'+');
gfx_drawchar($'R');
gfx_x = 215;
slider5 == 0 ?
(gfx_drawchar($'R');
 gfx_drawchar($'M');
 gfx_drawchar($'S'););
slider5 == 1 ?
(gfx_drawchar($'A');
 gfx_drawchar($'V');
 gfx_drawchar($'G'););
slider5 == 2 ?
(gfx_drawchar($'S');
 gfx_drawchar($'L');
 gfx_drawchar($'W'););

gfx_x = 333;
gfx_drawchar($'P');
gfx_x = 255;
rmsl_gfx > -300 ? (
  rmsl_gfx > 0.0 ? (
    gfx_r = 1;
    gfx_g = gfx_b = 0;
    gfx_drawchar($'+');
  );
  gfx_drawnumber(rmsl_gfx,2);
) : (
  gfx_drawchar($'-');
  gfx_drawchar($'I');
  gfx_drawchar($'N');
  gfx_drawchar($'F');
);
gfx_r = 1;
gfx_g = gfx_b = 1;
gfx_x = 355;
olt > -300 ? (
  olt >= 0.0 ? (
    gfx_drawchar($'+');
    gfx_r = 1;
    gfx_g = gfx_b = 0;  
  );
  gfx_drawnumber(olt,2);
) : (
  gfx_drawchar($'-');
  gfx_drawchar($'I');
  gfx_drawchar($'N');
  gfx_drawchar($'F');
);
ashcat_lt is offline   Reply With Quote