Teensy4 Audio Library and DMA

Status
Not open for further replies.

DW99

New member
Good day everyone,

This is my first post here so bear with me.

I have a Teensy4 and an audio project, and I need some advice on implementation.
I need to be able to both record and playback audio simultaneously; I need to record audio to the internal memory of the Teensy, and at the same time play audio files from an SD card. I know the audio shield is available that might make implementation easier, but assume for the moment I do not have access to it.

At the moment, my idea to implement this is as follows:
I will use the built in ADC to record audio from the microphone, using the audio library queue and adc objects. This audio is not long, I need to record it to an internal memory buffer, perform energy based speech detection, and then the buffer is cleared. Say, 8 packets at a time.
At the same time, I need to be able to play pre-recorded audio clips from the SD card. I am planning to do this using the Teensy4's MQS pin (audio output quality is not important, if it is audible it is fine).

From my understanding, I won't be able to do this without the use of DMA. The cpu will be caught up in performing adc and writing the samples to memory, as well as performing the speech algorithm, so it will not have time to do the audio playback. I therefore need to use DMA to playback the audio clips from the SD card.

Does the teensy audio library automatically perform DMA, or will I need to create my own code to playback the audio with dma? In other words, would it be possible to simply use the playSdWav and mqs objects in the audio library, together with the queue and adc objects? I see in the documentation for playSdWav, it says "While playing, the audio library accesses the SD card automatically." I am not sure whether this means it is using DMA, or not.

I should probably mention, I do not have all of the required parts yet, I am still waiting for the SD card module and speaker to arrive, which will happen on Monday. Until then, I cannot test my code to see what works and what doesn't, so I thought I might save some time by just asking here.
 
The audio library automatically uses DMA. No need to program that.
But ADC for Audio on T4 is kind of "experimental". Does not work good.
 
That is good news, thank you. What would you recommend I use in stead of the T4 ADC? The audio shield?
 
Status
Not open for further replies.
Back
Top