AuVal: 192khz memory allocation problem?

I’ve just started developing a plugin with Juce. It works great in AU Lab. However when i run it through AUVAL it crashes on the 192khz test.

Specifically it appears that an AudioSampleBuffer is failing to initialise (memory problem?).

I’m setting it up in the constructor like this:

CredlandStereo1399AudioProcessor::CredlandStereo1399AudioProcessor()
: erBuffer(2, 10000), delayBuffer(2, 20000), delayPointer(0)

I may be doing something stupid … it’s my first C++ in 15 years, and my first AU plugin. Suggestions wise people?

Okay - let me expand on that. Perhaps it isn’t a memory allocation problem.

The specific problem is that delayBuffer.getNumChannels() starts to return 0.

Which looks like it shouldn’t be possible. The constructor for AudioSampleBuffer has:

[code]AudioSampleBuffer::AudioSampleBuffer (const int numChannels_,
const int numSamples) noexcept
: numChannels (numChannels_),
size (numSamples)
{
jassert (numSamples >= 0);
jassert (numChannels_ > 0);

allocateData();

}[/code]

Arrrgh :slight_smile:

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]

I’m a moron. Pretend this thread didn’t exist. Memory corruption caused by developer failure.

for (i =0; i< twice the size of my buffer; i++) …