Viking Skull Lamp
V1.0.1
|
This object is used to process audio data. More...
#include <musicVisualizer.hpp>
Public Member Functions | |
musicChannel (int pin_p, float silentLimit_p) | |
Constructor. More... | |
musicChannel (int pin_p, float silentLimit_p, float offset_p) | |
Constructor. More... | |
musicChannel (int pin_p, float silentLimit_p, float offset_p, float avgSampleFilterBeta_p, float sampleFilterBeta_p) | |
Constructor. More... | |
void | update () |
Update function. More... | |
void | attachPeakFunction (void(*peakFunc_p)(void)) |
Attach a function to every peak event. More... | |
Public Attributes | |
bool | peak |
Flag, that indicates a peak event. More... | |
float | signal = 0.0 |
The filtered signal will be stored in this variable. More... | |
float | signalMax = 0.0 |
The maximum level of the signal is stored in this variable. More... | |
Private Attributes | |
float | silentLimit = 0.0 |
Silent limit. More... | |
int | pin = A0 |
Analog input pin of the channel. More... | |
float | avgSample = 0.0 |
Holds the average filter level. More... | |
float | sample = 0 |
The raw sample will be processed to this variable. More... | |
float | signalPrev = 0.0 |
Previous value of the signal. More... | |
float | avgPeak = 0.0 |
Average peak signal. More... | |
float | offset = 512.0 |
Offset of the ADC result. More... | |
float | avgSampleFilterBeta = 0.3 |
Filter constant for average sample. More... | |
float | sampleFilterBeta = 0.5 |
Filter constant for sample. More... | |
void(* | peakFunc )(void) = NULL |
Function pointer to peak event function. More... | |
This object is used to process audio data.
It is basically an advanced peak detector. It detects the noise floor dynamically to adjust it to the environment.
Definition at line 51 of file musicVisualizer.hpp.
musicChannel::musicChannel | ( | int | pin_p, |
float | silentLimit_p | ||
) |
Constructor.
pin_p | Analog input pin. |
silentLimit_p | Silent limit level. It depends on the exact type of the microphone. |
Definition at line 32 of file musicVisualizer.cpp.
musicChannel::musicChannel | ( | int | pin_p, |
float | silentLimit_p, | ||
float | offset_p | ||
) |
Constructor.
pin_p | Analog input pin. |
silentLimit_p | Silent limit level. It depends on the exact type of the microphone. |
offset_p | ADC offset. It is used when the ADC data is shifted. For example to half supply. |
Definition at line 40 of file musicVisualizer.cpp.
musicChannel::musicChannel | ( | int | pin_p, |
float | silentLimit_p, | ||
float | offset_p, | ||
float | avgSampleFilterBeta_p, | ||
float | sampleFilterBeta_p | ||
) |
Constructor.
pin_p | Analog input pin. |
silentLimit_p | Silent limit level. It depends on the exact type of the microphone. |
offset_p | ADC offset. It is used when the ADC data is shifted. For example to half supply. |
avgSampleFilterBeta_p | Filter coefficient for the average sample data. It used by a complementary-filter. Range [ 0.0 - 1.0 ] |
sampleFilterBeta_p | Filter coefficient for the sample data. It used by a complementary-filter. Range [ 0.0 - 1.0 ] |
Definition at line 49 of file musicVisualizer.cpp.
void musicChannel::attachPeakFunction | ( | void(*)(void) | peakFunc_p | ) |
Attach a function to every peak event.
You can attach a function to every peak event. It can be useful when you want to respond very fast to a peak.
peakFunc_p | Function that will be called when a peak event occurs. |
Definition at line 60 of file musicVisualizer.cpp.
void musicChannel::update | ( | ) |
Update function.
This function has to be called periodically with fixed timing.
Definition at line 67 of file musicVisualizer.cpp.
|
private |
Average peak signal.
Definition at line 117 of file musicVisualizer.hpp.
|
private |
Holds the average filter level.
If the signal level rises above this level, a peak event will trigger.
Definition at line 108 of file musicVisualizer.hpp.
|
private |
Filter constant for average sample.
Definition at line 123 of file musicVisualizer.hpp.
|
private |
Offset of the ADC result.
Definition at line 120 of file musicVisualizer.hpp.
bool musicChannel::peak |
Flag, that indicates a peak event.
Definition at line 87 of file musicVisualizer.hpp.
|
private |
Function pointer to peak event function.
Definition at line 129 of file musicVisualizer.hpp.
|
private |
Analog input pin of the channel.
Definition at line 104 of file musicVisualizer.hpp.
|
private |
The raw sample will be processed to this variable.
Definition at line 111 of file musicVisualizer.hpp.
|
private |
Filter constant for sample.
Definition at line 126 of file musicVisualizer.hpp.
float musicChannel::signal = 0.0 |
The filtered signal will be stored in this variable.
Definition at line 90 of file musicVisualizer.hpp.
float musicChannel::signalMax = 0.0 |
The maximum level of the signal is stored in this variable.
Imagine it like a digital Vu meters output.
Definition at line 94 of file musicVisualizer.hpp.
|
private |
Previous value of the signal.
Definition at line 114 of file musicVisualizer.hpp.
|
private |
Silent limit.
If the signal is less then this value, it wont react to peaks. It has to be tuned for the microphone and the analog stage.
Definition at line 101 of file musicVisualizer.hpp.