diff options
author | bunnei <bunneidev@gmail.com> | 2018-09-13 00:23:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-13 00:23:54 +0200 |
commit | 926dd415871a8c38605678f2fdcbd556413e52ee (patch) | |
tree | 06c477f5b9f318d0c461d653f490d2c467cefec4 /src/audio_core/time_stretch.h | |
parent | Merge pull request #1306 from bunnei/fix-b5g6r5u (diff) | |
parent | audio_core: Flush stream when not playing anything (diff) | |
download | yuzu-926dd415871a8c38605678f2fdcbd556413e52ee.tar yuzu-926dd415871a8c38605678f2fdcbd556413e52ee.tar.gz yuzu-926dd415871a8c38605678f2fdcbd556413e52ee.tar.bz2 yuzu-926dd415871a8c38605678f2fdcbd556413e52ee.tar.lz yuzu-926dd415871a8c38605678f2fdcbd556413e52ee.tar.xz yuzu-926dd415871a8c38605678f2fdcbd556413e52ee.tar.zst yuzu-926dd415871a8c38605678f2fdcbd556413e52ee.zip |
Diffstat (limited to 'src/audio_core/time_stretch.h')
-rw-r--r-- | src/audio_core/time_stretch.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/audio_core/time_stretch.h b/src/audio_core/time_stretch.h new file mode 100644 index 000000000..7e39e695e --- /dev/null +++ b/src/audio_core/time_stretch.h @@ -0,0 +1,36 @@ +// Copyright 2018 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <array> +#include <cstddef> +#include <SoundTouch.h> +#include "common/common_types.h" + +namespace AudioCore { + +class TimeStretcher { +public: + TimeStretcher(u32 sample_rate, u32 channel_count); + + /// @param in Input sample buffer + /// @param num_in Number of input frames in `in` + /// @param out Output sample buffer + /// @param num_out Desired number of output frames in `out` + /// @returns Actual number of frames written to `out` + size_t Process(const s16* in, size_t num_in, s16* out, size_t num_out); + + void Clear(); + + void Flush(); + +private: + u32 m_sample_rate; + u32 m_channel_count; + soundtouch::SoundTouch m_sound_touch; + double m_stretch_ratio = 1.0; +}; + +} // namespace AudioCore |