]> git.sesse.net Git - nageru/commitdiff
Show historic peak of each bus under the peak meter.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 28 Aug 2016 20:32:01 +0000 (22:32 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 19 Oct 2016 22:55:44 +0000 (00:55 +0200)
audio_mixer.cpp
audio_mixer.h
mainwindow.cpp

index 6b7ffeb0d6d28fb1ffdbfa8308ab341970893b20..7810b43ab8fb991d79387ec135ba4c701254dfe6 100644 (file)
@@ -555,6 +555,7 @@ void AudioMixer::measure_bus_levels(unsigned bus_index, const vector<float> &lef
                static constexpr float falloff_db_sec = 15.0f;  // dB/sec falloff after hold.
                float current_peak;
                PeakHistory &history = peak_history[bus_index][channel];
+               history.historic_peak = max(history.historic_peak, peak_levels[channel]);
                if (history.age_seconds < hold_sec) {
                        current_peak = history.last_peak;
                } else {
@@ -639,6 +640,9 @@ void AudioMixer::send_audio_level_callback()
                        bus_levels[bus_index].current_level_dbfs[1] = to_db(peak_history[bus_index][1].current_level);
                        bus_levels[bus_index].peak_level_dbfs[0] = to_db(peak_history[bus_index][0].current_peak);
                        bus_levels[bus_index].peak_level_dbfs[1] = to_db(peak_history[bus_index][1].current_peak);
+                       bus_levels[bus_index].historic_peak_dbfs = to_db(
+                               max(peak_history[bus_index][0].historic_peak,
+                                   peak_history[bus_index][1].historic_peak));
                        bus_levels[bus_index].gain_staging_db = gain_staging_db[bus_index];
                        if (compressor_enabled[bus_index]) {
                                bus_levels[bus_index].compressor_attenuation_db = -to_db(compressor[bus_index]->get_attenuation());
index 6e7719f23313238b5bebaab70fea90e47af1c8b0..5d65582c939fa191bcf8efad870d6e1c65b65c25 100644 (file)
@@ -204,6 +204,7 @@ public:
        struct BusLevel {
                float current_level_dbfs[2];  // Digital peak of last frame, left and right.
                float peak_level_dbfs[2];  // Digital peak with hold, left and right.
+               float historic_peak_dbfs;
                float gain_staging_db;
                float compressor_attenuation_db;  // A positive number; 0.0 for no attenuation.
        };
@@ -270,9 +271,11 @@ private:
        std::atomic<float> compressor_threshold_dbfs[MAX_BUSES];
        std::atomic<bool> compressor_enabled[MAX_BUSES];
 
+       // Note: The values here are not in dB.
        struct PeakHistory {
-               float current_level = 0.0f;  // Peak of the last frame (not in dB).
-               float current_peak = 0.0f;  // Current peak of the peak meter (not in dB).
+               float current_level = 0.0f;  // Peak of the last frame.
+               float historic_peak = 0.0f;  // Highest peak since last reset; no falloff.
+               float current_peak = 0.0f;  // Current peak of the peak meter.
                float last_peak = 0.0f;
                float age_seconds = 0.0f;   // Time since "last_peak" was set.
        };
index 923c4f9f199c45eabfbf05a50c70772e6013db15..261269add87ddd6002ee753eb5aa00b7e7886ce8 100644 (file)
@@ -127,6 +127,19 @@ string format_db(double db, unsigned flags)
        return text;
 }
 
+void set_peak_label(QLabel *peak_label, float peak_db)
+{
+       peak_label->setText(QString::fromStdString(format_db(peak_db, DB_BARE)));
+
+       // -0.1 dBFS is EBU peak limit. We use it consistently, even for the bus meters
+       // (which don't calculate interpolate peak, and in general don't follow EBU recommendations).
+       if (peak_db > -0.1f) {
+               peak_label->setStyleSheet("QLabel { background-color: red; color: white; }");
+       } else {
+               peak_label->setStyleSheet("");
+       }
+}
+
 }  // namespace
 
 MainWindow::MainWindow()
@@ -579,6 +592,7 @@ void MainWindow::audio_level_callback(float level_lufs, float peak_db, vector<Au
                                        level.current_level_dbfs[0], level.current_level_dbfs[1]);
                                miniview->peak_meter->set_peak(
                                        level.peak_level_dbfs[0], level.peak_level_dbfs[1]);
+                               set_peak_label(miniview->peak_display_label, level.historic_peak_dbfs);
 
                                Ui::AudioExpandedView *view = audio_expanded_views[bus_index];
                                view->peak_meter->set_level(
@@ -592,17 +606,14 @@ void MainWindow::audio_level_callback(float level_lufs, float peak_db, vector<Au
                                view->gainstaging_db_display->setText(
                                        QString("Gain: ") +
                                        QString::fromStdString(format_db(level.gain_staging_db, DB_WITH_SIGN)));
+                               set_peak_label(view->peak_display_label, level.historic_peak_dbfs);
                        }
                }
                ui->lra_meter->set_levels(global_level_lufs, range_low_lufs, range_high_lufs);
                ui->correlation_meter->set_correlation(correlation);
 
                ui->peak_display->setText(QString::fromStdString(format_db(peak_db, DB_BARE)));
-               if (peak_db > -0.1f) {  // -0.1 dBFS is EBU peak limit.
-                       ui->peak_display->setStyleSheet("QLabel { background-color: red; color: white; }");
-               } else {
-                       ui->peak_display->setStyleSheet("");
-               }
+               set_peak_label(ui->peak_display, peak_db);
 
                // NOTE: Will be invisible when using multitrack audio.
                ui->gainstaging_knob->blockSignals(true);