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
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: