Electronic – How to send multiple signals to a DAC

dacsound

So in my embedded systems class we were working with DACs and we build a resistor ladder. We then sent data to the resistor ladder using timers to generate sine waves at a certain frequency. This produced the sound we wanted to hear.

Since then I've build a 10bit DAC resistor ladder with a sampling rate of 1024Hz. I'm trying to send two notes at once to the DAC. I take the current value from the wave of one note, add it with the value of the wave of the other note, scale it appropriately so it doesn't exceed the max range, and then send this combined number to the DAC.

Unfortunately, this is creating a very gross distortion sound. Buried in the noise I can hear the chord I'm trying to produce, but why is there so much noise in the first place? Shouldn't making a chord be as simple as adding the sine waves together?

Best Answer

A sample rate of 1024 Hz is very low. You will need to filter the output of your DAC with a low-pass reconstruction filter that has very little response (at least 30dB of attenuation) above 500 Hz in order to eliminate the "image" frequencies created by the sampling process.

Suppose you were trying to generate tones at 100 Hz and 150 Hz. The raw output of your DAC will also have frequency components at

  • 1024 - 150 = 874 Hz
  • 1024 - 100 = 924 Hz
  • 1024 + 100 = 1124 Hz
  • 1024 + 150 = 1174 Hz

in additional to higher-order components. These additional components are not harmonically related to your original tones, so you perceive them as "noise".

Normally, a DAC for audio applications would have a sampling rate about 10x to 100x the rate you're using, with a matching output filter. Commonly used sample rates include:

  • 8 kHz (audio up to 3400 Hz) - called "voice grade" because this is used for telephone circuits.
  • 16 kHz (audio up to 7500 Hz) - AM radio grade
  • 32 kHz (audio up to 15 kHz) - FM radio grade
  • 44.1 kHz (audio up to 20 kHz) - "CD quality"
  • 48 to 192 kHz - professional audio rates
Related Topic