Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: webrtc/modules/audio_processing/test/fake_recording_device.h

Issue 2834643002: audioproc_f with simulated mic analog gain (Closed)
Patch Set: Merge + comments addressed Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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;
28
29 // Class for simulating a microphone with analog gain.
30 //
31 // The intended modes of operation are the following:
32 //
33 // FakeRecordingDevice fake_mic(
34 // 255, FakeRecordingDevice.DeviceKind.LINEAR);
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_; }
peah-webrtc 2017/06/29 22:04:00 This getter is never used. Please remove.
AleBzk 2017/07/26 13:42:30 Done.
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(AudioFrame* 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(ChannelBuffer<float>* 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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698