wav_based_simulator.h (2037B)
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 11 #ifndef MODULES_AUDIO_PROCESSING_TEST_WAV_BASED_SIMULATOR_H_ 12 #define MODULES_AUDIO_PROCESSING_TEST_WAV_BASED_SIMULATOR_H_ 13 14 #include <vector> 15 16 #include "absl/base/nullability.h" 17 #include "absl/strings/string_view.h" 18 #include "api/audio/audio_processing.h" 19 #include "api/scoped_refptr.h" 20 #include "modules/audio_processing/test/audio_processing_simulator.h" 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: 28 WavBasedSimulator( 29 const SimulationSettings& settings, 30 absl_nonnull scoped_refptr<AudioProcessing> audio_processing); 31 32 WavBasedSimulator() = delete; 33 WavBasedSimulator(const WavBasedSimulator&) = delete; 34 WavBasedSimulator& operator=(const WavBasedSimulator&) = delete; 35 36 ~WavBasedSimulator() override; 37 38 // Processes the WAV input. 39 void Process() override; 40 41 // Only analyzes the data for the simulation, instead of perform any 42 // processing. 43 void Analyze() override; 44 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(); 56 static std::vector<SimulationEventType> GetDefaultEventChain(); 57 static std::vector<SimulationEventType> GetCustomEventChain( 58 absl::string_view filename); 59 60 std::vector<SimulationEventType> call_chain_; 61 }; 62 63 } // namespace test 64 } // namespace webrtc 65 66 #endif // MODULES_AUDIO_PROCESSING_TEST_WAV_BASED_SIMULATOR_H_