--- /dev/null
+#ifndef AUDIO_CLIP_H
+#define AUDIO_CLIP_H
+
+// A short single-channel recording of an audio clip, for the delay analyzer.
+// Thread safe.
+
+#include <chrono>
+#include <memory>
+#include <mutex>
+#include <utility>
+#include <vector>
+
+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;
+
+ std::unique_ptr<std::pair<float, float>[]> get_min_max_peaks(unsigned width) const;
+
+private:
+ mutable std::mutex mu;
+ std::vector<float> vals; // Under <mutex>.
+ double sample_rate; // Under <mutex>.
+ std::chrono::steady_clock::time_point first_sample; // Under <mutex>.
+};
+
+#endif