Auto Analog Audio v1.50.0
TMRh20 2020 - Automatic DAC, ADC & Timers on Arduino Due
Loading...
Searching...
No Matches
List of all members
AutoAnalog Class Reference

#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)
 

Detailed Description

Examples
AudioRadioRelay.ino, MultiChannelAdcStream.ino, NRF52_PDM_PWMTest.ino, SdAudioAuto.ino, SdAudioBasic.ino, SdAudioRecording.ino, SdAudioWavPlayer.ino, SimpleAdcStream.ino, SimpleSine.ino, SimpleSine12Bit.ino, WirelessMicrophone.ino, and WirelessSpeaker.ino.

Definition at line 37 of file AutoAnalogAudio.h.

Constructor & Destructor Documentation

◆ AutoAnalog()

AutoAnalog::AutoAnalog ( )

Member Function Documentation

◆ begin()

void AutoAnalog::begin ( bool  enADC,
bool  enDAC 
)

◆ triggerADC()

void AutoAnalog::triggerADC ( )
Note
This function is no longer required and does nothing

◆ getADC()

void AutoAnalog::getADC ( uint32_t  samples = MAX_BUFFER_SIZE)

Load the current ADC data into the ADC Data Buffer

Parameters
samplesThe number of samples to retrieve from the ADC
Note
Changes to the number of samples will not take place until one buffer has been returned with the previous number of samples
Examples
AudioRadioRelay.ino, MultiChannelAdcStream.ino, NRF52_PDM_PWMTest.ino, SimpleAdcStream.ino, and WirelessMicrophone.ino.

◆ feedDAC()

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

Parameters
dacChannel0 for DAC0, 1 for DAC1, 2 for alternating DAC0/DAC1
samplesThe number of samples to send to the DAC
startInterruptsOnly used for the ESP32, this will enable an RTOS task to handle DAC
Examples
AudioRadioRelay.ino, NRF52_PDM_PWMTest.ino, SdAudioAuto.ino, SdAudioBasic.ino, SimpleSine.ino, SimpleSine12Bit.ino, and WirelessSpeaker.ino.

◆ setSampleRate()

void AutoAnalog::setSampleRate ( uint32_t  sampRate = 0,
bool  stereo = true 
)

Set sample rate. 0 enables the default rate specified in AutoAnalog_config.h

Parameters
sampRateThis sets the defined sample rate ie: 32000 is 32Khz
stereoOnly used for the ESP32, this sets stereo or mono output and affects the sample rate
Examples
AudioRadioRelay.ino, MultiChannelAdcStream.ino, NRF52_PDM_PWMTest.ino, SdAudioAuto.ino, SdAudioBasic.ino, SimpleAdcStream.ino, SimpleSine.ino, SimpleSine12Bit.ino, WirelessMicrophone.ino, and WirelessSpeaker.ino.

◆ dacHandler()

void AutoAnalog::dacHandler ( void  )

◆ enableAdcChannel()

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

Note
Specify pins numerically: 0=A0, 1=A1, etc...
Examples
MultiChannelAdcStream.ino.

◆ disableAdcChannel()

void AutoAnalog::disableAdcChannel ( uint8_t  pinAx)

Disable reads from the specified channel (pins A0-A6)

Note
Specify pins numerically: 0=A0, 1=A1, etc...

◆ disableDAC()

void AutoAnalog::disableDAC ( bool  withinTask = false)

Disable the DAC

Parameters
withinTaskOnly used for ESP32, set to true if calling from within a task itself, see included example
Examples
SdAudioAuto.ino.

◆ adcInterrupts()

void AutoAnalog::adcInterrupts ( bool  enabled = true)

En/Disable the interrupt for the ADC

If enabled, the following function needs to be added:

void ADC_Handler(void){
-code here-
}

◆ dacInterrupts()

void AutoAnalog::dacInterrupts ( bool  enabled = true,
bool  withinTask = false 
)

◆ rampOut()

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

Parameters
sampleFor ESP32 only, provide the first or last sample to ramp the signal in/out

◆ rampIn()

void AutoAnalog::rampIn ( uint8_t  sample)

Member Data Documentation

◆ dacBuffer

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()

See also
dacBitsPerSample
Examples
AudioRadioRelay.ino, SdAudioAuto.ino, SdAudioBasic.ino, and SimpleSine.ino.

Definition at line 82 of file AutoAnalogAudio.h.

◆ adcBuffer

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()

See also
adcBitsPerSample
Examples
AudioRadioRelay.ino, and WirelessMicrophone.ino.

Definition at line 89 of file AutoAnalogAudio.h.

◆ dacBuffer16

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()

See also
dacBitsPerSample
Examples
NRF52_PDM_PWMTest.ino, SdAudioAuto.ino, SimpleSine12Bit.ino, and WirelessSpeaker.ino.

Definition at line 96 of file AutoAnalogAudio.h.

◆ adcBuffer16

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()

See also
adcBitsPerSample
Examples
MultiChannelAdcStream.ino, NRF52_PDM_PWMTest.ino, and SimpleAdcStream.ino.

Definition at line 104 of file AutoAnalogAudio.h.

◆ autoAdjust

bool AutoAnalog::autoAdjust

◆ adcBitsPerSample

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

Examples
MultiChannelAdcStream.ino, NRF52_PDM_PWMTest.ino, SimpleAdcStream.ino, and WirelessMicrophone.ino.

Definition at line 135 of file AutoAnalogAudio.h.

◆ dacBitsPerSample

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

Examples
NRF52_PDM_PWMTest.ino, SdAudioAuto.ino, SdAudioBasic.ino, SimpleSine12Bit.ino, and WirelessSpeaker.ino.

Definition at line 146 of file AutoAnalogAudio.h.

◆ dacTaskHandle

TaskHandle_t AutoAnalog::dacTaskHandle

Definition at line 189 of file AutoAnalogAudio.h.


The documentation for this class was generated from the following file: