]> git.sesse.net Git - nageru/blobdiff - nageru/audio_clip.h
Make an automated delay estimate, by way of cross-correlation.
[nageru] / nageru / audio_clip.h
index 693dbbd4aa863e141a4ac619ea24e59d10c23f56..c087bdb2caa199035fb8e5f2e58e2d67e1abf574 100644 (file)
@@ -22,6 +22,12 @@ public:
        // Only valid if not empty.
        std::chrono::steady_clock::time_point get_first_sample() const;
 
+       struct BestCorrelation {
+               float delay_ms;  // Positive values means this clip is delayed compared to the reference.
+               float correlation;  // Between -1 and +1 (+1 is a perfect match, -1 is a perfect inversion).
+       };
+       BestCorrelation find_best_correlation(const AudioClip *reference) const;
+
        std::unique_ptr<std::pair<float, float>[]> get_min_max_peaks(unsigned width, std::chrono::steady_clock::time_point base) const;
 
 private: