OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2017 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_TEST_FAKE_RECORDING_DEVICE_H_ | |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_FAKE_RECORDING_DEVICE_H_ | |
13 | |
14 #include <algorithm> | |
15 #include <memory> | |
16 #include <vector> | |
17 | |
18 #include "webrtc/base/array_view.h" | |
19 #include "webrtc/base/checks.h" | |
20 #include "webrtc/base/optional.h" | |
21 #include "webrtc/common_audio/channel_buffer.h" | |
22 #include "webrtc/modules/include/module_common_types.h" | |
23 | |
24 namespace webrtc { | |
25 namespace test { | |
26 | |
27 class FakeRecordingDeviceWorker; | |
AleBzk
2017/06/22 10:16:01
Forward declaration for the FakeRecordingDeviceWor
| |
28 | |
29 // Abstract class for simulating a microphone with analog gain. | |
peah-webrtc
2017/06/29 05:45:27
This is not an abstract class, right? Or did I get
AleBzk
2017/06/29 11:43:36
Sorry, this comment applies to the previous PS, I
| |
30 // | |
31 // The intended modes of operation are the following: | |
32 // | |
33 // auto fake_mic = FakeRecordingDevice( | |
34 // 255, FakeRecordingDevice.DeviceKind.LINEAR); | |
AleBzk
2017/06/22 10:16:01
I fixed this as follows:
// FakeRecordingDevice f
| |
35 // | |
36 // fake_mic.set_mic_level(170); | |
37 // fake_mic.set_undo_mic_level(rtc::Optional<int>()); | |
38 // fake_mic.SimulateAnalogGain(buffer); | |
39 // | |
40 // When the mic level to undo is known: | |
41 // | |
42 // fake_mic.set_mic_level(170); | |
43 // fake_mic.set_undo_mic_level(rtc::Optional<int>(30)); | |
44 // fake_mic.SimulateAnalogGain(buffer); | |
45 // | |
46 // The second option virtually restores the unmodified microphone level. Calling | |
47 // SimulateAnalogGain() will first "undo" the gain applied by the real | |
48 // microphone (e.g., 30). | |
49 class FakeRecordingDevice final { | |
50 public: | |
51 enum class DeviceKind { IDENTITY, LINEAR }; | |
52 | |
53 FakeRecordingDevice(int initial_mic_level, DeviceKind kind); | |
54 ~FakeRecordingDevice(); | |
55 | |
56 // Setter and getter for the mic level to simulate. | |
57 void set_mic_level(int level) { mic_level_ = level; } | |
58 int mic_level() const { return mic_level_; } | |
59 | |
60 // Setter and getter for the mic level to undo. | |
61 void set_undo_mic_level(rtc::Optional<int> level) { undo_mic_level_ = level; } | |
62 rtc::Optional<int> undo_mic_level() const { return undo_mic_level_; } | |
63 | |
64 // Simulates the analog gain. | |
65 // If |real_device_level| is a valid level, the unmodified mic signal is | |
66 // virtually restored. To skip the latter step set |real_device_level| to | |
67 // an empty value. | |
68 void SimulateAnalogGain(ChannelBuffer<float>* buffer); | |
69 | |
70 // Simulates the analog gain. | |
71 // If |real_device_level| is a valid level, the unmodified mic signal is | |
72 // virtually restored. To skip the latter step set |real_device_level| to | |
73 // an empty value. | |
74 void SimulateAnalogGain(AudioFrame* buffer); | |
75 | |
76 private: | |
77 // Mic level to simulate. | |
78 int mic_level_; | |
79 | |
80 // Fake recording device worker. | |
81 std::unique_ptr<FakeRecordingDeviceWorker> worker_; | |
82 | |
83 // Optional undo mic level. | |
84 rtc::Optional<int> undo_mic_level_; | |
85 }; | |
86 | |
87 } // namespace test | |
88 } // namespace webrtc | |
89 | |
90 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_FAKE_RECORDING_DEVICE_H_ | |
OLD | NEW |