NanoLux (Device) 3.0
Codebase for the open-source AudioLux device.
|
#include <Arduino.h>
#include "arduinoFFT.h"
#include "nanolux_types.h"
#include "nanolux_util.h"
#include <cmath>
Functions | |
void | sample_audio () |
Samples incoming audio and stores the signal in vReal. | |
void | noise_gate (int threshhold) |
Zeros all audio analysis arrays if the volume is too low. | |
void | update_volume () |
Calculates and stores the current volume. | |
void | update_max_delta () |
Updates the largest frequency change in the last cycle. | |
void | update_peak () |
Updates the current peak frequency. | |
Variables | |
unsigned int | sampling_period_us |
Audio sampling period. | |
double | volume |
Global variable used to access the current volume. | |
double | peak |
Global variable used to store preak audio frequency. | |
bool | is_fft_initalized = false |
double | vReal [SAMPLES] |
double | vRealHist [SAMPLES] |
Last state of the vReal array. | |
double | vImag [SAMPLES] |
Imaginary component of vReal. Unused. | |
double | delt [SAMPLES] |
ArduinoFFT< double > | FFT = ArduinoFFT<double>(vReal, vImag, SAMPLES, SAMPLING_FREQUENCY) |
FFT used for processing audio. | |
double | maxDelt |
This file's functions perform basic audio processing.
Many of the functions in ext_analysis.cpp use values calculated here to perform more complex audio analysis.
void noise_gate | ( | int | threshhold | ) |
Zeros all audio analysis arrays if the volume is too low.
threshold | The threshold to compare the total volume against. |
void sample_audio | ( | ) |
Samples incoming audio and stores the signal in vReal.
Reads from ANALOG_PIN for the calculated sampling period. Once a timestep is sampled, the function sleeps until ready to sample again at the next timestep.
void update_max_delta | ( | ) |
Updates the largest frequency change in the last cycle.
Places the calculated value in the "maxDelt" variable.
void update_peak | ( | ) |
Updates the current peak frequency.
Places the calculated peak frequency in the "peak" variable.
void update_volume | ( | ) |
Calculates and stores the current volume.
Volume is stored in the "volume" global variable.
|
extern |
Variable used to store the frequency delta between vReal and vRealHist.
|
extern |
Global variable used to access the frequency band with the largest delta between iterations.
|
extern |
Global variable used to store preak audio frequency.
Global variable used to store preak audio frequency.
|
extern |
Global variable used to access the current volume.
Global variable used to access the current volume.
|
extern |
Array to store both sampled and FFT'ed audio. Processing is done in place.