Can You Determine if HISE's Output Ever Clipped?
-
Is there an efficient way to know if the output has ever clipped? Thank you.
-
@clevername27 With a scriptFX:
// Main interface script global = _peakValue = 0.0; // in a scriptFX processBlock for (c in channels) { for (s in c) { if (Math.abs(s) > _peakValue) _peakValue = s; } }
Then read the global with a timer, reset it with a button if you need...
Note that this is not true peak.Alternatively, this might be more elegant and lighter on CPU:
// oninit reg mag; // processBlock for (c in channels) { mag = c.getMagnitude(0, c.length); if (mag > _peakValue) _peakValue = mag; }
In fact, it can even be reduced to:
for (c in channels) { _peakValue = Math.max(_peakValue, c.getMagnitude(0, c.length)); }
-
@ustk Won't this work with a regular script too like we do for VU meters?
-
@d-healey I reckon we treated the topic a while ago. For what I remember, I was saying that when you read the
VUcurrent level meter, you get the value at this exact moment. There's no memory for what happened in between. For this you need to test all samples (or the buffer's magnitude) and record it for when you are ready to read it. -
@d-healey I have made the tests, current level reading, peak, and true peak, and the results were indisputable (and compared against commercial measuring tools too)
-
@d-healey I have corrected the second solution above that had a mistake...
-
@ustk Thank you @d-healey and @ustk for your suggestions. I had thought Engine.getMasterPeakLevel on a timer would be most efficient—but my concern with all these approaches is that we're only measuring the peak at a given moment—and missing all the possible peaks in between taking measurements. Do your or the Engine function search the current buffer for peaks, or is it simply moment by moment? Than you.
-
@clevername27 That is what I am saying, my solution gives you the real peak (not to be mistaken with true peak) and should be the way to go.
On the contrary and as you said, a mesure of the meter (current level or master peak level) will give you the reading only at one moment which is a no go for telling if the signal ever passed above 0dB. It's good for a level visualisation only. -
C clevername27 marked this topic as a regular topic on
-
C clevername27 marked this topic as a question on
-
C clevername27 has marked this topic as solved on
-