From 933508e2a2f7923cebc15d679b78933df8fb9ee5 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Thu, 3 Aug 2017 12:22:51 +0100 Subject: interpolate: Interpolate on a frame-by-frame basis --- src/audio_core/hle/source.cpp | 49 ++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) (limited to 'src/audio_core/hle/source.cpp') diff --git a/src/audio_core/hle/source.cpp b/src/audio_core/hle/source.cpp index 92484c526..de4e88cae 100644 --- a/src/audio_core/hle/source.cpp +++ b/src/audio_core/hle/source.cpp @@ -244,17 +244,27 @@ void Source::GenerateFrame() { break; } - const size_t size_to_copy = - std::min(state.current_buffer.size(), current_frame.size() - frame_position); - - std::copy(state.current_buffer.begin(), state.current_buffer.begin() + size_to_copy, - current_frame.begin() + frame_position); - state.current_buffer.erase(state.current_buffer.begin(), - state.current_buffer.begin() + size_to_copy); - - frame_position += size_to_copy; - state.next_sample_number += static_cast(size_to_copy); + switch (state.interpolation_mode) { + case InterpolationMode::None: + AudioInterp::None(state.interp_state, state.current_buffer, state.rate_multiplier, + current_frame, frame_position); + break; + case InterpolationMode::Linear: + AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier, + current_frame, frame_position); + break; + case InterpolationMode::Polyphase: + // TODO(merry): Implement polyphase interpolation + LOG_DEBUG(Audio_DSP, "Polyphase interpolation unimplemented; falling back to linear"); + AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier, + current_frame, frame_position); + break; + default: + UNIMPLEMENTED(); + break; + } } + state.next_sample_number += frame_position; state.filters.ProcessFrame(current_frame); } @@ -305,25 +315,6 @@ bool Source::DequeueBuffer() { return true; } - switch (state.interpolation_mode) { - case InterpolationMode::None: - state.current_buffer = - AudioInterp::None(state.interp_state, state.current_buffer, state.rate_multiplier); - break; - case InterpolationMode::Linear: - state.current_buffer = - AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier); - break; - case InterpolationMode::Polyphase: - // TODO(merry): Implement polyphase interpolation - state.current_buffer = - AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier); - break; - default: - UNIMPLEMENTED(); - break; - } - // the first playthrough starts at play_position, loops start at the beginning of the buffer state.current_sample_number = (!buf.has_played) ? buf.play_position : 0; state.next_sample_number = state.current_sample_number; -- cgit v1.2.3