Is it possible to allocate new AudioInputAnalog/AudioAnalyzeFFT1024/AudioConnection instances then release them again once finished? I have a C++ class that renders a spectrum analyzer to an LED matrix using FastLED, but I only want to use that functionality a small part of the time, and release the memory otherwise.
If I have something like the following:
Code:
// class fields
AudioInputAnalog *adc1;
AudioAnalyzeFFT1024 *fft;
AudioConnection *patchCord1;
// in the class constructor:
AudioMemory(12);
adc1 = new AudioInputAnalog(A4);
fft = new AudioAnalyzeFFT1024();
patchCord1 = new AudioConnection(*adc1, *fft);
// in the class destructor:
delete patchCord1;
delete fft;
delete adc1;
I get the following warnings:
Code:
src\effect\AudioNoise.cpp:23:10: warning: deleting object of polymorphic class type 'AudioAnalyzeFFT1024' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
delete fft;
^
src\effect\AudioNoise.cpp:24:10: warning: deleting object of polymorphic class type 'AudioInputAnalog' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
delete adc1;
^
It also makes my program unstable after I have created/destroyed the class a couple of times. Is there a solution, or do I need to keep these objects around for the entire time?