Friday, February 15, 2013

Chiptunes on a PIC microcontroller

This PIC-based project plays converted .MOD chiptunes. The circuit consists of a PIC18F2685 (chosen only for its large program memory--I could have just as easily used a smaller PIC and an external EEPROM), a DAC, and an LM386 linear op-amp. Also a voltage regulator (from 9V to 3V) and a couple capacitors. The .MOD converter GUI is a program I created in C++ using Qt. It loads in .MOD files, which have several tracks and can contain many "instrument" sound clips. In the .MOD playback, the instruments are repeated at different frequencies to allow some great flexibility. On the PIC, this is not feasible due to memory restrictions, so the PIC synthesizes different instruments using different waveforms (triangle, sawtooth, square, and white noise) with supporting data (volume, diminish, frequency, etc.). The converter GUI allows you to easily see and hear how each track will sound both before and after conversion. It generates .c files as its output, which are easily included in the PIC's project. Every time the circuit is powered on, the PIC pulls a random number seed from its internal EEPROM, generates a random number, and updates the seed. The random number is used to select a song to play from its internal memory. When the song plays to completion, the same process is used to randomly determine the next track. Without RNG, the same songs would play in the same order each time, which is boring. If my webcam had better sound quality, you could hear that it sounds pretty ...



http://www.youtube.com/watch?v=SsBf6Veq-Ps&hl=en

0 Comments:

Post a Comment