1 // Copyright 2016 Citra Emulator Project 2 // Licensed under GPLv2 or any later version 3 // Refer to the license.txt file included. 4 5 #pragma once 6 7 #include <array> 8 #include <cstddef> 9 #include <memory> 10 #include "common/common_types.h" 11 12 namespace soundtouch { 13 class SoundTouch; 14 } 15 16 namespace AudioCore { 17 18 class TimeStretcher { 19 public: 20 TimeStretcher(); 21 ~TimeStretcher(); 22 23 void SetOutputSampleRate(unsigned int sample_rate); 24 25 /// @param in Input sample buffer 26 /// @param num_in Number of input frames in `in` 27 /// @param out Output sample buffer 28 /// @param num_out Desired number of output frames in `out` 29 /// @returns Actual number of frames written to `out` 30 std::size_t Process(const s16* in, std::size_t num_in, s16* out, std::size_t num_out); 31 32 void Clear(); 33 34 void Flush(); 35 36 private: 37 unsigned int sample_rate; 38 std::unique_ptr<soundtouch::SoundTouch> sound_touch; 39 double stretch_ratio = 1.0; 40 }; 41 42 } // namespace AudioCore 43