I’m pretty new to JUCE and also just learning c++ so I apologize if this is a simple question or if it has been answered already. I searched and didn’t see it but it’s probably because it’s obvious to everyone but me.
So, I see that in this discussion of threading, it’s mentioned that you want to make sure that memory is neither allocated nor deleted on the audio thread. In the openButtonClicked() function this is called
ReferenceCountedBuffer::Ptr newBuffer = new ReferenceCountedBuffer (file.getFileName(),
reader->numChannels,
reader->lengthInSamples);
and in getNextAudioBlock(…) the following is called
ReferenceCountedBuffer::Ptr retainedCurrentBuffer (currentBuffer)
Why does one need to use the new keyword and the other doesn’t?
I think it is because in the first call, which runs on the message thread, you’re actually initializing a new buffer from the audio file whereas in the second one you’re only creating a pointer to the pre-existing buffer, currentBuffer, is that correct?