Right - at the risk of talking to myself
//// OUTPUT METER
jassert(delayBuffer.getNumChannels()>0);
updateMeter(meterOne, channelOne, numSamples);
updateMeter(meterTwo, channelTwo, numSamples);
jassert(delayBuffer.getNumChannels()>0);
The top assertion passes, the bottom one fails. updateMeter() doesn’t touch delayBuffer. I’m presuming there’s a memory corruption problem.
[code]void CredlandStereo1399AudioProcessor::updateMeter (struct LevelMeterMovement::MeterStruct &m,
float * data, int samples) {
float minv = 0.0f;
float maxv = 0.0f;
if (m.peakhold <= 0)
m.peak = m.baselevel; // floor
else
m.peakhold --;
FloatVectorOperations::findMinAndMax(data, samples, minv, maxv);
if (std::isnan(maxv)) maxv = 0; // handle some seeming bug in the MinandMaxcode
if (std::isnan(minv)) minv = 0; // perhaps the data sometimes contains NANs?
minv = fabsf(minv);
maxv = fmaxf(minv, maxv);
float maxdb = 20.0f * log10f(maxv);
m.decayingPeakDB -= 0.75f; // decay
if (m.decayingPeakDB<maxdb) {
m.decayingPeakDB = maxdb;
}
if (m.decayingPeakDB<m.baselevel) {
m.decayingPeakDB = m.baselevel;
}
if (maxv >= m.peak) {
m.peak = maxv;
m.peakhold = 100;
m.peakdb = 20.0f * log10f(m.peak);
m.peakunlimiteddb = m.peakdb;
if (m.peakdb < m.baselevel) m.peakdb = m.baselevel;
}
m.currentdb = 20.0f * log10f(maxv); // technically this is maxv / peak value, only peak value is 1.
if (m.currentdb < m.baselevel) m.currentdb = m.baselevel;
m.movingAverage -= m.movingAverage/10.0f;
m.movingAverage += m.currentdb/10.0f;
m.randomsample = data[0];
// if needed copy the buffer across
m.buffersize = samples>1024 ? 1024 : samples;
FloatVectorOperations::copy(m.data, data, m.buffersize);
}[/code]