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

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: minor changes Created 3 years, 4 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/common_audio/channel_buffer.h"
19 #include "webrtc/modules/include/module_common_types.h"
20 #include "webrtc/rtc_base/array_view.h"
21 #include "webrtc/rtc_base/checks.h"
22 #include "webrtc/rtc_base/optional.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(255, 1);
34 //
35 // fake_mic.set_mic_level(170);
peah-webrtc 2017/08/18 08:54:29 Please update the comments to comply with the api
AleBzk 2017/09/04 12:02:03 Done.
36 // fake_mic.set_undo_mic_level(rtc::Optional<int>());
37 // fake_mic.SimulateAnalogGain(buffer);
38 //
39 // When the mic level to undo is known:
40 //
41 // fake_mic.set_mic_level(170);
42 // fake_mic.set_undo_mic_level(rtc::Optional<int>(30));
43 // fake_mic.SimulateAnalogGain(buffer);
44 //
45 // The second option virtually restores the unmodified microphone level. Calling
46 // SimulateAnalogGain() will first "undo" the gain applied by the real
47 // microphone (e.g., 30).
48 class FakeRecordingDevice final {
49 public:
50 FakeRecordingDevice(int initial_mic_level, int device_kind);
51 ~FakeRecordingDevice();
52
53 int MicLevel() const;
54 void SetMicLevel(const int level);
55 void SetUndoMicLevel(const rtc::Optional<int> level);
56
57 // Simulates the analog gain.
58 // If |real_device_level| is a valid level, the unmodified mic signal is
59 // virtually restored. To skip the latter step set |real_device_level| to
60 // an empty value.
61 void SimulateAnalogGain(AudioFrame* buffer);
62
63 // Simulates the analog gain.
64 // If |real_device_level| is a valid level, the unmodified mic signal is
65 // virtually restored. To skip the latter step set |real_device_level| to
66 // an empty value.
67 void SimulateAnalogGain(ChannelBuffer<float>* buffer);
68
69 private:
70 // Fake recording device worker.
71 std::unique_ptr<FakeRecordingDeviceWorker> worker_;
72 };
73
74 } // namespace test
75 } // namespace webrtc
76
77 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_FAKE_RECORDING_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698