peah | 60a189f | 2016-05-25 03:54:40 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_TEST_WAV_BASED_SIMULATOR_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_TEST_WAV_BASED_SIMULATOR_H_ |
peah | 60a189f | 2016-05-25 03:54:40 | [diff] [blame] | 13 | |
| 14 | #include <vector> |
| 15 | |
Danil Chapovalov | 2b36b37 | 2024-10-24 12:46:15 | [diff] [blame] | 16 | #include "absl/base/nullability.h" |
Ali Tofigh | f3592cb | 2022-08-16 12:44:38 | [diff] [blame] | 17 | #include "absl/strings/string_view.h" |
Danil Chapovalov | 2b36b37 | 2024-10-24 12:46:15 | [diff] [blame] | 18 | #include "api/audio/audio_processing.h" |
| 19 | #include "api/scoped_refptr.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 20 | #include "modules/audio_processing/test/audio_processing_simulator.h" |
peah | 60a189f | 2016-05-25 03:54:40 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | namespace test { |
| 24 | |
| 25 | // Used to perform an audio processing simulation from wav files. |
| 26 | class WavBasedSimulator final : public AudioProcessingSimulator { |
| 27 | public: |
Danil Chapovalov | 2b36b37 | 2024-10-24 12:46:15 | [diff] [blame] | 28 | WavBasedSimulator( |
| 29 | const SimulationSettings& settings, |
| 30 | absl::Nonnull<scoped_refptr<AudioProcessing>> audio_processing); |
Niels Möller | de95329 | 2020-09-29 07:46:21 | [diff] [blame] | 31 | |
| 32 | WavBasedSimulator() = delete; |
| 33 | WavBasedSimulator(const WavBasedSimulator&) = delete; |
| 34 | WavBasedSimulator& operator=(const WavBasedSimulator&) = delete; |
| 35 | |
kwiberg | 3cc8774 | 2016-08-29 22:10:34 | [diff] [blame] | 36 | ~WavBasedSimulator() override; |
peah | 60a189f | 2016-05-25 03:54:40 | [diff] [blame] | 37 | |
| 38 | // Processes the WAV input. |
| 39 | void Process() override; |
| 40 | |
Per Åhgren | 879d33b | 2021-01-21 09:08:15 | [diff] [blame] | 41 | // Only analyzes the data for the simulation, instead of perform any |
| 42 | // processing. |
| 43 | void Analyze() override; |
| 44 | |
peah | 60a189f | 2016-05-25 03:54:40 | [diff] [blame] | 45 | private: |
| 46 | enum SimulationEventType { |
| 47 | kProcessStream, |
| 48 | kProcessReverseStream, |
| 49 | }; |
| 50 | |
| 51 | void Initialize(); |
| 52 | bool HandleProcessStreamCall(); |
| 53 | bool HandleProcessReverseStreamCall(); |
| 54 | void PrepareProcessStreamCall(); |
| 55 | void PrepareReverseProcessStreamCall(); |
peah | 5ad5de3 | 2016-12-09 11:18:22 | [diff] [blame] | 56 | static std::vector<SimulationEventType> GetDefaultEventChain(); |
| 57 | static std::vector<SimulationEventType> GetCustomEventChain( |
Ali Tofigh | f3592cb | 2022-08-16 12:44:38 | [diff] [blame] | 58 | absl::string_view filename); |
peah | 60a189f | 2016-05-25 03:54:40 | [diff] [blame] | 59 | |
| 60 | std::vector<SimulationEventType> call_chain_; |
peah | 60a189f | 2016-05-25 03:54:40 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | } // namespace test |
| 64 | } // namespace webrtc |
| 65 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 66 | #endif // MODULES_AUDIO_PROCESSING_TEST_WAV_BASED_SIMULATOR_H_ |