]> git.sesse.net Git - nageru/blobdiff - nageru/peak_display.cpp
Make the delay analyzer understand that two sources can have different starting times.
[nageru] / nageru / peak_display.cpp
index eda6b540fdbeffe4df6ee6799f03662512e99e29..c8e43913c42ef97cb2582ba978684506adedb85d 100644 (file)
@@ -11,6 +11,7 @@
 #include "audio_clip.h"
 
 using namespace std;
+using namespace std::chrono;
 
 PeakDisplay::PeakDisplay(QWidget *parent)
        : QWidget(parent)
@@ -24,8 +25,13 @@ void PeakDisplay::audio_clip_updated()
 
 void PeakDisplay::paintEvent(QPaintEvent *event)
 {
+       steady_clock::time_point paint_base = base;
+       if (paint_base == steady_clock::time_point() && !audio_clip->empty()) {
+               paint_base = audio_clip->get_first_sample();
+       }
+
        int w = width();
-       unique_ptr<pair<float, float>[]> min_max = audio_clip->get_min_max_peaks(w);
+       unique_ptr<pair<float, float>[]> min_max = audio_clip->get_min_max_peaks(w, paint_base);
 
        QPainter painter(this);
        painter.fillRect(event->rect(), Qt::white);