Browse Source

Fixed a problem when reading mono audio formats.

tags/2021-05-28
jules 14 years ago
parent
commit
ba2287033c
1 changed files with 9 additions and 8 deletions
  1. +9
    -8
      modules/juce_audio_formats/format/juce_AudioFormatReader.cpp

+ 9
- 8
modules/juce_audio_formats/format/juce_AudioFormatReader.cpp View File

@@ -117,12 +117,13 @@ void AudioFormatReader::read (AudioSampleBuffer* buffer,
if (numSamples > 0)
{
const int numTargetChannels = buffer->getNumChannels();
int* chans[3];
if (useReaderLeftChan == useReaderRightChan)
{
chans[0] = reinterpret_cast<int*> (buffer->getSampleData (0, startSample));
chans[1] = (numChannels > 1 && buffer->getNumChannels() > 1) ? reinterpret_cast<int*> (buffer->getSampleData (1, startSample)) : nullptr;
chans[1] = (numChannels > 1 && numTargetChannels > 1) ? reinterpret_cast<int*> (buffer->getSampleData (1, startSample)) : nullptr;
}
else if (useReaderLeftChan || (numChannels == 1))
{
@@ -155,7 +156,7 @@ void AudioFormatReader::read (AudioSampleBuffer* buffer,
}
}
if (numChannels > 1 && (chans[0] == nullptr || chans[1] == nullptr))
if (numTargetChannels > 1 && (chans[0] == nullptr || chans[1] == nullptr))
{
// if this is a stereo buffer and the source was mono, dupe the first channel..
memcpy (buffer->getSampleData (1, startSample),
@@ -221,9 +222,9 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile,
rmin = lmin;
}
lowestLeft = lmin;
highestLeft = lmax;
lowestRight = rmin;
lowestLeft = lmin;
highestLeft = lmax;
lowestRight = rmin;
highestRight = rmax;
}
else
@@ -266,9 +267,9 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile,
rmin = lmin;
}
lowestLeft = lmin / (float) std::numeric_limits<int>::max();
highestLeft = lmax / (float) std::numeric_limits<int>::max();
lowestRight = rmin / (float) std::numeric_limits<int>::max();
lowestLeft = lmin / (float) std::numeric_limits<int>::max();
highestLeft = lmax / (float) std::numeric_limits<int>::max();
lowestRight = rmin / (float) std::numeric_limits<int>::max();
highestRight = rmax / (float) std::numeric_limits<int>::max();
}
}


Loading…
Cancel
Save