OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_REPETITION_DETECTOR_H_ | |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_REPETITION_DETECTOR_H_ | |
13 | |
14 #include <vector> | |
15 | |
16 #include "webrtc/base/constructormagic.h" | |
17 #include "webrtc/typedefs.h" | |
18 | |
19 namespace webrtc { | |
20 | |
21 class RepetitionDetector { | |
22 public: | |
23 RepetitionDetector(); | |
24 virtual ~RepetitionDetector(); | |
25 | |
26 struct Pattern { | |
27 int id_; | |
28 // All followings are in samples-per-channel, and are independent of sample | |
29 // 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
| |
30 // rate. | |
31 int look_back_; | |
32 int look_back_range_; | |
33 int length_; | |
34 int length_range_; | |
35 }; | |
36 | |
37 // Detect repetition given audio samples. When multichannel, samples are | |
38 // interleaved. | |
39 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
| |
40 int num_channels); | |
41 | |
42 protected: | |
43 void RegisterRepititionPatterns(const Pattern* patterns, | |
hlundin-webrtc
2015/08/12 14:12:04
Why not use some std container class instead of ol
| |
44 int num_patterns); | |
hlundin-webrtc
2015/08/12 14:12:04
Align.
| |
45 void ClearRepititionPatterns(); | |
46 virtual void ReportRepetition(int id) { } | |
47 | |
48 private: | |
49 struct State { | |
50 State(int id, int look_back, int length, int length_range) | |
51 : id_(id), | |
52 look_back_(look_back), | |
53 length_(length), | |
54 length_range_(length_range), | |
55 count_(0) { | |
56 } | |
57 int id_; | |
58 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
| |
59 int length_; | |
60 int length_range_; | |
61 int count_; | |
62 }; | |
63 | |
64 void CreateBuffer(); | |
65 void DeleteBuffer(); | |
66 | |
67 void Reset(int new_num_channels); | |
68 | |
69 std::vector<State> states_; | |
70 | |
71 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.
| |
72 int num_channels_; // Number of audio channels in buffer. | |
73 int buffer_length_samples_; // Total samples in buffer for each channel. | |
74 int buffer_end_; // Pointer to the end of audio buffer. | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(RepetitionDetector); | |
77 }; | |
78 | |
79 } // namespace webrtc | |
80 | |
81 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_REPETITION_DETECTOR_H_ | |
OLD | NEW |