Instructables
Picture of Arduino Audio Output
Generate sound or output analog voltages with an Arduino.  This Instructable will show you how to set up a really basic digital to analog converter so you can start generating analog waves of all shapes and sizes from a few digital pins on an Arduino.  (This article is a companion to another Instructable I've written about sending audio into an Arduino, find that here)

Some ideas that come to mind:

sample based instrument- store samples on the Arduino or on an SD card and trigger playback with buttons or other types of controls.  Check out my Arduino drum sampler for an idea of how to get started.
digital synthesizer- make saw, sine, triangle, pulse, or arbitrary waveshapes- check out my waveform generator to get started
MIDI to control voltage module/ MIDI synthesizer- receive MIDI messages and translate them into a voltage so you can control an analog synthesizer with MIDI, or use the MIDI data to output audio of a certain frequency
analog output- you may find yourself needing to generate analog voltages from your Arduino at some point, maybe to communicate with an analog device
effects box/digital signal processing- in combination with a microphone/audio input you can perform all kinds of digital signal manipulations and send the processed audio out to speakers.  Check out my vocal effects box for an example. 
audio playback device- make your own ipod.  With the addition of an SD shield you could create your own Arduino mp3 player (check out the wave shield documentation for an idea of how to get started with the code).  The circuits and code provided here are compatible with SD shields that communicate via SPI.

Feel free to use any of the info here to put together an amazing project for the DIY Audio Contest!  We're giving away an HDTV, some DSLR cameras, and tons of other great stuff!  The contest closes Nov 26.

Parts List:

(x9) 1/4 Watt 20kOhm Resistors Digikey 0KQBK-ND
(x7) 1/4 Watt 10kOhm Resistors Digiikey CF14JT10K0CT-ND
(x2) TS922IN Digikey 497-3049-5-ND I like these because they can be powered off the Arduino's 5V supply (one 924 works too, but they don't seem to be available on digikey at the moment)
(x1) 10kOhm potentiometer linear Digikey 987-1308-ND
(x1) 0.01uF capacitor Digikey 445-5252-ND
(x1) 220uF capacitor Digikey P5183-ND
(x1) 0.1uF capacitor Digikey 445-5303-ND
(x1) 1/4 Watt 3kOhm Resistor Digikey CF14JT3K00CT-ND
(x1) 1/4 Watt 10Ohm Resistor Digikey CF14JT10R0CT-ND
(x1) Arduino Uno Sparkfun DEV-09950

Additional Materials:
22 Gauge Wire
solder
 
Remove these adsRemove these ads by Signing Up
m_osik1 month ago

HI all,

at first i would like to THNX for cool tutorial.

I tried to use as output converter MCP4921 (with AH_MCP4921.h) but i am not able to get any "audible" sounds. Have anybody tried this D/A converter with this solution ?

Best regards

Jan

zacaj5 months ago

Hi, thanks for this great tutorial!

I've got limited inputs, so I was looking at using a serial-in DAC chip instead of using a ladder, do you think that this http://www.digikey.com/product-detail/en/MCP4901-E... (MCP4901-E/P) would work? Could I just drop it in to your schematic as long as I handle the programming correctly?

Also, I hope to power some computer speakers (with their own amp/volume control) using this circuit. Since they'd have their own volume, I assume I don't need to install a potentiometer? Would the same buffer work, or would I need something bigger to support louder/larger speakers?

Thanks

amandaghassaei (author)  zacaj5 months ago

Yeah that chip looks good, but (as you mentioned) the code will have to change a bit. If your speakers have their own amp, you can probably get away with connecting the output of the buffer to the input of your speaker's amp. It's possible you may need a little preamp in there, in that case you can use the amp in my schematic w a resistor in place of the potentiometer.

It also seems I'm going to need to run off 3V instead of 5V. I know I'll need a different DAC, but other than that: I assume I'll need a different DC offset capacitor? Are there any other components I'll need to change?

Hey, thanks for the tutorial!

The input tutorial works great. For this one, though, TS922IN Digikey 497-3049-5-ND is obsolete. I called Digikey and http://www.digikey.com/product-detail/en/TS922IDT/... is the closest, but it's a surface mount chip. We are just gonna solder some wires and give it a go.

lynettequek5 months ago

Could the bit manipulation be used to free up Digital pins 0 and 1 for serial communication? I have only one serial communication used so I can't use software serial for that. I have this code so far:

// bit manipulation, sending number 36 to 0 and 1. PORTB: digitalPin 8-13
//define variables:
boolean bit0state;
boolean bit1state;

//in your main loop():
bit0state = (36 & B00000001)>>0;//get the zero bit of 36
bit1state = (36 & B00000010)>>1;//get the first bit of 36

//send data to portd w/o disrupting pins 0 and 1
PORTD |= (36&B11111100);//set high pins high using the number 36 with zeros replacing bits 0 and 1
PORTD &= (36|B00000011);//set low pins low using the number 36 with ones replacing bits 0 and 1


//send data to portb w/o disrupting pins 9, 10, and 11, affect 8, 12 and 13 ???
PORTB |= 0 | (bit3state) | (bit5state<<4) | (bit6state<<5);//set high pins
PORTB &= 255 & ~(1-bit3state) & ~((1-bit5state)<<4) & ~((1-bit6state)<<5);//set low pins

i'm stuck at the last part where i send data to portb, which i only want to affect pins 11 and 12, in replacement of pins 0 and 1. Am I on the right track to do this? Thanks so much!

amandaghassaei (author)  lynettequek5 months ago

is the number 36 just an example? you can send out numbers less than 64 using only six bits, so you wouldn't even have to worry about pins 8, 12, and 13.

//send data to portd w/o disrupting pins 0 and 1
PORTD |= ((36<<2)&B11111100);
PORTD &= ((36<<2)|B00000011);

thanks for your reply! yup 36 is just an example. following what you did for the instructable :) what if I want to "shift" pins 0 and 1 back to pins 11 and 12? do I have to include this part?

//send data to portb w/o disrupting pins 9, 10, and 11, affect 8, 12 and 13
PORTB |= 0 | (bit3state) | (bit5state<<4) | (bit6state<<5);//set high pins
PORTB &= 255 & ~(1-bit3state) & ~((1-bit5state)<<4) & ~((1-bit6state)<<5);//set low pins

amandaghassaei (author)  lynettequek5 months ago

PORTB |= 0 | (bit0state<<4) | (bit1state<<5);//set high pins

PORTB &= 255 & ~((1-bit0state)<<4) & ~((1-bit1state)<<5);//set low pins

I'm pretty sure that will work for pins 12 and 13

thanks so much! will try it out!
AbdulW875 months ago

Thanks for this instructable, very helpful. Can i use an AD712KNZ since they dont make the 922 anymore.

amandaghassaei (author)  AbdulW875 months ago
yes, you might also check out the lm386 bc it doesn't require a dual power supply.
hopkinskong5 months ago

Hello,

Thanks for your instructable! I am now managed to use this trick on one of my 8051 microcontroller!

amandaghassaei (author)  hopkinskong5 months ago
nice!
starock5 months ago

Tnank you so much~! \(≧▽≦)/~

1Question Plz:

How can I generate a sound like Mario-Gmae? I Love 8Bit music. Make a 8Bit synthesizer is my dream. T_T

amandaghassaei (author)  starock5 months ago
http://arduino.cc/en/Reference/tone
Reddyco7 months ago

Hey Amanda! Great job on this instructable, I'm using it to embase my work on a eletronic drum sound generator with Arduino (hopefully, one day I'll post here how to do it).

I'm writing to ask abuot that 0.01 uF and 10ohm resistor in parallel with the speaker and the DC offset capacitor. What are they used for?

Thanks in advance!

amandaghassaei (author)  Reddyco7 months ago

thanks! they're just threre to reduce noise, not a big deal if you don't have them

flowirin7 months ago

what's the upper limit on the sampling frequency for the arudino? can i get it up to 80kHz?

amandaghassaei (author)  flowirin7 months ago

definitely, you could get up to a few hundred kHz with no problem.

One concern is that the resistor ladder dac that I show in this ible might not respond fast enough as you increase the sampling rate - this might end up applying a low pass filter on your output. I updated step 1 with a little more info about alternative DACs, you might check out the R2R DAC IC I demonstrated in this Instructable (you can wire it up to only use one channel if you need), it has much better quality control then just throwing a bunch of resistors together on a breadboard and I think it will give you better results. It says the settling time for that DAC is 100ns, which should work fine for 80kHz sampling rate.

you will also have to change the frequency of the interrupt. For 40kZ I used this line:

OCR0A = 49;// = (16*10^6) / (40000*8) - 1

try this instead:

OCR0A = 24;// = (16*10^6) / (40000*8) - 1

ibirnam1 year ago
Just wanted to confirm this: since the TS922IN is now obsolete, would this be a sufficient replacement? Thank you!
amandaghassaei (author)  ibirnam1 year ago
that's going to be really hard to work w bc it's surface mount. Just get the lm386 chip and a couple of resistors and capacitors and wire it up like this:
http://www.hobby-hour.com/electronics/lm386-20.gif
it may need a 9v supply instead of 5v, I can't remember.

I'm working my way through this trying to substitute the lm386 at Step 3. The gif you linked looks like the replacement for the amplifier. I can see the part that replaces the low pass filter (thanks to your excellent explanation of what that is) but I don't see anything that I recognize as being the DAC buffer. Is the buffer unnecessary with the lm386, or is it there and I don't recognize it?
Thanks!
PS I'm a software engineer, so use small words. :-)

amandaghassaei (author)  heymarky7 months ago

actually, a resistor and capacitor only act as a low pass filter when the output signal is connected to the junction between them, here is a pic. You can see that switching the order of the components will turn it into a high pass filter. The lm386 circuit is not wired up the same way, so it won't act as a low pass filter. So here's what I would do:

arduino - dac - lm386 - low pass filter - output

you could also use a tl1072 or tl082 to replace both ts922's, but these require a +/- 9v supply, which is annoying.

Awesome, thanks for the help!

Ibirnam Is LM386 working instead of using TS922IN ?

joshuaphua18 months ago

near the end of the circuit, what's the 0.1uF capacitor and 10Ohm resistor for? another kind of filter?

amandaghassaei (author)  joshuaphua18 months ago

not a filter, just helps make the DC offset more stable.

joshuaphua19 months ago
Can you explain the DC offset more? I understand how a +2.5VDC offset works but am confused about this one. Thanks!
amandaghassaei (author)  joshuaphua19 months ago

I always think of it like this: the signal going into one side of the capacitor causes an alternating excess of positive or negative charge on one side of the cap. The other side of the cap reacts by accumulating opposite charge - this causes an alternating voltage on the opposite side of the cap. Since no current (or a negligible amount) actually gets passed across the cap, the DC voltage on one side does not transfer over to the other side, so the alternating voltage is centered around 0.

thanks!!

punk129010 months ago
I had to replace the TS922 with an LM386. I am trying to get step 3 working. Unfortunately I don't have an oscillator to verify I did things right in step 2. My issue is that when I connect my Adruino to my breadboard with this circuit the power LED dims and my computer no longer sees the Arduino. I tried unhooking the breadboard and then loading the program to my Arduino. That worked fine. When I connected everything back up, the LED came on immediately without ramping up. Any thoughts or ideas for me?
amandaghassaei (author)  punk12909 months ago

sounds like you're shorting out one of the arduino's power pins (the strip of pins near the analog inputs). Double check those.

Ploopy11 months ago
How did you write your code in those squares that you scroll?
  
amandaghassaei (author)  Ploopy9 months ago

it's a feature that's actually no longer supported, sorry! we're looking at new ways to make code easier to embed in the editor, it will happen.

avionics21 year ago
Thank you so much for making it clear now I understand everything very clearly and thank you for making such a concise tutorial. My hat off to you.

take care and please give us more tutorials.
amandaghassaei (author)  avionics21 year ago
thanks!
These chips come in handy if you do this alot. And they can be dasychained to increase the resolution.
http://www.digikey.com/product-detail/en/4116R-R2R-253LF/4116R-R2R-253LF-ND/2565168
I made a 32 bit one for my propeller, but frankly couldn't tell much of a difference.
elbiot1 year ago
Doesn't the Arduino UNO have PWM out? Is there a reason you use an external DAC instead of the PWM?
amandaghassaei (author)  elbiot1 year ago
yes it does, but the PWM only does 0 and 5V output, I wanted to output analog voltages so I could make any waveform shape.
um, you mean you want waveforms at ultrasonic frequencies? The PWM is for putting out any analog waveform, but it seems its a bit slower than the PCM that you use. The digital outs in your Pulse Code Modulation r2r setup only put out 0 or 5 volts, but this leads to an analog voltage of 0-5v. Pulse Width Modulation out just needs a capacitor and resistor (low pass filter) to do the same.
elbiot elbiot1 year ago
Ah, I see its not that simple for good audio. Lots of examples used 8kHz sample rates and things like that. This clever person used dual PWM to get 16 bit depth at a good sample rate. Hardware is still super simple. http://forum.arduino.cc/index.php?topic=142824.0
AntonDan1 year ago
Hi! That is a really nice guide :). I've got a question though.. The output is 8 bit right? I want to make a vocal effect (mostly distortion) pedal.. Will the 8 bit output reduce the quality of the sound (or something like that)? Thanks :)
amandaghassaei (author)  AntonDan1 year ago
yes, 8-bit (especially out an r2r dac like this) is going to sound noticeably distorted/noisy, but it is still a pretty good approximation of the original signal. here is an example:
http://www.instructables.com/id/Arduino-Vocal-Effects-Box/
avionics21 year ago
Great Amanda ! that made it clear now here it comes the second question hope you don't mind. in OCRA1 you put 49 , can you explain how you reached to number 49?

thanks for the good article.
amandaghassaei (author)  avionics21 year ago
my comment on that line has an error, it should say
(16*10^6) / (40000*8) - 1
which means the arduino has a clock speed of 16Mhz (16*10^6), and I set the prescaler to 8 (divide by 8) and the frequency I want is 40000 (divide by 40000) and all numbers are zero indexed (-1)
(16*10^6) / (40000*8) - 1 = 49
avionics21 year ago
Amanda can you explain where you get the numbers in your sine[] ?
amandaghassaei (author)  avionics21 year ago
I wrote a little python script to generate them, nothing fancy, just a bunch of values of 127+127*sin(x)
Amazing tutorial! Thank you so much, I'm using an arduino uno to make a musical sequencer and hopefully this will help me a lot!
also, i'm assuming that if I want to use 16 bit sound i just increase the length of the ladder? i'm using a shift register for serial output because i don't have rapidly changing sound and if i weren't i'd need something like 42 digital I/O pins in total!
amandaghassaei (author)  qwertyfinger1 year ago
theoretically yes, but after 8 bit the noise caused by adding more resistors in your ladder makes the increased resolution kind of pointless. I'd recommend getting an r2r dac ic for this they might even make 16 bit versions. The resistors in those dacs are calibrated to reduce noise.
hpan1 year ago
thank you so much! you're pretty awesome
hpan1 year ago
hola. Amanda.
when you create a sine wave, why do you use
"PORTD = 127+127*sin(2*3.14*t/100)" and let t runs from 0 to 100? I'm a little confused about that. please help. thank you
amandaghassaei (author)  hpan1 year ago
it's not 0 to 100, it's 0 to 255, where 255 is a 5V output and 0 is a 0V output (127 is 2.5V and so on). the sin function always returns something between -1 and 1, so the equation will only fall between 127+127 =~256 and 127 - 127 = 0
faziefazie1 year ago
can I using this mono jack instead of yours?
mono_jacks.jpg
amandaghassaei (author)  faziefazie1 year ago
sure
sparxxer1 year ago
Hi, thx for your awesome work! I have two questions: Shouldnt you refer to CS01 in the line TCCR0B |= (1 << CS11) when dealing with Timer/Counter0? And why does this code not work when im trying to use Timer 1 like this

TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 49;
TCCR1A |= (1 << WGM11);
TCCR1B |= (1 << CS11);
TIMSK1 |= (1 << OCIE1A);

and changing the ISR to ISR(TIMER1_COMPA_vect) ?

amandaghassaei (author)  sparxxer1 year ago
http://www.instructables.com/id/Arduino-Timer-Interrupts/
which code are you talking about? which step?
dcoutts1 year ago
Just breadboarded this. It's neat and easy!
amandaghassaei (author)  dcoutts1 year ago
awesome!
hello Amanda, how are you?
I want to use your project as a basis for my midi guitar. Where do i plug my oscilloscope probe to see if the signal is now digital?
amandaghassaei (author)  samurai_gui1 year ago
hook up your oscilloscope to the opposite side of the 20k resistor attached to arduino pin 8.
gargoor1 year ago
if i use another DAC chip , will i be able to use arduino to program it ?
mtorquato1 year ago
As said in my last comment, i'm trying to do the input/output project together.
How can i do to play in the output (speaker) my voice with a delay?
Like a 3sec ou 5sec delay...
I don't know how to do it in arduino.
amandaghassaei (author)  mtorquato1 year ago
you'll have to use an sd card for extra memory if you want to do a delay that long. The Arduino doesn't have too much memory unfortunately. This is a bit of an advanced project. I'd recommend starting with the no delay code here, getting that to work, and then moving on to sd card (probably with an sd card shield).
amandaghassaei (author)  amandaghassaei1 year ago
check out the comment valcarrara left
valcarrara1 year ago
I had the same problem of mtorquato: to generate 2 to 3 seconds delay in the arduino with a sampling rate of 44100 Hz. This means roughly 120 kbytes for a 8 bit AD convertion or 240 kbytes if more than 8 bits was chosen. However a sd card is not a solution, as amandaghassaei suggests, since the large number of R/W cycles in the sd card blows it with no time. A RAM card should work if you manage to find someone that provides it. I didn’t.
amandaghassaei (author)  valcarrara1 year ago
thanks for the info, I did not know that.
Panichou1 year ago
Hi !
I want to do a digital low pass filtering before putting the signal in the DAC.
I am not quite sur how to handle it in arduino.

Since the most simple form of a low pass filter is
T*ds/dt+s(t)=K*e(t) e : signal to process
s : output signal
T : Time constant
K : Gain filter
I was thinking about doing something like :

int incoming;
void setup(){}
void loop()
{ e = analogRead(A0);
for (byte j=0; j { s[j+Δt] = K*e[j]*Δt/T + s[j](1-Δt/T) }
}

Δt is the sampling rate
But how can I define the upper limit ( N ), since the arduino is constantly reading value from A0 ?

Thanks
amandaghassaei (author)  Panichou1 year ago
hmm, I'm not sure I'm totally following you. can you explain the equation a little more? have you tried this code and looked at it on an oscilloscope? low pass filtering is essentially lowering the slew rate of your signal, so it seems like a good strategy might be to scale down the change in voltage per unit time, and make it so that large changes in voltage over short periods of time are dampened more than small changes. That would have the effect of rounding out sharp corners, which is essentially what low pass filtering is.

this is what I'm thinking:

lastOutput = output;//record the last thing you output
incoming = analogRead(A0);//get new value
output = lastOutput + (1-c*(abs(incoming-lastOutput))*(incoming-lastOutput);//where 0<=c*(abs(incoming-lastOutput))<1
PORTD = output;//send to DAC

not sure if this is quite it, just an idea off the top of my head, but some really interesting ideas here, I may have to experiments with it a little myself... let me know how it works out!
Explain the equation ? Like how i get to the differential equation to the code or the differential equation itself ?
amandaghassaei (author)  Panichou1 year ago
I thought about it a little more, I think what I wrote before is overly complicated, so I'll propose something new. Here is an article on wikipedia that talks about algorithmic implementation of lp filters:
http://en.wikipedia.org/wiki/Low-pass_filter#Algorithmic_implementation
basically you would have:

lastOutput = output;//record the last thing you output
incoming = analogRead(A0);//get new value
output = lastOutput + c*(incoming-lastOutput);//where 0PORTD = output;//send to DAC

does it make sense how I got this from the wiki article? specifically from this part:
"for i from 1 to n
y[i] := y[i-1] + α * (x[i] - y[i-1])"

as for the slew rate stuff, the slew rate is the maximum change in voltage over time of a component. So if you put a pulse signal into a component, you can measure the slew by looking at how long it took the component to output the change in voltage. low pass filtering relates to slew rate because the effect of a low pass filter is to slow down the rate of change of a signal (dv/dt). it;s a little different than slew bc slew often only effects the max dv/dt, anything under this max is unaffected, but filter effects all dV/dt, but dampens higher dv/dt more. does that make sense?

this pic might help:
http://en.wikipedia.org/w/index.php?title=File:Slew-rate.svg&page=1
this is the effect of low slew rate on a pulse, with lp filtering the output would follow the same general shape, but will have exponential curves in its transitions:
http://en.wikipedia.org/wiki/File:Raised-cosine-filter.png
Okay. I am still trying to figure out the whole "slew rate" thing ( I'll ask my teacher to explain to me ) but I get the code. Actually what I wroted was shaped around the same idea, but it makes it a lost simpler to use the constant α !
I'll try the code within the next couple of weeks. I will keep you in the loop !

Thank you SO much again.
amandaghassaei (author)  Panichou1 year ago
basically there are two ways of thinking about low pass filters:

-frequency response- they cut out the higher frequency components of a signal- this is a much more analytical approach, but it is very hard to implement in code, as it requires an fft of the signal
-waveshaping- they smooth out large changes in dv/dt. This way of thinking about low pass filtering makes them much simpler to implement in your code because you only need to store two data points and do some simple math to get the slope

yes I'm really interested to hear the result, definitely keep me posted!
good luck!
amandaghassaei (author)  amandaghassaei1 year ago
sorry the formatting got screwed up, it should read:

lastOutput = output;//record the last thing you output
incoming = analogRead(A0);//get new value
output = lastOutput + c*(incoming-lastOutput);//where c is between 1 and 0
PORTD = output;//send to DAC
I will try but I would also want to get what the code is about : )
I don't understand the line :
output = lastOutput + (1-c*(abs(incoming-lastOutput))*(incoming-lastOutput) ;
How did you come up with it ?
And how is this changing the slew rate ?
mtorquato1 year ago
I have some doubts about this Instructable: 1 - I can't find tu buy a 20K resistor. Is there any problem if i use a 22K resistor in R2R resistor ladder? Can i solve this with another way? 2 - I'm new with Arduino, so i don't know how to code it to output my voice (Digital->Analog)
PS: I'm trying to do the Input and output Instructables togheter, in other words: Talk on the mic->ADC->DAC->Speakers.

Can someone help-me with this?

Thanks
amandaghassaei (author)  mtorquato1 year ago
here's a digikey link for 20k resistors.
22k will be ok for testing purposes, but when you solder this together I'd recommend getting the 20k. If you read my Arduino Audio Input tutorial you can get some info about how to set up the mic input circuit.  The code for mic->ADC->DAC->speakers is at the bottom of step 6 of my audio input tutorial: here.

hope that helps you get started!
skrubol2 years ago
You should really use 1% tolerance or better resistors. Effectively you've only got 5-6 bits of precision with 5%, and about 7 bits with 1%.
amandaghassaei (author)  skrubol2 years ago
thanks, this is a good point that I forgot to address in my post, as you increase the number of bits in your R2R DAC, the tolerance of your resistors becomes important. If you are very concerned with getting true 8 bit out of this DAC then you should definitely get 1% tolerance and you might even think about hand matching them.
Personally, I never really bother with this, I guess the 8-bit R2R DAC is fun for me because it's such a lo-fi solution for generating audio, so I don't worry too much about making it perfect. I kind of accept that each one just ends up with its own unique idiosyncrasies. If I wanted to make a better 8 bit DAC I'd probably opt for a dedicated IC rather than bother with matching resistors. There are plenty of 8 bit parallel input DACs available that would work great with this tutorial and code.
thanks for the comment, that was really helpful!
cefn2 years ago
Can anyone help guide me to select a cheap quad op-amp suitable for this project from Tayda? This page is a good place to start, but I may have made too narrow a search...
http://www.taydaelectronics.com/catalogsearch/result/?q=operational+amplifier+quad+pdip

The aim is to replace the TS924IN, which I'm getting quoted at about £1.59

I'm running a project to 'standardise' a breadboard and stripboard layout for use in an educational context, and audio output (especially with a resistor ladder) would be a brilliant project. However, the one Op-Amp IC you've chosen almost doubles the cost of this as a kit!

Finding something which would be adequate from Tayda's stock would be really handy. Hope someone knows more about reading data sheets than I do.
amandaghassaei (author)  cefn2 years ago
tl074/084 are fine for the buffer circuits, but they won't be able to source enough current to drive any kind of load, and you'll need and +V and -V supply for these instead of just +5. You'll need something with higher output current to drive speakers directly.
I wondered if the component at...
http://www.taydaelectronics.com/tlc274-quad-operational-amplifier-precision-pdip-14-tlc274cn.html
with datasheet...
http://pdf1.alldatasheet.com/datasheet-pdf/view/28886/TI/TLC274CN.html
...might be able to cope, although the need for a negative rail I'm not totally clear on. I appreciate it's more limited at 45mA total (30mA per channel) but more in the ballpark.

Do you think it's possible to set up a circuit with a TLC274CN across 6V (4xAA) giving -3V and +3V which seems a good enough voltage to drive an ATMEGA328-PU as well. Would certainly be quiet, but maybe good enough for a short sample to be played as part of an electronic game, and could add a battery-boosted speaker.

Does this make any sense?
jstarkmuth2 years ago
The misconception regarding "8-bit audio" is due to the fact that the term "8-bit sound" or "8-bit music" refers to music created by computers of the 8-bit era, which does not necessarily mean that the audio of those computers had 8-bit resolution. "8-bit" just refers to the CPU architecture of that time. Computer sound of that era often was more or less "1-bit", i.e. just rectangle wave beeps created by turning the output on and off perdiodically. The SID chip of the Commodore 64 (which is the peak of the "8-bit sound" era), changed that by providing real wave forms and filters.
Correction: 8 bit audio has a sample width of 8 bits. 12 bit audio is 12 bits, 24 bit audio is 24 bit samples.

Higher sample rates allow more resolution in regards to amplitude which directly translates into more dynamic range. Let's not confuse things here.

If Amanda is synth'ing/decoding 8 bit samples, it is 8 bit audio period. 8 bit gave digital audio a bad name in the early days account its grainy sound. 16 bit/44.1kHz is red book CD quality. Most modern audio interfaces allow 24 bit with 44.1-96kHz sample rates.

Most DSP is done internally at 32 bit allowing additional headroom and reducing the artifacts caused by floating point rounding errors
carlmal, everything you wrote is correct, but not a contradiction to my comment. I was just pointing out that the term "8-bit" in a musical context not always refers to 8-bit audio as you explained it, but sometimes to music from the "8-bit era" in general. That kind of music (which sounds like Nintendo etc.) is also referred to as "chiptunes". And that association might erroneously contribute to the bad reputation of 8-bit audio, besides the fact that, of course, 8-bit audio is audibly worse than CD quality (but not as worse as some people think).
amandaghassaei (author)  jstarkmuth2 years ago
yes I agree, the kind of stuff that people usually give the label "8-bit" is really 1-bit.
amandaghassaei (author)  jstarkmuth2 years ago
you're right, thanks for that explanation
Well explained and well presented! Brings me back to EE classes with op amps and DACs that seemed impractical at the time. Thanks!
nice instructable - I've got a cool stereo amplifier stripboard layout that would compliment this HERE it is quite loud though
Tomdf2 years ago
I'm just now delving into audio circuits and these have been a great introduction, ty :D
sfool2 years ago
:) , realy nice tut good job