Help with Info So I Can Write Peak Meter Tutorial for Everyone?
-
I'm looking to add a detailed Peak Meter tutorial to my LAF tutorial for everyone…but there's stuff I don't know about the MatrixPeakMeter tile. Can anyone please help? Below are my guesses for three categories of information. It's a lot of info…just (please) answer what you can, and I'll write it all up. My questions are in bold. The rest of the text is what I'm guessing to be correct.
INSPECTOR PARAMETERS
ProcessorId: The ID of the FX module you want to measure the output of.
Index: Don't know.
FollowWorkspace: Don't know.
SegmentLedSize: If you want to break the meter display into segments, enter the pixel size here. If you leave it at zero, the meter will be drawn in 1-pixel increments.
UpDecayTime: The time, in milliseconds, for the meter to display a peak.
DownDecayTime: The time, in milliseconds, for the meter to redraw after displaying a peak.
UseSourceChannels: Don't know.
SkewFactor: The weighting of the peak, though I don't know the specific equation here.
PaddingSize: Don't know.
ShowMaxPeak: Obviously, a true or false if the peak is shown, but within this context, I don't know exactly what this means?
ChannelIndexes: Which channels to display; Use '1' for mono, and '2' for stereo.
WORKING WITH DATA
The MatrixPeakMeter will provide you with an array of peaks over a specific length of time. This is a floating point value: 0.0 is silence, and 1.0 is the maximum level before clipping. Anything over equal to or great than 1.0 is clipping.
Getting the maximum peak: Iterate through the array, and save the highest value.
Getting the average peak: Iterate through the array, adding the values, and then divide by the length of the array.What affects the length of peak array? When I measure it, I always seem to get an array length of 1 (which isn't really an array).
How do we know the sampling period for the peak array?
How do we know if any peaks (greater than what is in the array) occurred?
What does it mean to ask "if (obj.peaks)"? I am guessing that if the value of any peak in the array is >= 1, then this condition fires. But obj.peaks is an array…don't we need to iterate through the array to get the values?
LAF STUFF
Use obj.peaks to get the peak data.
Drawing the graphics of the peak meters is simple drawing commands. Get the size of the component, and go from there. (I'll document in detail, but no need to go into here.) Likewise, to determine if it's a horizontal or vertical peak meter, take the component's area and compare width to height.
Using gradients is likewise simple; no need to draw here. If you want the gradient to go through specific colors, and put those colors at specific points, HISE's gradient drawing makes this easy—I can document no problem.
What's a better way to implement peak hold than this: Create two global variables; highestPeak and numOfCallsLAF. Each time the LAF is called: Compare the highest peak during that LAF iteration to the highestPeak global. If the current peak is higher than highestPeak:
1) Draw a bar at the end of standard meter bar.
2) Set Increment numOfCallsLAF to 1.
3) Update highestPeak.
But if it's not higher, then increment numOfCallsLAF. Check if numOfCallsLAF is greater than a number representing your hold period (for example, 20). If numOfCallsLAF > 20, then erase the peak-hold line, and draw a new one at whatever the current LAF's highest peak is, and store that value in highestPeak.That seems kinda convoluted, but at least avoids using another Timer.
FREQUENCY-WEIGHTED METERS
No questions here, just an offer if anyone's interested: It's sometimes useful to know the frequency range with the highest peak. If I can find out all of the information we need in the above questions, I can write a peak meter using a FT which adds a frequency band to the peak-hold display.
Cheers!
-
C clevername27 marked this topic as a question on
-
FollowWorkspace
This is a redundant property in almost all cases, so feel free to ignore
Index
This is also a generic property that is not used by the matrix peak meter
UseSourceChannels
Whether to use the input or output channels (makes a difference if you're using a custom routing)
PaddingSize
The padding size in pixels for the meters (in all directions)
ShowMaxPeak
Like you said, if true, it will show a line of the max peak (like Ableton 10+)
ChannelIndexes
an array of zero based integer indexes
[0, 1]
would be main stereoWhat affects the length of peak array?
The channel index array
How do we know the sampling period for the peak array?
It calculates the max value for each buffer and then applies the envelope follower defined by UpDecayTime and DownDecayTime.
How do we know if any peaks (greater than what is in the array) occurred?
It takes all samples into account so it doesn't just poll a random value at a given point so there will be no missed peaks. However if you set the attack time of the envelope follower to something > 0, then some short peaks will be smoothed away. If the ramp down time is to fast, then you might miss it (hence the two separate values, usually, you would just a very fast ramp up time and a slow ramp down time).
What's a better way to implement peak hold than this:
Don't. Set
ShowMaxPeak
to true, and then you will get the value ready for usage with a similar algorithm as you described. -
@Christoph-Hart Well, that answers all that.
Off to write the tutorial.
-
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