Fix playback within Sample (#7100)

This revisits two main aspects of playback from `Sample`: copying frames into a temporary playback buffer before resampling, and advancing the state's frame index.  Both operations were improperly done, causing distorted audio to be heard when resampling from within the `Sample::play` function.

To fix this, playback into the temporary playback buffer is now done using the `playRaw` function, which copies the frame one by one in a loop, moving through the buffer correctly as determined by the loop mode. In addition, advancement of the playback index is done using the `advance` function, which advances the index by the given amount and handles an out of bounds index for the loop modes as necessary using the modulo operator.
This commit is contained in:
saker
2024-02-16 16:31:44 -05:00
committed by GitHub
parent c87ff4194f
commit a81ad74e3a
4 changed files with 108 additions and 96 deletions

View File

@@ -31,7 +31,7 @@
namespace lmms {
SampleBuffer::SampleBuffer(const sampleFrame* data, int numFrames, int sampleRate)
SampleBuffer::SampleBuffer(const sampleFrame* data, size_t numFrames, int sampleRate)
: m_data(data, data + numFrames)
, m_sampleRate(sampleRate)
{