summaryrefslogtreecommitdiffstats
path: root/src/audio_core/time_stretch.h
diff options
context:
space:
mode:
authorMerryMage <MerryMage@users.noreply.github.com>2018-09-08 17:48:13 +0200
committerMerryMage <MerryMage@users.noreply.github.com>2018-09-08 19:56:38 +0200
commite51bd49f87052d0706a016fab88d18ffef05b8b1 (patch)
tree76eccf3f2b428ada51c8025bc3ab7c512263854d /src/audio_core/time_stretch.h
parentcubeb_sink: Hold last available value instead of writing zeros (diff)
downloadyuzu-e51bd49f87052d0706a016fab88d18ffef05b8b1.tar
yuzu-e51bd49f87052d0706a016fab88d18ffef05b8b1.tar.gz
yuzu-e51bd49f87052d0706a016fab88d18ffef05b8b1.tar.bz2
yuzu-e51bd49f87052d0706a016fab88d18ffef05b8b1.tar.lz
yuzu-e51bd49f87052d0706a016fab88d18ffef05b8b1.tar.xz
yuzu-e51bd49f87052d0706a016fab88d18ffef05b8b1.tar.zst
yuzu-e51bd49f87052d0706a016fab88d18ffef05b8b1.zip
Diffstat (limited to '')
-rw-r--r--src/audio_core/time_stretch.h35
1 files changed, 35 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..cdead34a2
--- /dev/null
+++ b/src/audio_core/time_stretch.h
@@ -0,0 +1,35 @@
+// 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();
+
+private:
+ u32 m_sample_rate;
+ u32 m_channel_count;
+ std::array<s16, 2> m_last_stretched_sample = {};
+ soundtouch::SoundTouch m_sound_touch;
+ double m_stretch_ratio = 1.0;
+};
+
+} // namespace AudioCore