Old 09-23-2016, 01:10 PM   #1
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default Clip indicator

I want a clip indicator for master channel embeded to my toolbar. Who can write a script for that please?
ertugrulgul is offline   Reply With Quote
Old 09-24-2016, 12:16 AM   #2
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,141
Default

Quote:
Originally Posted by ertugrulgul View Post
I want a clip indicator for master channel embeded to my toolbar. Who can write a script for that please?
What do you mean by "Clip" ?

Reaper does not clip as it uses floating point sample format. The clipping will only be introduced when Reaper sends data (usually in 24 bit fixed point format) to the (usually ASIO) driver or when saving such format to a file.

I don't suppose a script can detect this.

-Michael
__________________
www.boa-sorte.de
mschnell is online now   Reply With Quote
Old 09-24-2016, 01:05 AM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,217
Default

I made Script: Detect Tracks Clips - Peak Over 0db.
Maybe it can help !
X-Raym is offline   Reply With Quote
Old 09-24-2016, 04:17 AM   #4
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

Quote:
Originally Posted by mschnell View Post
I don't suppose a script can detect this.

-Michael
I assume he means when master goes over 0 db.
That's possible to detect in a script as X-Raym's shows (using GetPeakHoldDB()).
Light a toolbar button when this happens is also possible.

I wouldn't have time to do this script currently though, maybe at some later point if noone jumps in till then.
Or maybe OP is fine with X-Raym's version.

Last edited by nofish; 09-24-2016 at 04:24 AM.
nofish is offline   Reply With Quote
Old 09-24-2016, 05:39 AM   #5
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,141
Default

Quote:
Originally Posted by nofish View Post
I assume he means when master goes over 0 db.
That's possible to detect in a script as X-Raym's shows (using GetPeakHoldDB()).
Light a toolbar button when this happens is also possible.
Hm I understand that the standard meter already does this nicely.

Of course you could do a JSFX that creates a midi event when the audio is > 0dB, then route the Midi out of the PC and have some Hardware light up huge red lamp

-Michael
__________________
www.boa-sorte.de

Last edited by mschnell; 09-24-2016 at 06:52 AM.
mschnell is online now   Reply With Quote
Old 09-25-2016, 06:56 AM   #6
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

Nofish mentioned exactly what I want. If anybody can do this I'll be grateful.
ertugrulgul is offline   Reply With Quote
Old 09-25-2016, 12:17 PM   #7
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

I could offer this, but I wouldn't know how to make it a 'sticky' indicator (= at first clip it lights, click on it to turn off again).

Are you ok with this version, if not no problem, hope for someone else to jump in (or try to learn scripting yourself).

nofish is offline   Reply With Quote
Old 09-25-2016, 01:33 PM   #8
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

Quote:
Originally Posted by nofish View Post
I could offer this, but I wouldn't know how to make it a 'sticky' indicator (= at first clip it lights, click on it to turn off again).

Are you ok with this version, if not no problem, hope for someone else to jump in (or try to learn scripting yourself).

Unfortunately I don't understand anything about scripting. But if this had a sticky red light which turns off when clicking on it, would be excatly what I asked for.
ertugrulgul is offline   Reply With Quote
Old 09-25-2016, 02:36 PM   #9
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

Quote:
Originally Posted by ertugrulgul View Post
But if this had a sticky red light which turns off when clicking on it, would be excatly what I asked for.
Agreed, this would be better.
So we'll have to wait if someone turns up knowing if this is possible (and how).

I can post what I have currently (rather simple, in Eel):

Code:
lstate = -1;

function run(finishup)
( 
  masterTrack = GetMasterTrack(0);
  peakInfo_L = Track_GetPeakInfo(masterTrack, 0);
  peakInfo_R = Track_GetPeakInfo(masterTrack, 1);
  peakInfo_L > 1 || peakInfo_R > 1 ? (clipped = 1;) : (clipped = 0);    
   
  // toolbar toggle state example by Jeffos
  get_action_context(#fn,sec,cmd);
  state=finishup ? -1 : (clipped);
  state != lstate ? 
  ( 
    SetToggleCommandState(sec, cmd, state);  
    RefreshToolbar2(sec, cmd);  
    lstate=state;
  );
  !finishup ? defer("run(0);"); 
);

defer("run(0);");
atexit("run(1);");
nofish is offline   Reply With Quote
Old 09-29-2016, 06:02 AM   #10
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

Please help guys
ertugrulgul is offline   Reply With Quote
Old 09-29-2016, 08:51 AM   #11
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 271
Default

On the basis of nofish code, you can make a simple indicator.


Code:
function Indicator()
  local(masterTrack, peakInfo_L, peakInfo_R, lbl_w, lbl_h)
( 
  masterTrack = GetMasterTrack(0);
  peakInfo_L = Track_GetPeakInfo(masterTrack, 0);
  peakInfo_R = Track_GetPeakInfo(masterTrack, 1);
  peakInfo_L > 1 ? clip_L = 1;
  peakInfo_R > 1 ? clip_R = 1;   
  
  gfx_set(clip_L, 0, 0, 1);
  gfx_rect(0,0, gfx_w/2, gfx_h, 1);
  
  gfx_set(clip_R, 0, 0, 1);
  gfx_rect(gfx_w/2, 0, gfx_w/2, gfx_h, 1);
  
  gfx_set(1,1,1,1);
  gfx_line(gfx_w/2,0,gfx_w/2,gfx_h);
  
  gfx_measurestr("L", lbl_w, lbl_h);
  gfx_x = (gfx_w/2-lbl_w)/2; 
  gfx_y = (gfx_h-lbl_h)/2;
  gfx_drawstr("L");

  gfx_set(1,1,1,1);
  gfx_measurestr("R", lbl_w, lbl_h);
  gfx_x = gfx_w/2+(gfx_w/2-lbl_w)/2; 
  gfx_y = (gfx_h-lbl_h)/2;
  gfx_drawstr("R");

);


//-- mainloop ------------------
function mainloop()
( 
  play_state = GetPlayState();
  (mouse_cap&1==1 && last_mouse_cap&1==0) || 
  (play_state&1==1 && last_play_state&1==0)  ? 
  clip_L=clip_R=0;
  
  Indicator(); 
  //------------------------
  last_mouse_cap = mouse_cap;
  last_play_state = play_state; 
  char = gfx_getchar();
  char==32 ? Main_OnCommand(40044, 0); //-- play
  char >= 0 ? defer("mainloop();");    //-- defer
  gfx_update();
);

//-- init ----------------------
function Init()
(
  gfx_init("Clip Indicator",300,130,0,500,500);
  gfx_clear = 0;
  gfx_set(0,0,0,1);
  gfx_setfont(1, "Arial", 100);
  last_mouse_cap = 0;
);


Init();
mainloop();
__________________
ReaScripts

Last edited by eugen2777; 09-29-2016 at 09:32 AM.
eugen2777 is offline   Reply With Quote
Old 09-29-2016, 10:31 AM   #12
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

Quote:
Originally Posted by eugen2777 View Post
On the basis of nofish code, you can make a simple indicator.


Code:
function Indicator()
  local(masterTrack, peakInfo_L, peakInfo_R, lbl_w, lbl_h)
( 
  masterTrack = GetMasterTrack(0);
  peakInfo_L = Track_GetPeakInfo(masterTrack, 0);
  peakInfo_R = Track_GetPeakInfo(masterTrack, 1);
  peakInfo_L > 1 ? clip_L = 1;
  peakInfo_R > 1 ? clip_R = 1;   
  
  gfx_set(clip_L, 0, 0, 1);
  gfx_rect(0,0, gfx_w/2, gfx_h, 1);
  
  gfx_set(clip_R, 0, 0, 1);
  gfx_rect(gfx_w/2, 0, gfx_w/2, gfx_h, 1);
  
  gfx_set(1,1,1,1);
  gfx_line(gfx_w/2,0,gfx_w/2,gfx_h);
  
  gfx_measurestr("L", lbl_w, lbl_h);
  gfx_x = (gfx_w/2-lbl_w)/2; 
  gfx_y = (gfx_h-lbl_h)/2;
  gfx_drawstr("L");

  gfx_set(1,1,1,1);
  gfx_measurestr("R", lbl_w, lbl_h);
  gfx_x = gfx_w/2+(gfx_w/2-lbl_w)/2; 
  gfx_y = (gfx_h-lbl_h)/2;
  gfx_drawstr("R");

);


//-- mainloop ------------------
function mainloop()
( 
  play_state = GetPlayState();
  (mouse_cap&1==1 && last_mouse_cap&1==0) || 
  (play_state&1==1 && last_play_state&1==0)  ? 
  clip_L=clip_R=0;
  
  Indicator(); 
  //------------------------
  last_mouse_cap = mouse_cap;
  last_play_state = play_state; 
  char = gfx_getchar();
  char==32 ? Main_OnCommand(40044, 0); //-- play
  char >= 0 ? defer("mainloop();");    //-- defer
  gfx_update();
);

//-- init ----------------------
function Init()
(
  gfx_init("Clip Indicator",300,130,0,500,500);
  gfx_clear = 0;
  gfx_set(0,0,0,1);
  gfx_setfont(1, "Arial", 100);
  last_mouse_cap = 0;
);


Init();
mainloop();
Thank you. But is there a way to delete the L and R letters I want to see sum of both. And I want to embed it to the toolbar. I added to toolbar but it shows the indicator when clicking on it. How can I do that?
ertugrulgul is offline   Reply With Quote
Old 10-08-2016, 08:46 AM   #13
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

bump!
ertugrulgul is offline   Reply With Quote
Old 10-08-2016, 12:32 PM   #14
ericzang
Human being with feelings
 
ericzang's Avatar
 
Join Date: Mar 2014
Location: Phoenix, AZ
Posts: 345
Default

Merhaba ertugrulgul, this is a little closer to what you are asking.

I don't know how to put it in the toolbar. Docking is similar.

Thank you eugen and nofish!
Attached Images
File Type: jpg clip.JPG (47.7 KB, 81 views)
Attached Files
File Type: zip Clip Indicator Master Sum.zip (724 Bytes, 37 views)

Last edited by ericzang; 10-08-2016 at 01:32 PM.
ericzang is offline   Reply With Quote
Old 11-03-2016, 01:21 PM   #15
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

Quote:
Originally Posted by ericzang View Post
Merhaba ertugrulgul, this is a little closer to what you are asking.

I don't know how to put it in the toolbar. Docking is similar.

Thank you eugen and nofish!
Although it's not quite what I wanted, thank you.
ertugrulgul is offline   Reply With Quote
Old 05-24-2017, 04:22 PM   #16
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

Quote:
Originally Posted by nofish View Post
Agreed, this would be better.
So we'll have to wait if someone turns up knowing if this is possible (and how).

I can post what I have currently (rather simple, in Eel):

Code:
lstate = -1;

function run(finishup)
( 
  masterTrack = GetMasterTrack(0);
  peakInfo_L = Track_GetPeakInfo(masterTrack, 0);
  peakInfo_R = Track_GetPeakInfo(masterTrack, 1);
  peakInfo_L > 1 || peakInfo_R > 1 ? (clipped = 1;) : (clipped = 0);    
   
  // toolbar toggle state example by Jeffos
  get_action_context(#fn,sec,cmd);
  state=finishup ? -1 : (clipped);
  state != lstate ? 
  ( 
    SetToggleCommandState(sec, cmd, state);  
    RefreshToolbar2(sec, cmd);  
    lstate=state;
  );
  !finishup ? defer("run(0);"); 
);

defer("run(0);");
atexit("run(1);");
can you or someone make this start the script automatically when reaper starts?
ertugrulgul is offline   Reply With Quote
Old 05-24-2017, 04:47 PM   #17
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

Quote:
Originally Posted by ertugrulgul View Post
can you or someone make this start the script automatically when reaper starts?
If you haven't already, install SWS extensions.

http://www.sws-extension.org/

Then in Action List search for "SWS/S&M: Set global startup action" and assign this script to it.
nofish is offline   Reply With Quote
Old 05-24-2017, 05:49 PM   #18
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

Quote:
Originally Posted by nofish View Post
If you haven't already, install SWS extensions.

http://www.sws-extension.org/

Then in Action List search for "SWS/S&M: Set global startup action" and assign this script to it.
Thank you man! I wish someone turn this into a sticky one, it would be excatly what I want.
ertugrulgul is offline   Reply With Quote
Old 05-24-2017, 07:57 PM   #19
junh1024
Human being with feelings
 
Join Date: Feb 2014
Posts: 110
Default

http://www.stillwellaudio.com/plugins/bitter/ Does this fit the bill?
junh1024 is offline   Reply With Quote
Old 05-25-2017, 06:11 AM   #20
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

Quote:
Originally Posted by junh1024 View Post
no
ertugrulgul is offline   Reply With Quote
Old 05-25-2017, 06:00 PM   #21
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

Quote:
Originally Posted by nofish View Post

Code:
lstate = -1;

function run(finishup)
( 
  masterTrack = GetMasterTrack(0);
  peakInfo_L = Track_GetPeakInfo(masterTrack, 0);
  peakInfo_R = Track_GetPeakInfo(masterTrack, 1);
  peakInfo_L > 1 || peakInfo_R > 1 ? (clipped = 1;) : (clipped = 0);    
   
  // toolbar toggle state example by Jeffos
  get_action_context(#fn,sec,cmd);
  state=finishup ? -1 : (clipped);
  state != lstate ? 
  ( 
    SetToggleCommandState(sec, cmd, state);  
    RefreshToolbar2(sec, cmd);  
    lstate=state;
  );
  !finishup ? defer("run(0);"); 
);

defer("run(0);");
atexit("run(1);");
Who can turn this into a sticky toolbar button?
ertugrulgul is offline   Reply With Quote
Old 05-29-2017, 03:00 PM   #22
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

Anyone?
ertugrulgul is offline   Reply With Quote
Old 05-29-2017, 09:59 PM   #23
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,141
Default

I don't suppose a JSFX can access the Toolbar (of Reaper or that provided by the OS).

You would need a VST that does an appropriate Reaper or OS API call.

-Michael
__________________
www.boa-sorte.de
mschnell is online now   Reply With Quote
Old 05-29-2017, 10:54 PM   #24
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,141
Default

Edit:

A possible way might be like this:
1) have the JSFX send out a Midi signal (e.g. a CC)
2) use MidiToReaControlPath to route it back into the guts of Reaper
3) here have the CC trigger an event that
4) starts a ReaScript that
5) uses a Reaper API to access the ToolBar Button.

I already did stuff like (1) and (2). I am not sure how (3) can be done without using SWS LiveConfigs, and no idea at all about (4) and (5).

-Michael
__________________
www.boa-sorte.de

Last edited by mschnell; 05-30-2017 at 09:26 AM.
mschnell is online now   Reply With Quote
Old 05-30-2017, 04:28 PM   #25
ertugrulgul
Human being with feelings
 
Join Date: Jul 2014
Location: Turkey
Posts: 146
Default

No need for that complicated stuff I think. That code I mentioned above, it's constantly lights on and off when clipping occures. It lights when the meter is above 0 and it turns off when it's below 0. If that was stays on when clipping occures and goes off when clicking on it, it would be what I wanted. Also current version lights on at +0.1 db, it should be at exactly 0.0 db
ertugrulgul is offline   Reply With Quote
Old 05-30-2017, 10:15 PM   #26
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,141
Default

So why did you ask for "Toolbar" twice ?

-Michael
__________________
www.boa-sorte.de
mschnell is online now   Reply With Quote
Old 05-31-2017, 05:09 AM   #27
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

I revisited this and managed to make it sticky.



Thing is, it's far from ideal or even good useable this way in my opinion, because:

When it's lit you must always press twice (1. to unsticky it, 2. to re-start the script). If you'd forget this and only press once the script is stopped but there's no way to see it because the toolbar on / off state (which commonly is used to indicate if a script is running) is 'abused' here as a clip indicator. I couldn't do any better than this though.

Quote:
Also current version lights on at +0.1 db, it should be at exactly 0.0 db
Using a script for clip indication is not very accurate anyway because of the low frequency scripts are running (approx. 30 times / sec. afaik), so it's very far from being sample accurate (it would need a JSFX or VST to make it sample accurate).

So given all the above - I don't know what you want to use it for exactly, but I'd like to suggest a better alternative would be to read up and get into the habbit of proper gain staging which imo (almost) eliminates the need for clip indication.

If you want to use the version above nevertheless just tell me and I can post the code.
nofish 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 03:02 PM.


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