mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-05 03:50:07 +00:00
Fix for AudioFormatReader::read not filling extra channels when reading beyond the start of the source file.
This commit is contained in:
parent
4ac7b41779
commit
b8db6defb7
1 changed files with 4 additions and 3 deletions
|
|
@ -46,6 +46,7 @@ bool AudioFormatReader::read (int* const* destSamples,
|
|||
{
|
||||
jassert (numDestChannels > 0); // you have to actually give this some channels to work with!
|
||||
|
||||
const size_t originalNumSamplesToRead = (size_t) numSamplesToRead;
|
||||
int startOffsetInDestBuffer = 0;
|
||||
|
||||
if (startSampleInSource < 0)
|
||||
|
|
@ -64,7 +65,7 @@ bool AudioFormatReader::read (int* const* destSamples,
|
|||
if (numSamplesToRead <= 0)
|
||||
return true;
|
||||
|
||||
if (! readSamples (const_cast <int**> (destSamples),
|
||||
if (! readSamples (const_cast<int**> (destSamples),
|
||||
jmin ((int) numChannels, numDestChannels), startOffsetInDestBuffer,
|
||||
startSampleInSource, numSamplesToRead))
|
||||
return false;
|
||||
|
|
@ -87,13 +88,13 @@ bool AudioFormatReader::read (int* const* destSamples,
|
|||
if (lastFullChannel != nullptr)
|
||||
for (int i = (int) numChannels; i < numDestChannels; ++i)
|
||||
if (destSamples[i] != nullptr)
|
||||
memcpy (destSamples[i], lastFullChannel, sizeof (int) * (size_t) numSamplesToRead);
|
||||
memcpy (destSamples[i], lastFullChannel, sizeof (int) * originalNumSamplesToRead);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = (int) numChannels; i < numDestChannels; ++i)
|
||||
if (destSamples[i] != nullptr)
|
||||
zeromem (destSamples[i], sizeof (int) * (size_t) numSamplesToRead);
|
||||
zeromem (destSamples[i], sizeof (int) * originalNumSamplesToRead);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue