Go Back   Cockos Incorporated Forums > REAPER Forums > Recording Technologies and Techniques

Reply
 
Thread Tools Display Modes
Old 01-13-2020, 05:34 PM   #41
ErBird
Human being with feelings
 
Join Date: Jan 2017
Location: Los Angeles
Posts: 1,161
Default

Quote:
Originally Posted by Zeno View Post
Yes, this is a scaling problem.
Unfortunately, I have not yet found any useful documentation on the topic of embedded ui and scaling to be able to tackle this specifically.
I've found that the numbers after @gfx are used as the aspect ratio of the embedded UI. The absolute dimensions depend on the width of the extmixer which, of course, can vary by theme. On my theme, I use a sidebar with 90 px width. Within this, because of padding I guess, I get 84 px for the embedded UI.

I'd really like to see the ability to have different behavior or even a totally different gui depending on embed state.
ErBird is offline   Reply With Quote
Old 01-13-2020, 06:31 PM   #42
Zeno
Human being with feelings
 
Zeno's Avatar
 
Join Date: Sep 2018
Location: HH
Posts: 915
Default

Quote:
Originally Posted by ErBird View Post
I've found that the numbers after @gfx are used as the aspect ratio of the embedded UI.
True, but it also defines the scaling height and width in the fx window itself.
This is not the problem, but the arrangement of the meter layout within the given vectors.
Zeno is offline   Reply With Quote
Old 01-13-2020, 10:03 PM   #43
CrashAlpha
Human being with feelings
 
CrashAlpha's Avatar
 
Join Date: May 2010
Posts: 95
Default

Ok, I think I figured it out. In fact, the issue is that some features just don't scale like text, anti-aliasing, arc and line drawing - so don't embed in TCP and MCP nicely. I disabled line and arc, needle shadows & thickening, text display, notches, etc and show a very simplified UI for the smaller scale using the override gfx method technique used earlier as well as some inline if statements for specific cases.

Does this work for you?
Code:
//********************************************************************
// Gain Stager based on Simple VU Meter - a fine freeware by chris-s
// V1.1; 10-Jan-2017
// Disclaimer: Use of this software is on your own risk

// Modified by Zeno
// V1.3; 13-Jan-2020
   - graphic appearance: color scheme adapted, more modern look
   - added volume slider for gain adjustments
   - added hidden sliders for peak LEDs left/mid and right/side
   - added hidden sliders for vu meter readout left/mid and right/side

   Hidden sliders can be used as triggers for scripts and modulation envelopes !!
// Modified by CrashAlpha
// V1.4; 13-Jan-2020
   - added scaling features that allowed simplified VUs to appear 
   in track control panels

   Hidden sliders can be used as triggers for scripts and modulation envelopes !!

//*************************************** END INFO ****************/


desc:Gain Stager
//tags: analysis analyze vu meter gain staging
//author: chris-s, Zeno, CrashAlpha

// hidden sliders: remove the "-" in front of the name to activate

slider1:-18<-20,0,0.5>Zero callibration dB
slider2:-6<-20,0,0.1>Warning dB
slider3:50<0,100,1}>-Response  // Hidden
slider4:0<0,2,1{Stereo,Mono,Mid/Side}>Mode
slider5:0.0053<0,.01,0.0001>-Damping  // Hidden
slider6:0<-12,12,0.1>Gain (dB)

slider50: -20<-20,3>-VU Left/Mid  // Hidden     
slider51: -20<-20,0,3>-VU Right/Side  // Hidden
slider52: 0<0,1>-Peak LED L  // Hidden
slider53: 0<0,1>-Peak LED R  // Hidden

  
// Hide side meters
in_pin:left input
in_pin:right input
out_pin:left output
out_pin:right output

options:no_meter
 
/***************************************** END DESC *****************/


@init

//========================================= VOLUME ==================/
AMP_dB_i=1/8.68588963806504;

db=slider6; // initialize here but not in @slider for playback start


//======================================== VU METER =================/
errcnt = 0;
tot_nbr_spl = 0;
scnt = 0;

fact_up = 0;

offset = 0.0074;

nd_posL = nd_posR = 0;
nd_speedL = nd_speedR = 0;

dt = 10 / srate;

mom = 0.00042;
damp = 1 - 0.0053 * (48000 / srate);

dbL = dbR = 0;
overL = overR = 0;

print = 10;
print[0] = -20;
print[1] = -10;
print[2] = -7;
print[3] = -5;
print[4] = -3;
print[5] = -2;
print[6] = -1;
print[7] = 0;
print[8] = 1;
print[9] = 2;
print[10] = 3;

pos = 30;
pos[0] = 0;
pos[1] = .1650;
pos[2] = .2641;
pos[3] = .3519;
pos[4] = .4626;
pos[5] = .5284;
pos[6] = .6022;
pos[7]  = .6849;
pos[8]  = .7779;
pos[9] = .8822;
pos[10] = 1;

/**************************************** END @INIT *****************/


@slider

//======================================== VOLUME ===================/
ddb=0.0;


//======================================== VU METER =================/
fact_up = 10 ^ (( -slider1 - 10)/20) * 0.3785 ;

wl   = slider2;
mode = slider4;
lim = 10 ^ (wl / 20);

mom = 0.00010 + 0.00032 *  slider3^3 / 125000;   

damp = 1 - slider5 * (48000 / srate);

/**************************************** END @SLIDER ***************/


@block

//========================================= VOLUME ==================/
cnt=0;
ddb=0.0;

db_chg_splpos=slider_next_chg(1, tgtdb);
db_chg_splpos > 0 ? (
	db=slider6;
) : (
	tgtdb = slider6;
	db_chg_splpos = samplesblock;
);

ddb=(tgtdb-db)/db_chg_splpos;

/**************************************** END @BLOCK ****************/


@sample

//========================================= VOLUME ==================/
cnt == db_chg_splpos ? (
	ddb=0.0;
	db_chg_splpos=slider_next_chg(1, tgtdb);
	db_chg_splpos > cnt ? (
		ddb=(tgtdb-db)/(db_chg_splpos-cnt);
	);
);

adj=exp(db*AMP_DB_i);

spl0 *= adj;
spl1 *= adj;

db += ddb;
cnt += 1;


//======================================== VU METER =================/
tot_nbr_spl += 1;

smpL = spl0; 
smpR = spl1;

mode == 1 ? ( 
	smpL = (spl0 + spl1) * 0.5;
	smpR = smpL;  
);

mode >= 2 ? ( 
	smpL = (spl0 + spl1) * 0.5;
	smpR = (spl0 - spl1) * 0.5;  
);

smpL = abs(smpL);
smpR = abs(smpR);

scnt += 1;

scnt === 10 ? (
	// move left needle
	force = smpL * fact_up  -  (nd_posL * .1 + offset);

	nd_speedL += force * dt / mom;  
	nd_speedL = nd_speedL * damp;
	nd_posL += nd_speedL * dt;
	nd_posL < 0 || nd_posL > 1 ? nd_speedL = 0;

	nd_posL = min(max(nd_posL,0),1);

	// move right needle
	force = smpR * fact_up  - (nd_posR * .1 + offset);

	nd_speedR += force * dt / mom;  
	nd_speedR = nd_speedR * damp;
	nd_posR += nd_speedR * dt;
	nd_posR < 0 || nd_posR > 1 ? nd_speedR = 0;

	nd_posR = min(max(nd_posR,0),1);

	overL -= 10;
	overR -= 10;

	scnt = 0;  
);

tot_nbr_spl_g  = tot_nbr_spl;

overL_g = overL;
overR_g = overR;
nd_posL_g = nd_posL;
nd_posR_g = nd_posR;

tot_nbr_spl_g === tot_nbr_spl ? (
	dbL = (nd_posL_g * 23) - 20;
	dbR = (nd_posR_g * 23) - 20; 
) : (
  errcnt += 1; // thread collision
);

smpL > lim ? overL = srate;
smpR > lim ? overR = srate;

slider50 = dbL;   //LBX ZenoMOD
slider51 = dbR;   //LBX ZenoMOD
slider52 = overL_g;
slider53 = overR_g;

/**************************************** END @SAMPLE ***************/


@gfx 480 200

// override drawing functions for graphical window scaling
gsc = min(gfx_w/480,gfx_h/200); igsc = 1.0/gsc;
gxo = max(0,  gfx_w/2 - gfx_h*480/200/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) (gsc>.5 ? gfx_drawchar(x););
function gfx_drawstr(x) (gsc>.5 ? gfx_drawstr(x););
function gfx_printf(x,y) ( gsc>.5 ? gfx_printf(x,y) );
function gfx_arc(x, y, r, a1, a2, aa) (gsc>.5 ? gfx_arc(x, y, r, a1, a2, aa) : gfx_arc(x, y, r, a1, a2, 0); );

// paint gfx 
fontinit != 1 ? (
  gfx_setfont(1, "Arial", 14, '');
  gfx_setfont(2, "Arial", 20, 'b');

  fontinit = 1;
);

gfx_a = 1;

w1 = $pi * 16.5 / 180; 
w2 = $pi * 45 / 180;

xw = max(1,floor((gfx_w-30) / 2));
yw = floor(xw / 1.5);

r1 = floor(yw * 0.85);

chan = 0;
while (chan <= 1) (
	xd = 10 + chan*(xw+10);
	mode === 1 ? xd += floor(xw/2);

	yd = 10;

	xa = floor(xd + xw / 2);
	ya = floor(yd + yw * 1.1);

	// meter backgr
	gfx_r=0;gfx_g=1;gfx_b=.9;  
	gfx_rect(xd,yd,xw,yw);

	// scale   
	gfx_r=gfx_g=gfx_b = 0; // black 
	gfx_arc(xa, ya, r1, -45 * ($pi / 180), w2, 1);

	gfx_r=.95; gfx_g=0; gfx_b = 0; // red 
	gfx_arc(xa, ya, r1 + 1, w1, w2, 1);

	// thicken red scale if scaling allows
	gsc >.5 ? (
		gfx_arc(xa, ya, r1 + 2, w1, w2, 1);  
		gfx_arc(xa, ya, r1 + 3, w1, w2, 1);  
		gfx_arc(xa, ya, r1 + 4, w1, w2, 1);    
	);

	gfx_setfont(1);

	gfx_r=gfx_g=gfx_b = 0.2; // black 

	// Draw scale notches and values if scaling allows
	gsc >.5 ? (

		jj = 0;
		while ( jj <= 10 ) (
			ii = print[jj];

			ph =  pos[jj];
			ph = (45 + ph*90) * $pi / 180; 

			cosp = cos(ph) * r1;
			sinp = sin(ph) * r1;

			x1 = xa - cosp ;
			y1 = ya - sinp ;

			x2 = xa - cosp * 1.1;
			y2 = ya - sinp * 1.1;

			x3 = xa - cosp * 1.12;
			y3 = ya - sinp * 1.12;

			gfx_x = x1;
			gfx_y = y1 ; 

			gfx_lineto(x2, y2);
			gfx_x = x3 - 7;   
			gfx_y = y3 - gfx_texth;

			gfx_printf("%3d", ii);              

			jj += 1;

			jj == 8 ? ( gfx_r = 1; gfx_g = gfx_b = 0 );  
		); 
	);

	// Peak
	gfx_r=gfx_g=gfx_b = 0.0; // black 

	gfx_x = xd + xw * .9 - 30;
	gfx_y = yd + yw * .9 - 10;
	gfx_drawstr("PEAK");

	// VU
	gfx_setfont(2); // large
	gfx_r=gfx_g=gfx_b = 0.0; // black 

	gfx_x = xa - 10;
	gfx_y = yd + yw * .6;
	gfx_drawstr("VU");


	// draw LEDs
	gfx_r = .95; gfx_g = gfx_b = 0.1; // red 

	(chan == 0 && overL_g > 0) || (chan == 1 && overR_g > 0)  ? (   
		gfx_circle(xd + xw*0.9 + 6, yd + yw * 0.9 - 4, 4, 1, 1);
	);


	// draw needle
	chan == 0 ? ph = dbL : ph = dbR;

	ph = 45 + (ph+20)/23*90; 
	ph = ph * ($pi / 180);

	cosp = cos(ph);
	sinp = sin(ph);

	x1 = xa - cosp * r1 * 0.15;
	y1 = ya - sinp * r1 * 0.15;

	x2 = xa - cosp * r1 * 1.1;
	y2 = ya - sinp * r1 * 1.1;

	gfx_r=gfx_g=gfx_b = 0; // black                   

	gfx_x = x1;
	gfx_y = y1; 
	gfx_lineto(x2, y2);


	// draw thick needle lines and shadows if scaling allows
	gsc >.5 ? (
		gfx_x = x1+1;
		gfx_y = y1;
		gfx_lineto(x2+1, y2);
		gfx_x = x1+4;
		gfx_y = y1; 
		gfx_lineto(x2+4, y2);
	);

	gfx_r=gfx_g=gfx_b = 1; // white 

	gfx_x = xd;
	gfx_y = yd+yw+2;

	chan == 0 ?
	gfx_drawstr("LEFT / MID") :
	gfx_drawstr("RIGHT / SIDE") ;

	chan += 1;

	mode === 1 ? chan += 1;
);
  
  
/******************************************** EOF *******************/

Last edited by CrashAlpha; 01-13-2020 at 10:51 PM. Reason: correct minor logic error rendering scale notches and numbers
CrashAlpha is offline   Reply With Quote
Old 01-14-2020, 08:14 AM   #44
Zeno
Human being with feelings
 
Zeno's Avatar
 
Join Date: Sep 2018
Location: HH
Posts: 915
Default

Quote:
Originally Posted by CrashAlpha View Post
Does this work for you?
Thank you, that's better. Maybe you could take a look at the thread I opened?
I've listed a few things there that aren't right yet: VU Meter Embedded UI: Need some help!
Zeno is offline   Reply With Quote
Old 04-23-2020, 02:36 AM   #45
aurelien
Human being with feelings
 
Join Date: Apr 2014
Posts: 95
Default

Nice ! That exactly what we need for easy gain staging between plugins.

I tried different things and script and i ended up doing the following to get a behavior as close as mvmeter2 in "VU summed mode" + nice MCP integration :
->I used the script "LT VU Meter Deluxe" set up to -21dbfs, i don't know why but i had to set it up to -21 instead of -18, maybe because of stereo summing ?

I also tried the gainstager plugin, it works great, but yeah integration is not working in MCP, maybe we could use the classic js vumeter gui?

Thanks!
aurelien is offline   Reply With Quote
Old 09-06-2020, 05:48 PM   #46
ANDYZ
Human being with feelings
 
ANDYZ's Avatar
 
Join Date: Aug 2018
Posts: 113
Default

2++ pages of read, still have no idea what to do if I want to have an MCP embedded CORRECT VU meter with calibration option.

Sorry for being dumb, could someone guide me step by step?

When I open Fx - Js and type "VU" I have 3 options:

JS VU Meter
JS VU Meter (Summed)
JS WigWare Multi-channel Peak Limiter.

I choose JS VU Meter (Summed) and embed it in the Master section. I like the black look of it. But it is not calibrated. I want to set it to -18 and I want to be sure it reads correctly.

What should I do next?


Many thanks in advance.
ANDYZ is offline   Reply With Quote
Old 09-07-2020, 10:30 AM   #47
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,264
Default

Did you try mine? Not trying to toot a horn or anything, but I never use these things, and only did it to try to help y’all.

https://forum.cockos.com/showpost.ph...49&postcount=9
ashcat_lt is offline   Reply With Quote
Old 09-07-2020, 03:58 PM   #48
dagamusik
Human being with feelings
 
dagamusik's Avatar
 
Join Date: Aug 2020
Location: Colombia
Posts: 165
Default

Quote:
Originally Posted by ashcat_lt View Post
Did you try mine? Not trying to toot a horn or anything, but I never use these things, and only did it to try to help y’all.

https://forum.cockos.com/showpost.ph...49&postcount=9
I was trying to compare it with mvMeter2 and -18 is not matching.


I like the "show the MCP" UI as well in TCP it helps a lot when tracking a recording.

Do you know how to callibrate it to match with mvMeter2?
dagamusik is offline   Reply With Quote
Old 09-07-2020, 06:39 PM   #49
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,264
Default

Quote:
Originally Posted by dagamusik View Post
Do you know how to callibrate it to match with mvMeter2?
How far off is it? Some meters are sort of off by about 3db because of the sine vs square wave thing. Really kind of just move the calibrate slider til they match, I guess.
ashcat_lt is offline   Reply With Quote
Old 09-07-2020, 08:30 PM   #50
dagamusik
Human being with feelings
 
dagamusik's Avatar
 
Join Date: Aug 2020
Location: Colombia
Posts: 165
Default

Quote:
Originally Posted by ashcat_lt View Post
How far off is it? Some meters are sort of off by about 3db because of the sine vs square wave thing. Really kind of just move the calibrate slider til they match, I guess.
Yes it's about 3dB of dismatch, would be a way to trick the number in the calibration for example show -18 when it is truly -21 or so?

Or that doesn't work in a linear way?
dagamusik is offline   Reply With Quote
Old 09-07-2020, 08:38 PM   #51
ANDYZ
Human being with feelings
 
ANDYZ's Avatar
 
Join Date: Aug 2018
Posts: 113
Default

Quote:
Originally Posted by ashcat_lt View Post
How far off is it? Some meters are sort of off by about 3db because of the sine vs square wave thing. Really kind of just move the calibrate slider til they match, I guess.
Yes, I managed to find the source file and replace the code with yours and saved.

The meter works (pic) but shows different values than Klanghelm VU.

Yours is at the beginning (1) (disregard 10\10) of the Master chain, Klanghelm is second (2) and third (3) (to show -18 tag).

I tried to match the settings, not sure if correct. RMS, Average give around 5Db difference (pic), Slew maybe 7 Db or more.

I will try to move the calibration slider to match the Klanghelm VU reading, thanks!


ANDYZ is offline   Reply With Quote
Old 09-07-2020, 08:49 PM   #52
ANDYZ
Human being with feelings
 
ANDYZ's Avatar
 
Join Date: Aug 2018
Posts: 113
Default

I think its 4Db of difference, sine wave 440 Hz fed signal.

If I set the calibration slider to -22 for detector Average it brings the needle to 0 but it doesnt behave similarly to Klanghelm with the music.

Set to detector RMS and -21 it seems to behave very similar to Klanghelm.


Last edited by ANDYZ; 09-07-2020 at 08:57 PM.
ANDYZ is offline   Reply With Quote
Old 09-08-2020, 09:17 AM   #53
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,264
Default

Yeah that’s the sine vs square thing, like I thought. The true RMS value of a sine wave is about 3db less than its peak value, while the RMS of a square wave is exactly the same as its peak. Some (many?) meters compensate for that, but frankly I think that’s kind of weird. Glad you sorted it out. You could change the code if you want, or just remember that this one is based off true RMS.
ashcat_lt is offline   Reply With Quote
Old 08-30-2021, 06:00 AM   #54
aurelien
Human being with feelings
 
Join Date: Apr 2014
Posts: 95
Default

Currently using these VU meter in the MCP and they work really great for gain staging.
I'm wondering if that would be possible to add a gain control in the UI of the MCP ?

That would be very handy.

Thanks!
aurelien is offline   Reply With Quote
Old 09-04-2021, 05:16 AM   #55
bigjoe
Human being with feelings
 
bigjoe's Avatar
 
Join Date: Jun 2015
Posts: 321
Default

Quote:
Originally Posted by ashcat_lt View Post
Yeah that’s the sine vs square thing, like I thought. The true RMS value of a sine wave is about 3db less than its peak value, while the RMS of a square wave is exactly the same as its peak. Some (many?) meters compensate for that, but frankly I think that’s kind of weird.
Actually most meters use square wave alignment because AES17 standard is now the norm.
Almost all of the RMS meters around defaults to AES17 standard
bigjoe is online now   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 11:46 PM.


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