Audio Library - Output audio through SPI DAC chip.

Status
Not open for further replies.

jidagraphy

Active member
Short version :
Will there ever be a support for outputting audio to DAC chips via SPI?
How would I write a driver/module that I can use as a module that does such thing?


Slightly longer version:
By design choices, I choose not to use any SMD ICs on my board.
I have my teensy 4.0s that do not have dacs, but I really want/need them to output audio without having to use the audio shield. I have myself a couple of MCP4822s (SPI DAC) that I am trying to stream audio to, but I having hard time even imagining where to start. I did read through output_dac.cpp source file too, but I'm not sure if my coding skills are THAT high to understand whats going on :(. (but I will)


I can probably find resources to learn how to make my DACs make sounds via SPI, but the problem is how I can use Audio Library at the same time. I.e. write a new module that acts as if its one of the patchable module from the library.

Im trying not to blindly ask for how to do everything, and trying to at least attempt it first. So I'll ask a few questions instead.

1. Why isn't it supported / ideal to output audio by SPI to DAC? efficiency? quality? noone requested?
2. What makes it *difficult* to stream audio through SPI DAC?
3. I'm seeing if I can modify output_dac.cpp so I can make it output audio to external DAC chip instead of onboard DAC. I haven't understood a lot of it but I'll try. Could I get any guidance or tips on where I should start looking?

Thank you guys,
You are all stars.

Jin








P.S. I do not mind having to sacrifice sample rate - I can pretend I intended lo-fi sound lol. Probably would want it more if it was.
 
How do you propose to synchronize the sample rate transfer over SPI to the Audio Library's sampling rate (even if you use a lower rate)?
 
By design choices, I choose not to use any SMD ICs on my board.

So you need to hand solder? Sure, you don't want SMD but that doesn't explain why SPI... Why not use I2S, the standard for digital audio?
 
How do you propose to synchronize the sample rate transfer over SPI to the Audio Library's sampling rate (even if you use a lower rate)?
Recklessness aside, I do not know.. I was kind of hoping I someone would give me an idea.
Do you reckon this would be efficiently possible if I didn't use the audio library?

So you need to hand solder? Sure, you don't want SMD but that doesn't explain why SPI... Why not use I2S, the standard for digital audio?
Sorry for the late reply -
because there literally wasn't any audio DAC ICs, that is also DIP. At least I couldn't find one that I can realistically get my hands on. Am I missing something??
 
SPI-controlled DAC

I have a Digilent PMOD DA4 (SPI pmod). It took me a long time to learn how to use it reliably, but now I can make it do whatever I want with a Teensy 4. I wanted 8 channels of DAC (at a medium-low resolution). (I don't bother using Digilent's development platform. ) These little boards like 3.3v.

If anyone would like to see the code I got working, it's a combination of several examples for the Arduino platform.

I'm pretty sure I could use other Digilent PMOD cards much the same way. (They have a variety of AD DAC boards.)

But yes, I suppose keeping SPI running fast while doing other audio things is just another ball to keep in the air.
 
Last edited:
Hi!
Yes! Please show us the source code you did with the PMOD DA4!
I need to also use that, is it possible to use more than 1 PMOD?
What SPI Speed do you use?
How clear is the sound you get from it?
I am so excited ! :D
 
The PMOD interface is just wiring to the dac chip. I did not make any effort to support the dac as an audio interface for the Teensy Audio Library. But now that I think about it, that would be fun. I still have the proto board with the the DA4 attached, so maybe this weekend I can try my code and clean it up enough to share. If I could run several simple sound sources at one time it would be great for things like making the complex noise needed for cymbals, bells, and claps in analog drum machines. As it is, I run out of dacs very fast.
 
Hey, I would be also glad just for the skeleton source code of using the pmod via the SPI!
It does not need to be part of the audio library.
Especially, I need to somehow speed the playback up or slow it down till 0. Like when DJs are doing the scratching with the vynil records.
 
Sorry I never wrote back. Many distractions. I'm going to revisit this soon, I think.
I do not have a lot of free time at this point, so I will not try to use the AD5628 for audio, but it would be great to have 8 dac channels for low-frequency control signals.
If I remember there's a "wake-up" period when using this board, and that initial lag can throw off sample code.
 
Status
Not open for further replies.
Back
Top