ColdFireSynth

I got it in my head to make a digital synthesizer using a leftover microcontroller (Freescale JM128 Coldfire V1) from a class I had taken previously. So off I went. I wanted something that I could use a MIDI keyboard with. While snooping around a local store, I stumbled upon this:

Akai SynthStation 25

It’s a 25 key keyboard which is supposed to work with your iPhone. Additionally, it works as a USB MIDI keyboard! The microcontroller I was using had support for USB device and host mode, though getting it working was a real pain. Freescale supplies a small USB stack for the microcontroller, and after a week of toiling I finally got it working correctly. One of the problems I had run into was that the D+ and D- pins of the USB had to have pulldown resistors in order to work correctly, something that took me a few days to figure out.

USB!

I used tusbsnoop with the keyboard connected to my computer to get the vendor and product ID as well as the device class and endpoint information for the USB protocol. I had to put this information into a struct for the USB stack to use it correctly to connect as follows:


static USB_HOST_DRIVER_INFO DriverInfoTable[] =
{
 {
 {0x09,0xE8}, /** Vendor ID for Akai*/
 {0x00,0x7A}, /** Product ID per synthstation USB kb */
 USB_CLASS_AUDIO , /** Class code */
 USB_SUBCLASS_AUD_MIDI_STRM, /** Sub-Class code */
 0x00, /** Protocol */
 0, /** Reserved */
 SynthStationUsbEvent /** Application call back function */
 },

Anyway, with that all set, I connected everything up. Amusingly, the space in the SynthStation where you put your iDevice into was just about right to slip a small breadboard into, which made my life much easier.

Makin’ noise

Alright, so I got the thing reading the keypresses, but now I have to make some noise. I decided to use a technique called digital direct synthesis (DDS) to generate my waveforms. I used this wonderful guide to help me out, thanks electricdruid! I hardcoded a sine wavetable, and generated the tables for sawtooth, triangle and square waves. All this was great but, how do I get sound out of this thing?

To get sound out of the microcontroller would require using a digital to analog converter (DAC), which is the reverse of an analog to digital converter (ADC) which is found on many microcontrollers as a built in peripheral. I found a guide online on how to use a single PWM pin to create a low fidelity 1-bit DAC, and tried it. I was not too happy with the sound!

Eventually I decided to buy a DAC and settled on the Microchip MCP4921, which is a 12 bit DAC using SPI. I created a basic RC low pass filter to clean up the output and wired everything up nicely.

How is the sound generated? The basic idea is that I had an interrupt on a 22kHz timer that would look into the wavetables to generate a sample, and then this sample was fed to the DAC using SPI. I chose to use 256x1byte entries to store 1 period of each wavetype.

Here’s what it looked like now:

The micro, the DAC, a 24 character LCD for later use, and the RC filter attached

 

I went ahead and added a character LCD for later use. You can see a small 1/8″ audio jack that I hackishly put in to test the sound synthesis.

More to come later!