Audio out using PCM (synth trial runs)

Well I've run into some issues with this project that will probably require an external chip to solve.

The reason that most computers have a dedicated sound processing card/chip in addition to the cpu is because the logic code needed to create different wave forms can't be run quick enough directly from the cpu itself.

I ran into the problem with the Arduino and cant really find an easy fix. Because the processor only runs at 16 or 20 MHz, it's hard to have accurate frequency control over any oscillator code you write.

For example, if you setup the "PlayMelody" tutorial (http://www.arduino.cc/en/Tutorial/PlayMelody) and use a musical tuner to check the frequencies (such as the 'a' at 440 hertz) you'll find that the frequencies are lower then they should be. The A given in the code doesn't actually give a frequency of 440. This is due to the time delay given while the rest of the code runs each loop. This could be fixed in the PlayMelody tutorial because it's playing a tune that's coded in.

However, the method shown in the PlayMelody tutorial can't be used for realtime frequency generation. The amount of time spent by the Arduino's CPU when executing the analogRead() function puts a HUGE kink in how high the frequency can be.

I set up some code that would switch one of the analog outputs from high to low on every alternating loop. The highest frequency I got (using a software oscilloscope) was rather high. I believe it was in the range of 34k hertz (above the human hearing).

As soon as I added the code to read in a value from an analog input, a delay was added into each loop that made the highest frequency square wave peak out at about 148 hertz (not anywhere near high enough).

I'll redo the experiment and get the exact numbers after I sign up for classes this afternoon but I know for a fact that the numbers aren't high enough for any real time signal generation using the equipment the Arduino comes with alone.

However, for those of us that would like to make synthesizers using the Arduino, there do exist frequency generator chips! A friend sent me this link last night (http://www.makezine.com/blog/archive/2007/01/how_to_make_a_f_2.html) which hints at two such chips (the Maxim MAX038 and the Exar XR2206). I'm currently looking for some samples of either chip to test in conjunction with the Arduino.

Another possible option is to find a "broken" game system from the NES generation. The synth sounds used in many video games is quite tasty for some styles of music and it may be feasible to use a chip from one of those systems.

I'll post again when I find a chip that'll do the job I need.

Tateu: sorry but the code I have doesn't really produce reliable waveforms. I can, however, try to draw up a circuit for a low pass filter along with the formulas needed for the component values.

Anyone know of a good circuit design software...?

~jamis