void Source::GenerateFrame() { current_frame.fill({}); if (state.current_buffer.empty() && !DequeueBuffer()) { state.enabled = false; state.buffer_update = true; state.current_buffer_id = 0; return; } size_t frame_position = 0; state.current_sample_number = state.next_sample_number; while (frame_position < current_frame.size()) { if (state.current_buffer.empty() && !DequeueBuffer()) { 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<u32>(size_to_copy); } state.filters.ProcessFrame(current_frame); }
void Source::GenerateFrame() { current_frame.fill({}); if (state.current_buffer.empty() && !DequeueBuffer()) { state.enabled = false; state.buffer_update = true; state.current_buffer_id = 0; return; } size_t frame_position = 0; state.current_sample_number = state.next_sample_number; while (frame_position < current_frame.size()) { if (state.current_buffer.empty() && !DequeueBuffer()) { break; } 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 += static_cast<u32>(frame_position); state.filters.ProcessFrame(current_frame); }