Index: webrtc/modules/audio_processing/repetition_detector.h |
diff --git a/webrtc/modules/audio_processing/repetition_detector.h b/webrtc/modules/audio_processing/repetition_detector.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3871bf61015efe12cde4c0961d8ee5008bc7dcfd |
--- /dev/null |
+++ b/webrtc/modules/audio_processing/repetition_detector.h |
@@ -0,0 +1,81 @@ |
+/* |
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_REPETITION_DETECTOR_H_ |
+#define WEBRTC_MODULES_AUDIO_PROCESSING_REPETITION_DETECTOR_H_ |
+ |
+#include <vector> |
+ |
+#include "webrtc/base/constructormagic.h" |
+#include "webrtc/typedefs.h" |
+ |
+namespace webrtc { |
+ |
+class RepetitionDetector { |
+ public: |
+ RepetitionDetector(); |
+ virtual ~RepetitionDetector(); |
+ |
+ struct Pattern { |
+ int id_; |
+ // All followings are in samples-per-channel, and are independent of sample |
+ // rate, since repetition patterns are supposedly independent of sample |
peah-webrtc
2015/08/12 11:02:54
I'm not sure that the repetition pattern length is
minyue-webrtc
2015/08/12 11:32:14
Right. I had this in my mind when I wrote this, an
|
+ // rate. |
+ int look_back_; |
+ int look_back_range_; |
+ int length_; |
+ int length_range_; |
+ }; |
+ |
+ // Detect repetition given audio samples. When multichannel, samples are |
+ // interleaved. |
+ void Detect(const int16_t* data, int samples_per_channel, |
Andrew MacDonald
2015/08/11 20:50:42
float is preferred now.
minyue-webrtc
2015/08/12 11:32:14
Oh. We depend strongly on the assumption that the
hlundin-webrtc
2015/08/12 14:12:04
Use size_t for samples_per_channel and num_channel
Andrew MacDonald
2015/08/12 20:25:32
Not necessarily, but the Chromium audio pipeline i
|
+ int num_channels); |
+ |
+ protected: |
+ void RegisterRepititionPatterns(const Pattern* patterns, |
hlundin-webrtc
2015/08/12 14:12:04
Why not use some std container class instead of ol
|
+ int num_patterns); |
hlundin-webrtc
2015/08/12 14:12:04
Align.
|
+ void ClearRepititionPatterns(); |
+ virtual void ReportRepetition(int id) { } |
+ |
+ private: |
+ struct State { |
+ State(int id, int look_back, int length, int length_range) |
+ : id_(id), |
+ look_back_(look_back), |
+ length_(length), |
+ length_range_(length_range), |
+ count_(0) { |
+ } |
+ int id_; |
+ int look_back_; |
hlundin-webrtc
2015/08/12 14:12:04
I'd prefer size_t for the length and count variabl
minyue-webrtc
2015/08/28 14:27:00
Now measure in millisecond.
But other counters ar
|
+ int length_; |
+ int length_range_; |
+ int count_; |
+ }; |
+ |
+ void CreateBuffer(); |
+ void DeleteBuffer(); |
+ |
+ void Reset(int new_num_channels); |
+ |
+ std::vector<State> states_; |
+ |
+ int16_t** audio_buffer_; // Ring buffers to store input audio channels. |
Andrew MacDonald
2015/08/11 20:50:42
Use vectors for this. (Or consider AudioRingBuffer
minyue-webrtc
2015/08/12 11:32:14
Acknowledged.
|
+ int num_channels_; // Number of audio channels in buffer. |
+ int buffer_length_samples_; // Total samples in buffer for each channel. |
+ int buffer_end_; // Pointer to the end of audio buffer. |
+ |
+ DISALLOW_COPY_AND_ASSIGN(RepetitionDetector); |
+}; |
+ |
+} // namespace webrtc |
+ |
+#endif // WEBRTC_MODULES_AUDIO_PROCESSING_REPETITION_DETECTOR_H_ |