start/stoping AnalogAudioStream and AudioRealFFT #755
-
Hello, void setupFFT(int sr) { void StartFFT(int sr) { void StopFFT() { void setupGeneralAdc(int pin) { void StartAdc() { void StopAdc() { |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
You would need to figure out why it is crashing: analyse the stacktrace ! Are you sure that you do not write any data to the closed fft ? |
Beta Was this translation helpful? Give feedback.
-
Analyzing the crashdump exeeds my capabilities.
I use AudioRealFFT
It would already be a help when you could confirm how to properly start/stop AudioStreams and fft. I’m not sure if the ..end() method is the right way to do. E.g. if ..end() destroys all objects and allows me to create new ones during runtime
… On 6 Apr 2023, at 18:05, Phil Schatzmann ***@***.***> wrote:
You would need to figure out why it is crashing: analyse the stacktrace !
You did not mention which of the many FFT implementation you were selecting...
—
Reply to this email directly, view it on GitHub <#755 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AOWLL6QNNKIPVEHS2LCBE4LW73SU3ANCNFSM6AAAAAAWVTAXNQ>.
You are receiving this because you authored the thread.
|
Beta Was this translation helpful? Give feedback.
-
I was just running a test and for me this is working w/o any issues. Are you sure that you installed the latest version when I told you that I have committed a correction ? Here is my test case: #include "AudioTools.h"
#include "AudioLibs/AudioKit.h"
#include "AudioLibs/AudioRealFFT.h" // or AudioKissFFT
AudioKitStream kit; // Audio source
AudioRealFFT fft; // or AudioKissFFT
StreamCopy copier(fft, kit); // copy mic to tfl
int channels = 2;
int samples_per_second = 44100;
int bits_per_sample = 16;
float value=0;
// display fft result
void fftResult(AudioFFTBase &fft){
float diff;
auto result = fft.result();
if (result.magnitude>100){
Serial.print(result.frequency);
Serial.print(" ");
Serial.print(result.magnitude);
Serial.print(" => ");
Serial.print(result.frequencyAsNote(diff));
Serial.print( " diff: ");
Serial.println(diff);
}
}
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
// setup Audiokit
auto cfg = kit.defaultConfig(RX_MODE);
cfg.input_device = AUDIO_HAL_ADC_INPUT_LINE2;
cfg.channels = channels;
cfg.sample_rate = samples_per_second;
cfg.bits_per_sample = bits_per_sample;
kit.begin(cfg);
// Setup FFT
auto tcfg = fft.defaultConfig();
tcfg.length = 8192;
tcfg.channels = channels;
tcfg.sample_rate = samples_per_second;
tcfg.bits_per_sample = bits_per_sample;
tcfg.callback = &fftResult;
fft.begin(tcfg);
copier.copyN(100);
fft.end();
fft.begin(tcfg);
}
void loop() {
copier.copy();
} |
Beta Was this translation helpful? Give feedback.
-
Yes, start() allocates memory both for the input & result array on the heap and calls the fft specific initialisation and end() is releasing it again. |
Beta Was this translation helpful? Give feedback.
-
There were some changes and I might not have updated the examples: |
Beta Was this translation helpful? Give feedback.
I committed a correction that might help.
I did not reset the pointers to null so when the FFT object was created after calling end the necessary arrays and objects were not allocated any more...