diff options
Diffstat (limited to 'src/audio_core/hle/source.cpp')
| -rw-r--r-- | src/audio_core/hle/source.cpp | 49 |
1 files changed, 20 insertions, 29 deletions
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() { | |||
| 244 | break; | 244 | break; |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | const size_t size_to_copy = | 247 | switch (state.interpolation_mode) { |
| 248 | std::min(state.current_buffer.size(), current_frame.size() - frame_position); | 248 | case InterpolationMode::None: |
| 249 | 249 | AudioInterp::None(state.interp_state, state.current_buffer, state.rate_multiplier, | |
| 250 | std::copy(state.current_buffer.begin(), state.current_buffer.begin() + size_to_copy, | 250 | current_frame, frame_position); |
| 251 | current_frame.begin() + frame_position); | 251 | break; |
| 252 | state.current_buffer.erase(state.current_buffer.begin(), | 252 | case InterpolationMode::Linear: |
| 253 | state.current_buffer.begin() + size_to_copy); | 253 | AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier, |
| 254 | 254 | current_frame, frame_position); | |
| 255 | frame_position += size_to_copy; | 255 | break; |
| 256 | state.next_sample_number += static_cast<u32>(size_to_copy); | 256 | case InterpolationMode::Polyphase: |
| 257 | // TODO(merry): Implement polyphase interpolation | ||
| 258 | LOG_DEBUG(Audio_DSP, "Polyphase interpolation unimplemented; falling back to linear"); | ||
| 259 | AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier, | ||
| 260 | current_frame, frame_position); | ||
| 261 | break; | ||
| 262 | default: | ||
| 263 | UNIMPLEMENTED(); | ||
| 264 | break; | ||
| 265 | } | ||
| 257 | } | 266 | } |
| 267 | state.next_sample_number += frame_position; | ||
| 258 | 268 | ||
| 259 | state.filters.ProcessFrame(current_frame); | 269 | state.filters.ProcessFrame(current_frame); |
| 260 | } | 270 | } |
| @@ -305,25 +315,6 @@ bool Source::DequeueBuffer() { | |||
| 305 | return true; | 315 | return true; |
| 306 | } | 316 | } |
| 307 | 317 | ||
| 308 | switch (state.interpolation_mode) { | ||
| 309 | case InterpolationMode::None: | ||
| 310 | state.current_buffer = | ||
| 311 | AudioInterp::None(state.interp_state, state.current_buffer, state.rate_multiplier); | ||
| 312 | break; | ||
| 313 | case InterpolationMode::Linear: | ||
| 314 | state.current_buffer = | ||
| 315 | AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier); | ||
| 316 | break; | ||
| 317 | case InterpolationMode::Polyphase: | ||
| 318 | // TODO(merry): Implement polyphase interpolation | ||
| 319 | state.current_buffer = | ||
| 320 | AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier); | ||
| 321 | break; | ||
| 322 | default: | ||
| 323 | UNIMPLEMENTED(); | ||
| 324 | break; | ||
| 325 | } | ||
| 326 | |||
| 327 | // the first playthrough starts at play_position, loops start at the beginning of the buffer | 318 | // the first playthrough starts at play_position, loops start at the beginning of the buffer |
| 328 | state.current_sample_number = (!buf.has_played) ? buf.play_position : 0; | 319 | state.current_sample_number = (!buf.has_played) ? buf.play_position : 0; |
| 329 | state.next_sample_number = state.current_sample_number; | 320 | state.next_sample_number = state.current_sample_number; |