diff options
| author | 2018-09-12 18:23:54 -0400 | |
|---|---|---|
| committer | 2018-09-12 18:23:54 -0400 | |
| commit | 926dd415871a8c38605678f2fdcbd556413e52ee (patch) | |
| tree | 06c477f5b9f318d0c461d653f490d2c467cefec4 /src/audio_core | |
| parent | Merge pull request #1306 from bunnei/fix-b5g6r5u (diff) | |
| parent | audio_core: Flush stream when not playing anything (diff) | |
| download | yuzu-926dd415871a8c38605678f2fdcbd556413e52ee.tar.gz yuzu-926dd415871a8c38605678f2fdcbd556413e52ee.tar.xz yuzu-926dd415871a8c38605678f2fdcbd556413e52ee.zip | |
Merge pull request #1163 from FearlessTobi/add-audio-stretching
audio_core: Add audio stretching support
Diffstat (limited to 'src/audio_core')
| -rw-r--r-- | src/audio_core/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/audio_core/cubeb_sink.cpp | 114 | ||||
| -rw-r--r-- | src/audio_core/null_sink.h | 6 | ||||
| -rw-r--r-- | src/audio_core/sink_stream.h | 4 | ||||
| -rw-r--r-- | src/audio_core/stream.cpp | 3 | ||||
| -rw-r--r-- | src/audio_core/time_stretch.cpp | 68 | ||||
| -rw-r--r-- | src/audio_core/time_stretch.h | 36 |
7 files changed, 185 insertions, 49 deletions
diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index 82e4850f7..c381dbe1d 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt | |||
| @@ -17,6 +17,8 @@ add_library(audio_core STATIC | |||
| 17 | sink_stream.h | 17 | sink_stream.h |
| 18 | stream.cpp | 18 | stream.cpp |
| 19 | stream.h | 19 | stream.h |
| 20 | time_stretch.cpp | ||
| 21 | time_stretch.h | ||
| 20 | 22 | ||
| 21 | $<$<BOOL:${ENABLE_CUBEB}>:cubeb_sink.cpp cubeb_sink.h> | 23 | $<$<BOOL:${ENABLE_CUBEB}>:cubeb_sink.cpp cubeb_sink.h> |
| 22 | ) | 24 | ) |
| @@ -24,6 +26,7 @@ add_library(audio_core STATIC | |||
| 24 | create_target_directory_groups(audio_core) | 26 | create_target_directory_groups(audio_core) |
| 25 | 27 | ||
| 26 | target_link_libraries(audio_core PUBLIC common core) | 28 | target_link_libraries(audio_core PUBLIC common core) |
| 29 | target_link_libraries(audio_core PRIVATE SoundTouch) | ||
| 27 | 30 | ||
| 28 | if(ENABLE_CUBEB) | 31 | if(ENABLE_CUBEB) |
| 29 | target_link_libraries(audio_core PRIVATE cubeb) | 32 | target_link_libraries(audio_core PRIVATE cubeb) |
diff --git a/src/audio_core/cubeb_sink.cpp b/src/audio_core/cubeb_sink.cpp index 5a1177d0c..79155a7a0 100644 --- a/src/audio_core/cubeb_sink.cpp +++ b/src/audio_core/cubeb_sink.cpp | |||
| @@ -3,27 +3,23 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <atomic> | ||
| 6 | #include <cstring> | 7 | #include <cstring> |
| 7 | #include <mutex> | ||
| 8 | |||
| 9 | #include "audio_core/cubeb_sink.h" | 8 | #include "audio_core/cubeb_sink.h" |
| 10 | #include "audio_core/stream.h" | 9 | #include "audio_core/stream.h" |
| 10 | #include "audio_core/time_stretch.h" | ||
| 11 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 12 | #include "common/ring_buffer.h" | ||
| 13 | #include "core/settings.h" | ||
| 12 | 14 | ||
| 13 | namespace AudioCore { | 15 | namespace AudioCore { |
| 14 | 16 | ||
| 15 | class SinkStreamImpl final : public SinkStream { | 17 | class CubebSinkStream final : public SinkStream { |
| 16 | public: | 18 | public: |
| 17 | SinkStreamImpl(cubeb* ctx, u32 sample_rate, u32 num_channels_, cubeb_devid output_device, | 19 | CubebSinkStream(cubeb* ctx, u32 sample_rate, u32 num_channels_, cubeb_devid output_device, |
| 18 | const std::string& name) | 20 | const std::string& name) |
| 19 | : ctx{ctx}, num_channels{num_channels_} { | 21 | : ctx{ctx}, num_channels{std::min(num_channels_, 2u)}, time_stretch{sample_rate, |
| 20 | 22 | num_channels} { | |
| 21 | if (num_channels == 6) { | ||
| 22 | // 6-channel audio does not seem to work with cubeb + SDL, so we downsample this to 2 | ||
| 23 | // channel for now | ||
| 24 | is_6_channel = true; | ||
| 25 | num_channels = 2; | ||
| 26 | } | ||
| 27 | 23 | ||
| 28 | cubeb_stream_params params{}; | 24 | cubeb_stream_params params{}; |
| 29 | params.rate = sample_rate; | 25 | params.rate = sample_rate; |
| @@ -38,7 +34,7 @@ public: | |||
| 38 | 34 | ||
| 39 | if (cubeb_stream_init(ctx, &stream_backend, name.c_str(), nullptr, nullptr, output_device, | 35 | if (cubeb_stream_init(ctx, &stream_backend, name.c_str(), nullptr, nullptr, output_device, |
| 40 | ¶ms, std::max(512u, minimum_latency), | 36 | ¶ms, std::max(512u, minimum_latency), |
| 41 | &SinkStreamImpl::DataCallback, &SinkStreamImpl::StateCallback, | 37 | &CubebSinkStream::DataCallback, &CubebSinkStream::StateCallback, |
| 42 | this) != CUBEB_OK) { | 38 | this) != CUBEB_OK) { |
| 43 | LOG_CRITICAL(Audio_Sink, "Error initializing cubeb stream"); | 39 | LOG_CRITICAL(Audio_Sink, "Error initializing cubeb stream"); |
| 44 | return; | 40 | return; |
| @@ -50,7 +46,7 @@ public: | |||
| 50 | } | 46 | } |
| 51 | } | 47 | } |
| 52 | 48 | ||
| 53 | ~SinkStreamImpl() { | 49 | ~CubebSinkStream() { |
| 54 | if (!ctx) { | 50 | if (!ctx) { |
| 55 | return; | 51 | return; |
| 56 | } | 52 | } |
| @@ -62,27 +58,32 @@ public: | |||
| 62 | cubeb_stream_destroy(stream_backend); | 58 | cubeb_stream_destroy(stream_backend); |
| 63 | } | 59 | } |
| 64 | 60 | ||
| 65 | void EnqueueSamples(u32 num_channels, const std::vector<s16>& samples) override { | 61 | void EnqueueSamples(u32 source_num_channels, const std::vector<s16>& samples) override { |
| 66 | if (!ctx) { | 62 | if (source_num_channels > num_channels) { |
| 63 | // Downsample 6 channels to 2 | ||
| 64 | std::vector<s16> buf; | ||
| 65 | buf.reserve(samples.size() * num_channels / source_num_channels); | ||
| 66 | for (size_t i = 0; i < samples.size(); i += source_num_channels) { | ||
| 67 | for (size_t ch = 0; ch < num_channels; ch++) { | ||
| 68 | buf.push_back(samples[i + ch]); | ||
| 69 | } | ||
| 70 | } | ||
| 71 | queue.Push(buf); | ||
| 67 | return; | 72 | return; |
| 68 | } | 73 | } |
| 69 | 74 | ||
| 70 | std::lock_guard lock{queue_mutex}; | 75 | queue.Push(samples); |
| 76 | } | ||
| 71 | 77 | ||
| 72 | queue.reserve(queue.size() + samples.size() * GetNumChannels()); | 78 | size_t SamplesInQueue(u32 num_channels) const override { |
| 79 | if (!ctx) | ||
| 80 | return 0; | ||
| 73 | 81 | ||
| 74 | if (is_6_channel) { | 82 | return queue.Size() / num_channels; |
| 75 | // Downsample 6 channels to 2 | 83 | } |
| 76 | const size_t sample_count_copy_size = samples.size() * 2; | 84 | |
| 77 | queue.reserve(sample_count_copy_size); | 85 | void Flush() override { |
| 78 | for (size_t i = 0; i < samples.size(); i += num_channels) { | 86 | should_flush = true; |
| 79 | queue.push_back(samples[i]); | ||
| 80 | queue.push_back(samples[i + 1]); | ||
| 81 | } | ||
| 82 | } else { | ||
| 83 | // Copy as-is | ||
| 84 | std::copy(samples.begin(), samples.end(), std::back_inserter(queue)); | ||
| 85 | } | ||
| 86 | } | 87 | } |
| 87 | 88 | ||
| 88 | u32 GetNumChannels() const { | 89 | u32 GetNumChannels() const { |
| @@ -95,10 +96,11 @@ private: | |||
| 95 | cubeb* ctx{}; | 96 | cubeb* ctx{}; |
| 96 | cubeb_stream* stream_backend{}; | 97 | cubeb_stream* stream_backend{}; |
| 97 | u32 num_channels{}; | 98 | u32 num_channels{}; |
| 98 | bool is_6_channel{}; | ||
| 99 | 99 | ||
| 100 | std::mutex queue_mutex; | 100 | Common::RingBuffer<s16, 0x10000> queue; |
| 101 | std::vector<s16> queue; | 101 | std::array<s16, 2> last_frame; |
| 102 | std::atomic<bool> should_flush{}; | ||
| 103 | TimeStretcher time_stretch; | ||
| 102 | 104 | ||
| 103 | static long DataCallback(cubeb_stream* stream, void* user_data, const void* input_buffer, | 105 | static long DataCallback(cubeb_stream* stream, void* user_data, const void* input_buffer, |
| 104 | void* output_buffer, long num_frames); | 106 | void* output_buffer, long num_frames); |
| @@ -144,38 +146,52 @@ CubebSink::~CubebSink() { | |||
| 144 | SinkStream& CubebSink::AcquireSinkStream(u32 sample_rate, u32 num_channels, | 146 | SinkStream& CubebSink::AcquireSinkStream(u32 sample_rate, u32 num_channels, |
| 145 | const std::string& name) { | 147 | const std::string& name) { |
| 146 | sink_streams.push_back( | 148 | sink_streams.push_back( |
| 147 | std::make_unique<SinkStreamImpl>(ctx, sample_rate, num_channels, output_device, name)); | 149 | std::make_unique<CubebSinkStream>(ctx, sample_rate, num_channels, output_device, name)); |
| 148 | return *sink_streams.back(); | 150 | return *sink_streams.back(); |
| 149 | } | 151 | } |
| 150 | 152 | ||
| 151 | long SinkStreamImpl::DataCallback(cubeb_stream* stream, void* user_data, const void* input_buffer, | 153 | long CubebSinkStream::DataCallback(cubeb_stream* stream, void* user_data, const void* input_buffer, |
| 152 | void* output_buffer, long num_frames) { | 154 | void* output_buffer, long num_frames) { |
| 153 | SinkStreamImpl* impl = static_cast<SinkStreamImpl*>(user_data); | 155 | CubebSinkStream* impl = static_cast<CubebSinkStream*>(user_data); |
| 154 | u8* buffer = reinterpret_cast<u8*>(output_buffer); | 156 | u8* buffer = reinterpret_cast<u8*>(output_buffer); |
| 155 | 157 | ||
| 156 | if (!impl) { | 158 | if (!impl) { |
| 157 | return {}; | 159 | return {}; |
| 158 | } | 160 | } |
| 159 | 161 | ||
| 160 | std::lock_guard lock{impl->queue_mutex}; | 162 | const size_t num_channels = impl->GetNumChannels(); |
| 163 | const size_t samples_to_write = num_channels * num_frames; | ||
| 164 | size_t samples_written; | ||
| 165 | |||
| 166 | if (Settings::values.enable_audio_stretching) { | ||
| 167 | const std::vector<s16> in{impl->queue.Pop()}; | ||
| 168 | const size_t num_in{in.size() / num_channels}; | ||
| 169 | s16* const out{reinterpret_cast<s16*>(buffer)}; | ||
| 170 | const size_t out_frames = impl->time_stretch.Process(in.data(), num_in, out, num_frames); | ||
| 171 | samples_written = out_frames * num_channels; | ||
| 161 | 172 | ||
| 162 | const size_t frames_to_write{ | 173 | if (impl->should_flush) { |
| 163 | std::min(impl->queue.size() / impl->GetNumChannels(), static_cast<size_t>(num_frames))}; | 174 | impl->time_stretch.Flush(); |
| 175 | impl->should_flush = false; | ||
| 176 | } | ||
| 177 | } else { | ||
| 178 | samples_written = impl->queue.Pop(buffer, samples_to_write); | ||
| 179 | } | ||
| 164 | 180 | ||
| 165 | memcpy(buffer, impl->queue.data(), frames_to_write * sizeof(s16) * impl->GetNumChannels()); | 181 | if (samples_written >= num_channels) { |
| 166 | impl->queue.erase(impl->queue.begin(), | 182 | std::memcpy(&impl->last_frame[0], buffer + (samples_written - num_channels) * sizeof(s16), |
| 167 | impl->queue.begin() + frames_to_write * impl->GetNumChannels()); | 183 | num_channels * sizeof(s16)); |
| 184 | } | ||
| 168 | 185 | ||
| 169 | if (frames_to_write < num_frames) { | 186 | // Fill the rest of the frames with last_frame |
| 170 | // Fill the rest of the frames with silence | 187 | for (size_t i = samples_written; i < samples_to_write; i += num_channels) { |
| 171 | memset(buffer + frames_to_write * sizeof(s16) * impl->GetNumChannels(), 0, | 188 | std::memcpy(buffer + i * sizeof(s16), &impl->last_frame[0], num_channels * sizeof(s16)); |
| 172 | (num_frames - frames_to_write) * sizeof(s16) * impl->GetNumChannels()); | ||
| 173 | } | 189 | } |
| 174 | 190 | ||
| 175 | return num_frames; | 191 | return num_frames; |
| 176 | } | 192 | } |
| 177 | 193 | ||
| 178 | void SinkStreamImpl::StateCallback(cubeb_stream* stream, void* user_data, cubeb_state state) {} | 194 | void CubebSinkStream::StateCallback(cubeb_stream* stream, void* user_data, cubeb_state state) {} |
| 179 | 195 | ||
| 180 | std::vector<std::string> ListCubebSinkDevices() { | 196 | std::vector<std::string> ListCubebSinkDevices() { |
| 181 | std::vector<std::string> device_list; | 197 | std::vector<std::string> device_list; |
diff --git a/src/audio_core/null_sink.h b/src/audio_core/null_sink.h index f235d93e5..2ed0c83b6 100644 --- a/src/audio_core/null_sink.h +++ b/src/audio_core/null_sink.h | |||
| @@ -21,6 +21,12 @@ public: | |||
| 21 | private: | 21 | private: |
| 22 | struct NullSinkStreamImpl final : SinkStream { | 22 | struct NullSinkStreamImpl final : SinkStream { |
| 23 | void EnqueueSamples(u32 /*num_channels*/, const std::vector<s16>& /*samples*/) override {} | 23 | void EnqueueSamples(u32 /*num_channels*/, const std::vector<s16>& /*samples*/) override {} |
| 24 | |||
| 25 | size_t SamplesInQueue(u32 /*num_channels*/) const override { | ||
| 26 | return 0; | ||
| 27 | } | ||
| 28 | |||
| 29 | void Flush() override {} | ||
| 24 | } null_sink_stream; | 30 | } null_sink_stream; |
| 25 | }; | 31 | }; |
| 26 | 32 | ||
diff --git a/src/audio_core/sink_stream.h b/src/audio_core/sink_stream.h index 41b6736d8..4309ad094 100644 --- a/src/audio_core/sink_stream.h +++ b/src/audio_core/sink_stream.h | |||
| @@ -25,6 +25,10 @@ public: | |||
| 25 | * @param samples Samples in interleaved stereo PCM16 format. | 25 | * @param samples Samples in interleaved stereo PCM16 format. |
| 26 | */ | 26 | */ |
| 27 | virtual void EnqueueSamples(u32 num_channels, const std::vector<s16>& samples) = 0; | 27 | virtual void EnqueueSamples(u32 num_channels, const std::vector<s16>& samples) = 0; |
| 28 | |||
| 29 | virtual std::size_t SamplesInQueue(u32 num_channels) const = 0; | ||
| 30 | |||
| 31 | virtual void Flush() = 0; | ||
| 28 | }; | 32 | }; |
| 29 | 33 | ||
| 30 | using SinkStreamPtr = std::unique_ptr<SinkStream>; | 34 | using SinkStreamPtr = std::unique_ptr<SinkStream>; |
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index dbae75d8c..84dcdd98d 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp | |||
| @@ -73,6 +73,7 @@ static void VolumeAdjustSamples(std::vector<s16>& samples) { | |||
| 73 | void Stream::PlayNextBuffer() { | 73 | void Stream::PlayNextBuffer() { |
| 74 | if (!IsPlaying()) { | 74 | if (!IsPlaying()) { |
| 75 | // Ensure we are in playing state before playing the next buffer | 75 | // Ensure we are in playing state before playing the next buffer |
| 76 | sink_stream.Flush(); | ||
| 76 | return; | 77 | return; |
| 77 | } | 78 | } |
| 78 | 79 | ||
| @@ -83,6 +84,7 @@ void Stream::PlayNextBuffer() { | |||
| 83 | 84 | ||
| 84 | if (queued_buffers.empty()) { | 85 | if (queued_buffers.empty()) { |
| 85 | // No queued buffers - we are effectively paused | 86 | // No queued buffers - we are effectively paused |
| 87 | sink_stream.Flush(); | ||
| 86 | return; | 88 | return; |
| 87 | } | 89 | } |
| 88 | 90 | ||
| @@ -90,6 +92,7 @@ void Stream::PlayNextBuffer() { | |||
| 90 | queued_buffers.pop(); | 92 | queued_buffers.pop(); |
| 91 | 93 | ||
| 92 | VolumeAdjustSamples(active_buffer->Samples()); | 94 | VolumeAdjustSamples(active_buffer->Samples()); |
| 95 | |||
| 93 | sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples()); | 96 | sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples()); |
| 94 | 97 | ||
| 95 | CoreTiming::ScheduleEventThreadsafe(GetBufferReleaseCycles(*active_buffer), release_event, {}); | 98 | CoreTiming::ScheduleEventThreadsafe(GetBufferReleaseCycles(*active_buffer), release_event, {}); |
diff --git a/src/audio_core/time_stretch.cpp b/src/audio_core/time_stretch.cpp new file mode 100644 index 000000000..da094c46b --- /dev/null +++ b/src/audio_core/time_stretch.cpp | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | // Copyright 2018 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | #include <cmath> | ||
| 7 | #include <cstddef> | ||
| 8 | #include "audio_core/time_stretch.h" | ||
| 9 | #include "common/logging/log.h" | ||
| 10 | |||
| 11 | namespace AudioCore { | ||
| 12 | |||
| 13 | TimeStretcher::TimeStretcher(u32 sample_rate, u32 channel_count) | ||
| 14 | : m_sample_rate(sample_rate), m_channel_count(channel_count) { | ||
| 15 | m_sound_touch.setChannels(channel_count); | ||
| 16 | m_sound_touch.setSampleRate(sample_rate); | ||
| 17 | m_sound_touch.setPitch(1.0); | ||
| 18 | m_sound_touch.setTempo(1.0); | ||
| 19 | } | ||
| 20 | |||
| 21 | void TimeStretcher::Clear() { | ||
| 22 | m_sound_touch.clear(); | ||
| 23 | } | ||
| 24 | |||
| 25 | void TimeStretcher::Flush() { | ||
| 26 | m_sound_touch.flush(); | ||
| 27 | } | ||
| 28 | |||
| 29 | size_t TimeStretcher::Process(const s16* in, size_t num_in, s16* out, size_t num_out) { | ||
| 30 | const double time_delta = static_cast<double>(num_out) / m_sample_rate; // seconds | ||
| 31 | |||
| 32 | // We were given actual_samples number of samples, and num_samples were requested from us. | ||
| 33 | double current_ratio = static_cast<double>(num_in) / static_cast<double>(num_out); | ||
| 34 | |||
| 35 | const double max_latency = 1.0; // seconds | ||
| 36 | const double max_backlog = m_sample_rate * max_latency; | ||
| 37 | const double backlog_fullness = m_sound_touch.numSamples() / max_backlog; | ||
| 38 | if (backlog_fullness > 5.0) { | ||
| 39 | // Too many samples in backlog: Don't push anymore on | ||
| 40 | num_in = 0; | ||
| 41 | } | ||
| 42 | |||
| 43 | // We ideally want the backlog to be about 50% full. | ||
| 44 | // This gives some headroom both ways to prevent underflow and overflow. | ||
| 45 | // We tweak current_ratio to encourage this. | ||
| 46 | constexpr double tweak_time_scale = 0.05; // seconds | ||
| 47 | const double tweak_correction = (backlog_fullness - 0.5) * (time_delta / tweak_time_scale); | ||
| 48 | current_ratio *= std::pow(1.0 + 2.0 * tweak_correction, tweak_correction < 0 ? 3.0 : 1.0); | ||
| 49 | |||
| 50 | // This low-pass filter smoothes out variance in the calculated stretch ratio. | ||
| 51 | // The time-scale determines how responsive this filter is. | ||
| 52 | constexpr double lpf_time_scale = 2.0; // seconds | ||
| 53 | const double lpf_gain = 1.0 - std::exp(-time_delta / lpf_time_scale); | ||
| 54 | m_stretch_ratio += lpf_gain * (current_ratio - m_stretch_ratio); | ||
| 55 | |||
| 56 | // Place a lower limit of 5% speed. When a game boots up, there will be | ||
| 57 | // many silence samples. These do not need to be timestretched. | ||
| 58 | m_stretch_ratio = std::max(m_stretch_ratio, 0.05); | ||
| 59 | m_sound_touch.setTempo(m_stretch_ratio); | ||
| 60 | |||
| 61 | LOG_DEBUG(Audio, "{:5}/{:5} ratio:{:0.6f} backlog:{:0.6f}", num_in, num_out, m_stretch_ratio, | ||
| 62 | backlog_fullness); | ||
| 63 | |||
| 64 | m_sound_touch.putSamples(in, num_in); | ||
| 65 | return m_sound_touch.receiveSamples(out, num_out); | ||
| 66 | } | ||
| 67 | |||
| 68 | } // namespace AudioCore | ||
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 @@ | |||
| 1 | // Copyright 2018 yuzu 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 <SoundTouch.h> | ||
| 10 | #include "common/common_types.h" | ||
| 11 | |||
| 12 | namespace AudioCore { | ||
| 13 | |||
| 14 | class TimeStretcher { | ||
| 15 | public: | ||
| 16 | TimeStretcher(u32 sample_rate, u32 channel_count); | ||
| 17 | |||
| 18 | /// @param in Input sample buffer | ||
| 19 | /// @param num_in Number of input frames in `in` | ||
| 20 | /// @param out Output sample buffer | ||
| 21 | /// @param num_out Desired number of output frames in `out` | ||
| 22 | /// @returns Actual number of frames written to `out` | ||
| 23 | size_t Process(const s16* in, size_t num_in, s16* out, size_t num_out); | ||
| 24 | |||
| 25 | void Clear(); | ||
| 26 | |||
| 27 | void Flush(); | ||
| 28 | |||
| 29 | private: | ||
| 30 | u32 m_sample_rate; | ||
| 31 | u32 m_channel_count; | ||
| 32 | soundtouch::SoundTouch m_sound_touch; | ||
| 33 | double m_stretch_ratio = 1.0; | ||
| 34 | }; | ||
| 35 | |||
| 36 | } // namespace AudioCore | ||