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

#include <AutoAnalogAudio.h>

Public Attributes

Section for nRF52 Devices Only

This section is for nRF52 devices only

int pwrPin
 
int dinPin
 
int clkPin
 
int8_t gain
 
uint16_t I2S_PIN_MCK
 
uint8_t I2S_PORT_MCK
 
uint16_t I2S_PIN_SCK
 
uint8_t I2S_PORT_SCK
 
uint16_t I2S_PIN_LRCK
 
uint8_t I2S_PORT_LRCK
 
uint16_t I2S_PIN_SDOUT
 
uint8_t I2S_PORT_SDOUT
 
uint16_t I2S_PIN_SDIN
 
uint8_t I2S_PORT_SDIN
 
uint32_t maxBufferSize
 

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 (uint8_t enADC, uint8_t enDAC, uint8_t _useI2S=0)
 
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=false)
 
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 ( uint8_t  enADC,
uint8_t  enDAC,
uint8_t  _useI2S = 0 
)

Setup the timer(s)

Make sure to define your chosen pins before calling begin();

NRF52 Only: Call the below code prior to begin() to limit memory usage/buffer sizes:

aaAudio.maxBufferSize = YOUR_AUDIO_BUFFER_SIZE;

Third option:

Parameters
enADC0 = Disabled, 1 = PDM input, 2 = I2S input, 3 = SAADC input
enDAC0 = Disabled, 1 = PWM output, 2 = I2S output
_useI2SThis is deprecated, use enADC and enDAC to control inputs/outputs
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.

◆ 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 = false 
)

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 & NRF52840 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 95 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 102 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 109 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 117 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 148 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 159 of file AutoAnalogAudio.h.

◆ dacTaskHandle

TaskHandle_t AutoAnalog::dacTaskHandle

Definition at line 202 of file AutoAnalogAudio.h.

◆ pwrPin

int AutoAnalog::pwrPin

Set the Power Pin for PDM
By default this is PIN_PDM_PWR
If PIN_PDM_PWR is not defined, it is set to -1 by default
Configure this before calling begin()

Definition at line 258 of file AutoAnalogAudio.h.

◆ dinPin

int AutoAnalog::dinPin

Set the Input Pin for PDM or SAADC. With SAADC AIN0 is 1, AIN1 is 2 etc. By default this is PIN_PDM_DIN
If PIN_PDM_DIN is not defined, it is set to 35 by default
Configure this before calling begin()

Definition at line 266 of file AutoAnalogAudio.h.

◆ clkPin

int AutoAnalog::clkPin

Set the Clock Pin for PDM
By default this is PIN_PDM_CLK
If PIN_PDM_CLK is not defined, it is set to 36 by default
Configure this before calling begin()

Definition at line 274 of file AutoAnalogAudio.h.

◆ gain

int8_t AutoAnalog::gain

Set the Gain for PDM
By default this is set to 40
Configure this before calling begin()

Definition at line 281 of file AutoAnalogAudio.h.

◆ I2S_PIN_MCK

uint16_t AutoAnalog::I2S_PIN_MCK

Configure the pins and ports for nRF52 using GPIO numbers before calling begin()
Defaults:
I2S_PIN_MCK = 2;
I2S_PORT_MCK = 0;
I2S_PIN_SCK = 3;
I2S_PORT_SCK = 0;
I2S_PIN_LRCK = 29;
I2S_PORT_LRCK = 0;
I2S_PIN_SDOUT = 5;
I2S_PORT_SDOUT = 0;
I2S_PIN_SDIN = 4;
I2S_PORT_SDIN = 0;

Definition at line 297 of file AutoAnalogAudio.h.

◆ I2S_PORT_MCK

uint8_t AutoAnalog::I2S_PORT_MCK

Definition at line 298 of file AutoAnalogAudio.h.

◆ I2S_PIN_SCK

uint16_t AutoAnalog::I2S_PIN_SCK

Definition at line 299 of file AutoAnalogAudio.h.

◆ I2S_PORT_SCK

uint8_t AutoAnalog::I2S_PORT_SCK

Definition at line 300 of file AutoAnalogAudio.h.

◆ I2S_PIN_LRCK

uint16_t AutoAnalog::I2S_PIN_LRCK

Definition at line 301 of file AutoAnalogAudio.h.

◆ I2S_PORT_LRCK

uint8_t AutoAnalog::I2S_PORT_LRCK

Definition at line 302 of file AutoAnalogAudio.h.

◆ I2S_PIN_SDOUT

uint16_t AutoAnalog::I2S_PIN_SDOUT

Definition at line 303 of file AutoAnalogAudio.h.

◆ I2S_PORT_SDOUT

uint8_t AutoAnalog::I2S_PORT_SDOUT

Definition at line 304 of file AutoAnalogAudio.h.

◆ I2S_PIN_SDIN

uint16_t AutoAnalog::I2S_PIN_SDIN

Definition at line 305 of file AutoAnalogAudio.h.

◆ I2S_PORT_SDIN

uint8_t AutoAnalog::I2S_PORT_SDIN

Definition at line 306 of file AutoAnalogAudio.h.

◆ maxBufferSize

uint32_t AutoAnalog::maxBufferSize

Set the maximum buffer size for nRF52
The internal buffers are all allocated dynamically.
By default the MAX_BUFFER_SIZE is defined in AutoAnalogAudio_config.h
Override that value for internal buffers by setting this before calling begin()

Definition at line 314 of file AutoAnalogAudio.h.


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