Eliminate assert condition by reading # sample elements that are multiple of num-of-channels

This commit is contained in:
Olli 2018-10-28 15:49:50 +02:00
parent a1c400eb2c
commit 59129fa33d

View File

@ -229,7 +229,7 @@ static void detectBPM(WavInFile *inFile, RunParameters *params)
fflush(stderr); fflush(stderr);
nChannels = (int)inFile->getNumChannels(); nChannels = (int)inFile->getNumChannels();
assert(BUFF_SIZE % nChannels == 0); int readSize = BUFF_SIZE - BUFF_SIZE % nChannels; // round read size down to multiple of num.channels
// Process the 'inFile' in small blocks, repeat until whole file has // Process the 'inFile' in small blocks, repeat until whole file has
// been processed // been processed
@ -238,7 +238,7 @@ static void detectBPM(WavInFile *inFile, RunParameters *params)
int num, samples; int num, samples;
// Read sample data from input file // Read sample data from input file
num = inFile->read(sampleBuffer, BUFF_SIZE); num = inFile->read(sampleBuffer, readSize);
// Enter the new samples to the bpm analyzer class // Enter the new samples to the bpm analyzer class
samples = num / nChannels; samples = num / nChannels;