diff options
author | Maribel <MerryMage@users.noreply.github.com> | 2016-05-15 03:04:03 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2016-05-14 22:04:03 -0400 |
commit | 6f6af6928fdff8c807e4a4d03cfd8906e0c7c7cd (patch) | |
tree | c857bb669cb13a0358ec6f5bee504963254534c6 /src/audio_core/hle/dsp.cpp | |
parent | d299f7ed2808cb5be16cc7def68cbbba2388af65 (diff) |
AudioCore: Implement time stretcher (#1737)
* AudioCore: Implement time stretcher
* fixup! AudioCore: Implement time stretcher
* fixup! fixup! AudioCore: Implement time stretcher
* fixup! fixup! fixup! AudioCore: Implement time stretcher
* fixup! fixup! fixup! fixup! AudioCore: Implement time stretcher
* fixup! fixup! fixup! fixup! fixup! AudioCore: Implement time stretcher
Diffstat (limited to 'src/audio_core/hle/dsp.cpp')
-rw-r--r-- | src/audio_core/hle/dsp.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/audio_core/hle/dsp.cpp b/src/audio_core/hle/dsp.cpp index 0cdbdb06ab..5113ad8cab 100644 --- a/src/audio_core/hle/dsp.cpp +++ b/src/audio_core/hle/dsp.cpp @@ -9,6 +9,7 @@ #include "audio_core/hle/pipe.h" #include "audio_core/hle/source.h" #include "audio_core/sink.h" +#include "audio_core/time_stretch.h" namespace DSP { namespace HLE { @@ -48,15 +49,29 @@ static std::array<Source, num_sources> sources = { }; static std::unique_ptr<AudioCore::Sink> sink; +static AudioCore::TimeStretcher time_stretcher; void Init() { DSP::HLE::ResetPipes(); + for (auto& source : sources) { source.Reset(); } + + time_stretcher.Reset(); + if (sink) { + time_stretcher.SetOutputSampleRate(sink->GetNativeSampleRate()); + } } void Shutdown() { + time_stretcher.Flush(); + while (true) { + std::vector<s16> residual_audio = time_stretcher.Process(sink->SamplesInQueue()); + if (residual_audio.empty()) + break; + sink->EnqueueSamples(residual_audio); + } } bool Tick() { @@ -77,6 +92,7 @@ bool Tick() { void SetSink(std::unique_ptr<AudioCore::Sink> sink_) { sink = std::move(sink_); + time_stretcher.SetOutputSampleRate(sink->GetNativeSampleRate()); } } // namespace HLE |