]> git.sesse.net Git - nageru/blobdiff - nageru/audio_clip.h
When the delay analyzer wants audio from an ALSA card, temporarily auto-enable captur...
[nageru] / nageru / audio_clip.h
index 71248af99cc5ba1cdef3f5ac081c8f6e00c8682d..c087bdb2caa199035fb8e5f2e58e2d67e1abf574 100644 (file)
@@ -15,9 +15,20 @@ class AudioClip
 public:
        void clear();
        void add_audio(const float *samples, size_t num_samples, double sample_rate, std::chrono::steady_clock::time_point frame_time);
-       double get_length_seconds() const;
+       double get_length_seconds() const;  // 0.0 if empty().
+       double get_length_seconds_after_base(std::chrono::steady_clock::time_point base) const;
+       bool empty() const;
 
-       std::unique_ptr<std::pair<float, float>[]> get_min_max_peaks(unsigned width) const;
+       // 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:
        mutable std::mutex mu;