4 // A short single-channel recording of an audio clip, for the delay analyzer.
17 void add_audio(const float *samples, size_t num_samples, double sample_rate, std::chrono::steady_clock::time_point frame_time);
18 double get_length_seconds() const; // 0.0 if empty().
19 double get_length_seconds_after_base(std::chrono::steady_clock::time_point base) const;
22 // Only valid if not empty.
23 std::chrono::steady_clock::time_point get_first_sample() const;
25 struct BestCorrelation {
26 float delay_ms; // Positive values means this clip is delayed compared to the reference.
27 float correlation; // Between -1 and +1 (+1 is a perfect match, -1 is a perfect inversion).
29 BestCorrelation find_best_correlation(const AudioClip *reference) const;
31 std::unique_ptr<std::pair<float, float>[]> get_min_max_peaks(unsigned width, std::chrono::steady_clock::time_point base) const;
34 mutable std::mutex mu;
35 std::vector<float> vals; // Under <mutex>.
36 double sample_rate; // Under <mutex>.
37 std::chrono::steady_clock::time_point first_sample; // Under <mutex>.