snapshot
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
## FFT
|
||||
|
||||
I found some cheap [AI Thinker ESP32 Audio Kit V2.2](https://docs.ai-thinker.com/en/esp32-audio-kit) on AliExpress and because I was tired of all the wires I had to connect to implement my different scenarios that are possible with my [Arduino Audio Tools Library](https://github.com/pschatzmann/arduino-audio-tools), I thought it to be a good idea to buy this board.
|
||||
|
||||
<img src="https://pschatzmann.github.io/Resources/img/audio-toolkit.png" alt="Audio Kit" />
|
||||
|
||||
You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies
|
||||
|
||||
The fast Fourier transform (FFT) can be used to determine the frequencies of a singal. More [details can be found in the Wiki](https://github.com/pschatzmann/arduino-audio-tools/wiki/FFT)
|
||||
|
||||
### Note
|
||||
|
||||
The log level has been set to Info to help you to identify any problems. Please change it to AudioLogger::Warning to get the best sound quality!
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
You need to install the following libraries:
|
||||
|
||||
- https://github.com/pschatzmann/arduino-audio-tools
|
||||
- https://github.com/pschatzmann/arduino-audio-driver
|
||||
@@ -0,0 +1,53 @@
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "AudioTools/AudioLibs/AudioRealFFT.h" // or AudioKissFFT
|
||||
|
||||
AudioBoardStream kit(AudioKitEs8388V1); // 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);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// setup Audiokit
|
||||
auto cfg = kit.defaultConfig(RX_MODE);
|
||||
cfg.input_device = 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);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
Reference in New Issue
Block a user