Line data Source code
1 : #pragma once
2 :
3 : namespace Amplitron {
4 :
5 : /**
6 : * @brief Utility class to analyze VU levels, RMS smoothing, peak holds, and clip indicators.
7 : * Moves level computation and smoothing math outside of the UI thread.
8 : */
9 : class LevelAnalyzer {
10 : public:
11 1458 : LevelAnalyzer() = default;
12 :
13 : /**
14 : * @brief Update analyzer values with current block RMS and clipping info.
15 : * @param input_rms Current input RMS level.
16 : * @param output_rms Current output RMS level.
17 : * @param input_clipped True if clipping was detected in the input.
18 : * @param output_clipped True if clipping was detected in the output.
19 : * @param dt Time delta since last update.
20 : */
21 : void update(float input_rms, float output_rms, bool input_clipped, bool output_clipped, float dt);
22 :
23 22 : float smoothed_input_rms() const { return smoothed_input_rms_; }
24 17 : float smoothed_output_rms() const { return smoothed_output_rms_; }
25 19 : float input_peak_hold() const { return input_peak_hold_; }
26 16 : float output_peak_hold() const { return output_peak_hold_; }
27 13 : float input_clip_flash() const { return input_clip_flash_; }
28 13 : float output_clip_flash() const { return output_clip_flash_; }
29 :
30 : private:
31 296 : float smoothed_input_rms_ = 0.0f;
32 296 : float smoothed_output_rms_ = 0.0f;
33 296 : float input_peak_hold_ = 0.0f;
34 296 : float output_peak_hold_ = 0.0f;
35 296 : float input_clip_flash_ = 0.0f;
36 296 : float output_clip_flash_ = 0.0f;
37 : };
38 :
39 : } // namespace Amplitron
|