|
|
|
04-12-2015, 01:57 PM
|
#1
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
|
JS FX that tells you where your audio peaks above 0dB...
Here is a nifty (I think so myself, at least ) little JS FX I just wrote to let me know where my audio peaks above a specified threshold, typically 0 dB. I put it on a track of its own, send all buses to that track and record the output of the track. The FX then outputs zeros as long as its input is below the threshold and 1.0 whenever the input is above the threshold.
Once I have that recorded I know exactly where, and I can inspect why, the output goes above the threshold there.
It is not as good as having markers automatically dropped when the master peaks above 0 dB, but close... It is useful for me, might be useful for you.
Code:
/*
Legalities, blah blah blah...
2015 Fabian
*/
// Inserts a 1.0000 sample in the output whenever a sample
// above the threshold is detected, else only zeros
desc:MF/Overflow marker
slider1:0<-10,30,0.1> Threshold (dB)
slider2:0<0,10^6,1> Num overflow (read only)
@init
num = 0; // Total num overflows
@slider
thresh = 2^(slider1/6); // Turn dB into gain
@block
slider3 = num;
@sample
out0 = out1 = 0; // Default output is zero
(abs(spl0) > thresh) ?
(
out0 = 1.0; // Overflow detected!
num += 1;
);
(abs(spl1) > thresh) ?
(
out1 = 1.0; // Overflow detected!
num += 1;
);
spl0 = out0;
spl1 = out1;
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
04-14-2015, 07:21 AM
|
#2
|
Human being with feelings
Join Date: Jun 2012
Posts: 2,173
|
Pretty cool. Thanks.
|
|
|
04-14-2015, 09:41 AM
|
#3
|
Human being with feelings
Join Date: Jan 2014
Posts: 5,205
|
A script may actually be able to drop the markers, might be better than JS approach
|
|
|
04-14-2015, 02:08 PM
|
#4
|
Human being with feelings
Join Date: Mar 2010
Posts: 4,713
|
Here's a quick POC of doing it with a deferred script as Fergler suggests:
Code:
function drop_marker_when_over_threshold()
(
track = GetMasterTrack(0);
peak = Track_GetPeakInfo(track, 0);
peak_dB = 20 * log(peak);
threshold = 0;
pos = GetPlayPosition();
sprintf(#name, "%f", peak_dB);
peak_dB >= threshold ?
(
AddProjectMarker2(0, 0, pos, 0, #name, 0, 0xFF0000|0x1000000);
);
);
function main()
(
GetPlayStateEx(0) == 1 ?
(
drop_marker_when_over_threshold();
);
defer("main();");
);
main();
You might want to play around with the other GetPlayPosition functions, depending on what suits you best. Could be made better if you think it would be useful ...
But it's not going to be as accurate as the JSFX because deferred scripts are not run every sample (or even as often as every block AFAIK).
The best way would be to create a VST plug-in that drops the marker via the extension API, but I don't have the time to do that right now unfortunately ...
Last edited by timlloyd; 04-14-2015 at 02:43 PM.
|
|
|
04-17-2015, 01:30 AM
|
#5
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
|
Yes, dropping markers would of course be much better, but I actually find the JS FX much more useful than I originally thought. And it works rather well.
In the version I am using now I made a small change to get the sign of the peak. Just change the peak detection part to this:
Code:
(abs(spl0) > thresh) ?
(
out0 = spl0; // Overflow detected!
num += 1;
);
(abs(spl1) > thresh) ?
(
out1 = spl1; // Overflow detected!
num += 1;
);
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
04-17-2015, 05:32 PM
|
#6
|
Human being with feelings
Join Date: Dec 2012
Posts: 7,271
|
I thought you wanted exactly 1 when it goes over. The new way will print the actual sample value. If you want the standardized 1, but with an indication of the sign, you could do:
out0 = sign(spl0);
etc...
|
|
|
04-18-2015, 07:33 AM
|
#7
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
|
Quote:
Originally Posted by ashcat_lt
I thought you wanted exactly 1 when it goes over. The new way will print the actual sample value. If you want the standardized 1, but with an indication of the sign, you could do:
out0 = sign(spl0);
etc...
|
Of course. But having the actual value will also tell me how much it peaks over 0 dB. Not that I'm using that info for anything, though...
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
04-18-2015, 09:30 AM
|
#8
|
Human being with feelings
Join Date: Dec 2012
Posts: 7,271
|
Quote:
Originally Posted by Fabian
Of course. But having the actual value will also tell me how much it peaks over 0 dB. Not that I'm using that info for anything, though...
|
At that point isn't it really just a super nasty noise gate?
It also occurs to me that a single sample's blip in a waveform may not even be visible unless you're zoomed in pretty close to begin with
|
|
|
04-18-2015, 09:47 AM
|
#9
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
|
Quote:
Originally Posted by ashcat_lt
At that point isn't it really just a super nasty noise gate?
It also occurs to me that a single sample's blip in a waveform may not even be visible unless you're zoomed in pretty close to begin with
|
Well... its output is not supposed to be listened to, it just shows where the audio fed into it goes above 0 dB. And yes it shows, even a single sample blip. It might not be useful to you, but it is to me.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Last edited by Fabian; 04-18-2015 at 11:54 AM.
|
|
|
04-18-2015, 10:38 AM
|
#10
|
Human being with feelings
Join Date: Dec 2012
Posts: 7,271
|
If it works it works. There's a dude on another forum asking for something similar. IDK what DAW he's using, but I might point him at this.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 09:06 AM.
|