Hi Adam, About 4 years ago I made a synthesized music box using a 16F876, an 8 bit DAC, audio amp, LCD, and a serial EEPROM. It turned out that in the end it sounded so good that people were surprised that it wasn't a real music box. When they saw it, their reaction was "yeah, so what, it's a music box" until I showed them that there were no moving parts inside :) Probably overkill for your app as it was designed to play four simultaneous voices (two lines of music along with decay from the previous note on each). However you might be able to scale up the idea. PWM would probably work fine as a DAC method for your case, too. The basic idea was simply recording samples into the serial EEPROM and playing them through the DAC at appropriate times. In my case, I stored two octaves worth of notes (24 tone snippets, since I wanted the full chromatic scale). Each snippet was long enough that repeating it over and over didn't cause audible discontinuities. Inside the PIC I would multiply each snippet by the output of an "attack/decay" lookup table to give a realistic sounding envelope. The output of each of the four channels was then added and scaled to prevent saturation, and then fed to the DAC. The "snippets" were generated by a PC-based C program which added together several harmonics. I initially tried to model an actual music box or even a plucked piece of metal but in the end, the best sound came from just tweaking the harmonic amplitudes and listening to it. This program directly generated a .HEX file to be programmed into the serial EEPROM. The serial EEPROM also contained the musical "score" for each piece (about 8 in total which could be selected via the LCD and buttons). The scope specified which note (or a rest) to play at each timestep, and for how long to play it. Playing it longer didn't mean changing the attack/decay, it just meant how long to wait before loading the next note (like a piano). If anyone is interested, I can dig up the source code and probably a schematic. Unfortunately, since it was a one-off, and I needed to get the project working in time, I ended up slightly overclocking the SPI to the serial EEPROM since there was a tremendous amount of data flowing from it into the PIC. Sean On Wed, Dec 17, 2008 at 9:49 AM, M. Adam Davis wrote: > So my 4yr old has told two santas (with about a week inbetween) that > he wants a toy car that goes choo-choo. Even the santas questioned > whether he didn't want a train - he was pretty specific. > > So I can't easily dismiss it as merely a whim of the moment. > > The easy way out is to buy both a toy car with sound and a toy train > with sound, and swap the modules (Maybe put the train with car sounds > into a toy donation box...? ;-D ). > > Alternately I can spend $30-$80 on a 'professional' sound generator as > used in model trian layouts. A little on the expensive side, though. > > But I'm curious what options are out there now in terms of building it > myself. I can use a PIC and a few different methods. There are sound > chips available elsewhere. What have you all been doing lately to > generate sound? The only reason I might not do this is time - to make > it very low power, sound good, etc I would hae to spend more than a > little time doing the design right. On the other hand, if done well I > can see it as something I could add as a kit to my website for others > who find themselves in this bind. > > Brainstorm away! > > -Adam > > -- > Please rate and vote for my contest entry: > http://mypic32.com/web/guest/profiles?profileID=50331 > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist