Why this crash?

Shifting things about in my synth, and is trying to do stuff in a temporary buffer instead of the main output buffer.

This works very well:

[code] if (!accumulateOutput){
output.clear();
}

synt1->doProcess(output);

[/code]

This crashes like a driftwood sculpture thrown from a trebuchet:

    int numSamples = output.getNumSamples();

    AudioSampleBuffer * tmpBuf = new AudioSampleBuffer(2, numSamples);

    synt1->doProcess(*tmpBuf);

    if (!accumulateOutput){
        output.clear();
    }

    output = *tmpBuf;

actually you can’t change the output buffer like this. do your process as you would, but instead of copying the pointers (unsafe cause the output buffer is managed by the host, and here you are loosing a block of allocated memory) just copy your buffer over the output one doing a for loop (or using AudioSampleBuffer copy methods). don’t mess too much with memory in the audioprocess function, try creating your buffer outside it (like in prepareToPlay)…

I thought = was overloaded to do that copying?

The allocation is actually in the constructor, I just put it there temporarily for clarity.

Anyway, I replaced it with:

    output.addFrom(0, 0, *tmpBuf, 0, 0, numSamples, 0.5f);
    output.addFrom(1, 0, *tmpBuf, 1, 0, numSamples, 0.5f);

Which compiles and everything, but now I am getting distorted noises evertime I move the mouse over a GUI component!!

Sooooo… big time memory fuxxor somewhere. Are there somekind of tool for scanning for such things?
I am going to rebuild JUCE in debug to see if it does anything. Maybe this isn’t my boo boo.

edit> Fucketty. It appears vc 2003 toolkit doesn’t include the debug libs. I guess I’ll have to take a look at that express thingmabob.

edit2 > installing VC Express is much like I would imagine what it’s like to be felt up in the subway. The registration requires submitting a stool sample and naked pictures of your wife. The debug libs did not do anything for spotting the memory problems, and the compiler outputs a synth that is twice as big, but half as fast as my previous builds. All in all a pretty bad move.