8#ifndef AUDIO_ANALYSIS_H
9#define AUDIO_ANALYSIS_H
11#define INIT_PRISM(M) \
12 M.setWindowSize(SAMPLES); \
13 M.setSampleRate(SAMPLING_FREQUENCY); \
14 M.setSpectrogram(&fftHistory);
20#include "AudioPrism.h"
22#include "nanolux_util.h"
133 int salFreqs[3] = {0,0,0};
135 bool percussionPresent =
false;
137 float fbs[5] = {0,0,0,0,0};
140 complex fftBuffer[SAMPLES];
141 float vReal[SAMPLES];
142 float smoothVReal[SAMPLES];
146 Spectrogram fftHistory;
147 MeanAmplitude volumeModule;
148 MajorPeaks peaksModule;
149 DeltaAmplitudes deltaModule;
150 SalientFreqs salientModule;
151 Centroid centroidModule;
152 PercussionDetection percussionModule;
153 Noisiness noisinessModule;
156 bool vRealSmoothed =
false;
157 bool peakUpdated =
false;
158 bool volumeUpdated =
false;
159 bool maxDeltaUpdated =
false;
160 bool deltasUpdated =
false;
161 bool salientsUpdated =
false;
162 bool centroidUpdated =
false;
163 bool percussionUpdated =
false;
164 bool noisinessUpdated =
false;
165 bool fbsUpdated =
false;
183 void noise_gate(
int);
189 void vReal_smoothing(
float);
199 void update_volume();
204 void update_max_delta();
209 void update_deltas();
214 void update_salient_freqs();
219 void update_centroid();
224 void update_percussion_detection();
229 void update_noisiness();
235 void update_five_band_split(
int);
AudioAnalysis audioAnalysis
External reference to the AudioAnalysis instance.
Definition globals.h:45
Handles audio signal processing and feature extraction.
Definition audio_analysis.h:38
void processAudioFrame(int)
Processes an audio frame, including sampling, FFT computation, and noise gating.
Definition audio_analysis.cpp:48
float getCentroid()
Gets the centroid frequency of the audio spectrum.
Definition audio_analysis.cpp:91
float * getFiveBandSplit(int len)
Calculates and returns a five-band split of the audio spectrum.
Definition audio_analysis.cpp:106
int getMaxDelta()
Gets the maximum delta value between FFT bins.
Definition audio_analysis.cpp:76
float * getVReal()
Gets the raw real part of the FFT result.
Definition audio_analysis.cpp:57
float getPeak()
Gets the peak frequency detected in the audio.
Definition audio_analysis.cpp:66
float * getDeltas()
Gets the delta values between FFT bins.
Definition audio_analysis.cpp:81
void resetCache()
Clears all flags that indicate updated data for getters.
Definition audio_analysis.cpp:35
int * getSalientFreqs()
Gets the salient frequencies detected in the audio.
Definition audio_analysis.cpp:86
AudioAnalysis()
Constructor for the AudioAnalysis class. Initializes AudioPrism modules and other variables.
Definition audio_analysis.cpp:13
float getVolume()
Gets the volume level of the audio.
Definition audio_analysis.cpp:71
float getNoisiness()
Gets the noisiness level of the audio.
Definition audio_analysis.cpp:101
bool getPercussionPresence()
Checks for the presence of percussion in the audio.
Definition audio_analysis.cpp:96