Go Down

Topic: Arduino DAC (Read 5016 times) previous topic - next topic

Hevle

Hi all,
  I'm new to the forum and I have a question about using an Arduino Uno as a digital to analog converter to use for listening to .MP3's or .WAV files. I know there are shields available to do this, but I wanted to use the Uno to do the actual conversion itself, so I can listen to music through it. Can anyone point me in the right direction? I have also made an 8-bit R-2R ladder DAC to create a simple sine wave, but I want to be able to stream an 8-bit audio file and in the future an actual high fidelity audio file. Any help is greatly appreciated. Thanks.
  Hevle

DVDdoug

The Arduino does not have a DAC.   It has a 10-bit ADC with multiple inputs. And, it has 8-bit PWM outputs which can substitue for analog output for some applications.  But, it won't work for good-quality voice or music. 

Grumpy_Mike

The arduino will not be able to read MP3 files, it does not have enough memory and is too slow to decode them in real time.
However WAV files are possible. But 8 bits is not very good. If you made it yourself I would be surprised if it is true 8 bits, that is I don't think you will have monoticity.

Anyway look at the LadaAda wave shield for examples of how to read from an SD card. What do you expect to stream the audio data from?

Hevle

I have an audio cd that is 8 bit music, and I can rip it to my pc in .WAV format. I have seen the SD shields, and I think that would be a good place to put the audio file since the arduino memory is so small. I was hoping to be able to have the audio input over a serial connection from the pc. This is also just a first attempt at this project. The audio codec shields and DAC shields would probably work perfectly, but I was hoping to figure out how a high end DAC works and implement a simple one of my own.

Grumpy_Mike

It uses R 2R ladder, but you can't make one yourself unless you have the capacity to make resistors with incredaably well matched values. Do the math, but I think you need 0.1% matching for an 8 bit converter.
If you have 8  bit audio samples then you can simply strewn them from the serial port but the sample rate has to match exactly the rate you can transfer data.

Tuttut

Hi, I did very long research efforts on how to get good audio out of Arduino. It will be at least close to Hifi. This are the three secrets:

1. Use PWM with  only 8-Bit but highest frequency: You can achive sample rates up to 62.500Hz which is very good and often you don't need a low-pass filter anymore. Believe me, even 8-Bit with 31kHz sounds better than 16-Bit with 11kHz.

2. To get high resolution the best way is to use an R-256R network to combine two 8-bit pwm outputs to one 16-bit output.

3. Arduino sounds only as good as its supply voltage. And Ardu's supply is often very noisy due noise from AVR itself and noise coming from USB supply. You can clean noisy PWM signals by running them through a Schmitt-Trigger that has a better filtered supply.

Here is the circuit that I actually use with impressive results: http://hackerspace-ffm.de/wiki/index.php?title=Datei:SSDA_Better16bit.png

I think I really should do a video on that for all non-believers...

Tuttut

Grumpy_Mike

That is a very simplistic view of digital sound.
How accurate is your R-256R ratio? You are fooling yourself if you think that gives you 16 bit resolution. There will be no monoticity.
I do not doubt that the results sound alright but they will be no where near to the quality of a true 16 bit system.

Tuttut

I simply you a trimmer as one part of that voltage divider. I trim it just by listening to the sound. Therefore I play a low volume audio part and adjust the trimmer to minimum audible noise. Of course, that DAC never reaches true 16 bit, but there is still a big audible improvement over 8 bit, that is especially audible on lower volume parts or if something fades out. Remember: It is made with simplicity in mind - one resistor and one pot and that's it.

Grumpy_Mike

Quote
I trim it just by listening to the sound. Therefore I play a low volume audio part and adjust the trimmer to minimum audible noise

Fair enough.
Quote
Of course, that DAC never reaches true 16 bit

Yes that's right.

There are two main causes of noise in a digital audio system, one is quantization noise of the amplitude of the signal, and the other is the noise introduced by the quantization of time or sampling period. By over sampling you can cut down the latter but the former is down to the number of bits on the D/A I got very good results in the 70s with 13 bit converters, which in those days cost the same as three months research grant.

The best titled academic paper I read during my lit search was:-
The effects of alcohol on perceived quantization noise.

Which surprise surprise concluded that the more alcohol you gave some on the less they noticed quantization noise.

jangofei


Quote
I trim it just by listening to the sound. Therefore I play a low volume audio part and adjust the trimmer to minimum audible noise

Fair enough.
Quote
Of course, that DAC never reaches true 16 bit

Yes that's right.

There are two main causes of noise in a digital audio system, one is quantization noise of the amplitude of the signal, and the other is the noise introduced by the quantization of time or sampling period. By over sampling you can cut down the latter but the former is down to the number of bits on the D/A I got very good results in the 70s with 13 bit converters, which in those days cost the same as three months research grant.

The best titled academic paper I read during my lit search was:-
The effects of alcohol on perceived quantization noise.

Which surprise surprise concluded that the more alcohol you gave some on the less they noticed quantization noise.


Where can we find the academic paper:
The effects of alcohol on perceived quantization noise

jangofei

The newest Due board supports DAC out audio. Could you test it? The Due is compatible wtih ADK 2012.

Grumpy_Mike

Quote
Where can we find the academic paper:
The effects of alcohol on perceived quantization noise

It was in the American Journal of Audiology, I saw it in my university libary in 1974 in a bound volume so it was some years before that.

jangofei


Quote
Where can we find the academic paper:
The effects of alcohol on perceived quantization noise

It was in the American Journal of Audiology, I saw it in my university libary in 1974 in a bound volume so it was some years before that.

So we can't find it in internet. or can we get a soft copy?

Grumpy_Mike


So we can't find it in internet. or can we get a soft copy?

I have no idea but probably not, not everything is on the internet you know especially 60s / 70s research papers.

Hevle

Thanks for all of the input guys. I think I am going to try to implement a simple DAC using an FGPA board, but I haven't given up on the Arduino! I recently purchased the WAV shield for the Arduino that comes with a 10-bit DAC. For the Arduino project itself, I am going to try to make a basic audio player, much like an MP3 player with it. If anyone knows any more on the topic I would love to hear it, and I will post updates on my progress. Thanks again!

Go Up