Auto Analog Audio v1.50.0
TMRh20 2020 - Automatic DAC, ADC & Timers on Arduino Due
|
#include <AutoAnalogAudio.h>
User Interface | |
Main methods to drive the library | |
uint8_t | dacBuffer [MAX_BUFFER_SIZE] |
uint8_t | adcBuffer [MAX_BUFFER_SIZE] |
uint16_t | dacBuffer16 [MAX_BUFFER_SIZE] |
uint16_t | adcBuffer16 [MAX_BUFFER_SIZE] |
bool | autoAdjust |
uint8_t | adcBitsPerSample |
uint8_t | dacBitsPerSample |
TaskHandle_t | dacTaskHandle |
AutoAnalog () | |
void | begin (bool enADC, bool enDAC) |
void | triggerADC () |
void | getADC (uint32_t samples=MAX_BUFFER_SIZE) |
void | feedDAC (uint8_t dacChannel=0, uint32_t samples=MAX_BUFFER_SIZE, bool startInterrupts=false) |
void | setSampleRate (uint32_t sampRate=0, bool stereo=true) |
void | dacHandler (void) |
void | enableAdcChannel (uint8_t pinAx) |
void | disableAdcChannel (uint8_t pinAx) |
void | disableDAC (bool withinTask=false) |
void | adcInterrupts (bool enabled=true) |
void | dacInterrupts (bool enabled=true, bool withinTask=false) |
void | rampOut (uint8_t sample) |
void | rampIn (uint8_t sample) |
Definition at line 37 of file AutoAnalogAudio.h.
AutoAnalog::AutoAnalog | ( | ) |
void AutoAnalog::begin | ( | bool | enADC, |
bool | enDAC | ||
) |
void AutoAnalog::triggerADC | ( | ) |
void AutoAnalog::getADC | ( | uint32_t | samples = MAX_BUFFER_SIZE | ) |
Load the current ADC data into the ADC Data Buffer
samples | The number of samples to retrieve from the ADC |
void AutoAnalog::feedDAC | ( | uint8_t | dacChannel = 0 , |
uint32_t | samples = MAX_BUFFER_SIZE , |
||
bool | startInterrupts = false |
||
) |
Feed the current PCM/WAV data into the DAC for playback
dacChannel | 0 for DAC0, 1 for DAC1, 2 for alternating DAC0/DAC1 |
samples | The number of samples to send to the DAC |
startInterrupts | Only used for the ESP32, this will enable an RTOS task to handle DAC |
void AutoAnalog::setSampleRate | ( | uint32_t | sampRate = 0 , |
bool | stereo = true |
||
) |
Set sample rate. 0 enables the default rate specified in AutoAnalog_config.h
sampRate | This sets the defined sample rate ie: 32000 is 32Khz |
stereo | Only used for the ESP32, this sets stereo or mono output and affects the sample rate |
void AutoAnalog::dacHandler | ( | void | ) |
Function called by DAC IRQ
void AutoAnalog::enableAdcChannel | ( | uint8_t | pinAx | ) |
Enable reads from the specified channel (pins A0-A6)
Active ADC Channels will be read in numeric order, high to low
void AutoAnalog::disableAdcChannel | ( | uint8_t | pinAx | ) |
Disable reads from the specified channel (pins A0-A6)
void AutoAnalog::disableDAC | ( | bool | withinTask = false | ) |
Disable the DAC
withinTask | Only used for ESP32, set to true if calling from within a task itself, see included example |
void AutoAnalog::adcInterrupts | ( | bool | enabled = true | ) |
En/Disable the interrupt for the ADC
If enabled, the following function needs to be added:
void AutoAnalog::dacInterrupts | ( | bool | enabled = true , |
bool | withinTask = false |
||
) |
void AutoAnalog::rampOut | ( | uint8_t | sample | ) |
Rampout and RampIn functions ramp the signal in/out to minimize 'pop' sound made when en/disabling the DAC
sample | For ESP32 only, provide the first or last sample to ramp the signal in/out |
void AutoAnalog::rampIn | ( | uint8_t | sample | ) |
uint8_t AutoAnalog::dacBuffer[MAX_BUFFER_SIZE] |
DAC data buffer for 8-bit samples
8-bit user samples are loaded directly into this buffer before calling feedDAC()
Definition at line 82 of file AutoAnalogAudio.h.
uint8_t AutoAnalog::adcBuffer[MAX_BUFFER_SIZE] |
ADC Data buffer for 8-bit samples
8-bit samples are read directly from this buffer after calling getADC()
Definition at line 89 of file AutoAnalogAudio.h.
uint16_t AutoAnalog::dacBuffer16[MAX_BUFFER_SIZE] |
DAC data buffer for 10 or 12-bit samples
10 or 12-bit user samples are loaded directly into this buffer before calling feedDAC()
Definition at line 96 of file AutoAnalogAudio.h.
uint16_t AutoAnalog::adcBuffer16[MAX_BUFFER_SIZE] |
ADC Data buffer for 10 or 12-bit samples
10 or 12-bit samples are read directly from this buffer after calling getADC()
Definition at line 104 of file AutoAnalogAudio.h.
bool AutoAnalog::autoAdjust |
Auto & Manual sample rates. En/Disables automatic adjustment of timers
Default: true
Definition at line 124 of file AutoAnalogAudio.h.
uint8_t AutoAnalog::adcBitsPerSample |
ADC (Analog to Digital Converter)
Select the bits-per-sample for incoming data
Default: 8:8-bit, 10:10-bit, 12:12-bit
There are two separate data buffers for the ADC,selected by setting this variable.
adcBuffer[] is an 8-bit buffer used solely for your 8-bit samples
adcBuffer16[] is a 16-bit buffer used solely for placing your 10 and 12-bit samples
Definition at line 135 of file AutoAnalogAudio.h.
uint8_t AutoAnalog::dacBitsPerSample |
DAC (Digital to Analog Converter)
Select the bits-per-sample for incoming data
Default: 8:8-bit, 10:10-bit, 12:12-bit
There are two separate data buffers for the DAC, selected by setting this variable.
dacBuffer[] is an 8-bit buffer used solely for your 8-bit samples
dacBuffer16[] is a 16-bit buffer used solely for placing your 10 and 12-bit samples
Definition at line 146 of file AutoAnalogAudio.h.
TaskHandle_t AutoAnalog::dacTaskHandle |
Definition at line 189 of file AutoAnalogAudio.h.