Tell me about DACs!

I'm looking into how to go about playing back audio samples, both prerecorded and generated in realtime, and while I know all about do-it-yourself R2R DACs, I don't know anything about the on-cip solutions.

I was looking for some at Mouser, and the ones I found were really expensive. Like $15. And some forum posts I found on google seemed to indicate that was the case for DACs.

But on Digikey, I found some which were cheap. Like $2-$3:

But I realized, I don't know what the heck I should be looking for here. I know I need a DIP package, and I think 8-bit should be sufficient for my needs, and some of those cheap ones are 12 bit, which is great, but why are they so cheap? Are they fast enough for generating audio?

And lastly, is there any specific DAC folks would recommend I look at? I'm just generating sound effects in a prop. It doesn't need to produce really great sound.

(Oh, and in regards to the R2R ladder... I could fall back on that, but I'd rather not dedicate six pins just to sound generation. I am also considering PCM, but that might use too much cpu.)

I could fall back on [r2r-based DAC], but I'd rather not dedicate six pins just to sound generation.

So you need a serial DAC. At least two pins for I2C or three pins for SPI?
You could start at manufacturers. TI and National both have a bunch of cheap DACs. National looks to have 8/10/12 bit parts all pin-compatible, which is sorta neat. No DIP packages, though. Tiny little SMT things.

This is a good site for seeing what is what with D/As

Grumpy:

Great resource, but... head explodes

I don't know where to start with that!

I don't know what questions to ask either though, so I'll give that a good once or twice over before I start. :slight_smile:

Have a look at the Ladyada sound shield. The schematic is somewhere on their site, but not easy to find. I think this uses an MCP4921 DA chip. I have used a few of these shields and they sound good. The DA & audio bit of the circuit looks easy to implement.

Edit: found it here Audio Shield for Arduino right at the bottom of the page

Reminds me of my wife on here first teaching practice. A child read a book and wrote:-
"this book tells me more about penguins than I wish to know"

The sampling RATE is also an important factor. Nyquist, et.al. says that you need 2x the highest frequency you want to reproduce. Standard good-quality audio is defined as 20Hz to 20KHz. That is why CDs use a sample rate or 44KHz (2x the 20KHz maximum plus a bit more to accomodate the low-pass filter skirts.) But, again, you say you don't need pristine quality, so maybe you could get away with a sample rate of 11KHz or even 8KHz?

Yeah, I'm aware of that 2x sampling rate issue. And I did some tests last night on the sound effect I want to use in Sound Forge, to see exactly how small I could get it. Turned out it sounded fine at 8bit, but I couldn't lower the sampling rate any lower than 22khz without it turning to muddy sounding crap because it's mostly frequencies around 5-10khz.

Even at 8bit and 22khz mono, and sampling only a single cycle of the effect which I would then have to adjust in pitch, I still couldn't get it down below about 20K, which is too big for the Arduino to store.

So... not sure what I'm gonna do about that.

I wonder if I could compress the sound in some way. A lower sample depth would give a sine wave that isn't very smooth, but what if instead of storing the samples, I stored the difference between each, and instead of simply storing the difference, I set it up so that stored diferences of 1 2 3 or 4 would be translated to 1 2 4 or 8, so greater changes would be stored with less accuracy, while finer adjustments would have greater accuracy?

Well just an idea. Even if that gave me 2x compression it still wouldn't really be enough to fit the sample in memory with my program.

Hm... I wonder if one could do something like that with a resistor ladder to get a better sounding output. That's not what they did with the phones, is it? It sounds like you were saying they did a kind of compression like that, but with the sample value, rather than the difference, so louder samples would be lower quality.

Not even sure how that compression idea of mine would even sound actually. Or if you could do that with a resisotr ladder dac.

but what if instead of storing the samples, I stored the difference between each,

That is called delta modulation and it is what I did my PhD on back in the 70s. You can't get much better than a 4 times compression with this sort of method.

That's not what they did with the phones, is it?

They used an A-law encoding system where the bigger numbers had bigger steps between them, a sort of log output instead of a liner one.

However the basic problem is that the arduino doesn't have enough memory.

I have just purchased 4-5 of SparkFun's "MP3 Trigger" boards. They are MADE for integrating into installations (like museum pieces, etc.) Great stuff. They use a micro SD flash memory card to accomodate GB of audio data.

Those MP3 trigger boards look cool, but they're way too expensive to integrate into my props. They're also kinda big. I don't think one would fit in this particular prop. (I don't use the regular Arduinos, I use the Pro Minis.)

Are there any "smart" DACs out there that you can configure with a sample rate (say 22kHz), and then have them interrupt periodically for you to fill up an internal buffer (2x64 samples or so?) I guess there is a bunch of stuff that works like this for DSPs, but they seem to only support "standard" samplerates and sizes (eg "CD quality") and use somewhat odd interfaces (in cooperation with the DSP-side hardware.)

(I guess this is the sort of thing that you could program an ATMEGA8 or similar to do, as a "slave cpu" for the Arduino...)

Are there any "smart" DACs out there

I have not seen any but you could make your own by putting a FIFO in front of a D/A and clocking it out at your fixed sample rate.

There are chips that record and playback a few seconds of sound, all self-contained.
But you mentioned changing pitch, etc. which is not supported by those solutions.

Can you name some of those? They might not help with this project but something like that would surely come in handy for others.