Design/ Testing




MCU Synthesizer

Background Math

The main background math we needed to successfully finish this project was 8:8 fixed point notation and mathematic representation of waveform. For the fixed point math we mostly referred to the ECE 476 web page[1]. The main idea is that we used Int to represent floating point values by putting the binary point between bit 7 and 8. This gives us a range of +/- 127 with a resolution of .00396. By using floating point math we were able to dramatically decrease the amount of computation in comparison to floating point math. This allowed us to fit all the code we needed into the sound generation interrupt.

Waveform Creation

In order to create the different waveform we used a basic x-y map layout of the wave via a 256 size char array, where each array represents a “x value” and the “y-value” is stored in the char. Once we have one period of the wave we could then just keep repeating it to make our sound wave.


The Attack, Decay, Sustain, and Release times are the most common parameters in a generic synthesizer. Attack is how fast the amplitude of the waveform raise when a note is played. Decay is how fast the amplitude drops to sustain after the attack. Sustain is the amplitude of the note when held down. Release determines how long the not persists after the user has stopped pressing the note. Together these four waves determine the sound of the note. Changing the ADSR will alter the waveform entirely. For example, raising the Attack time will create a more hollow/windpipe sound, while changing the decay will create more of a string sound. Release will bring more of a resonance sound and the sustain level will determine if the sound is more like a pluck or a press. This enveloped modulation can be seen the following picture.


Midi is a communications protocol designed for digital instruments. Midi devices do not transmit audio signals but instead digital event messages that tell the receiving end what the device is trying to do. Midi messages are sent via a serial connection at 31,250 bits per second. Each midi byte consist of 1 start bit( zero), 8 data bits, and one stop bit (one), there are no parity bits. There are many messages that a midi device may send, which vary in length and content. With all messages the first byte is always the status byte, which tells the receiving end what to do with the data that follows. The high nibble of the status byte is the information about what event to perform and the low nibble says which channel to perform that event on. After scoping the output of our keyboard we found that it sends all status bytes with a low nibble of 2, meaning perform event “status byte high nibble” on channel 2. Some common status bytes include NOTEON (0x92), NOTEOFF(0x82), PITCHWHEEL(0xE2). The most common messages consist of 3 bytes, a status byte followed by a note byte followed by a velocity byte. The velocity byte is an encoding of how hard the key was hit to find out how loud to play a note, the range is from 0 to 127. This 3-byte message would be sent when pressing a key on a midi keyboard. For example, if you pressed middle C semi-hard on the a midi keyboard it might send a 3-byte message of 0x92, 0x3C, 0x64, which would correspond to a message that says play middle C at a relative loudness of 100. When a note is released a 3-byte message with NOTEOFF at the status byte is sent. Some keyboards, i.e. the one we used, send a NOTEON status byte when a key is released but with a velocity of 0, this is interpreted as a NOTEOFF message, telling the receiving end to stop playing a note. For our purposes the only messages we concerned ourselves with were messages with a status byte of NOTEON.

Music Notes

The basic princples we needed to know about the frequencies is that starting with the note A(440 Hz), we can can increase or decrease the halftone by multiplying or dividing the value by the twelfthroot(2). From there we have the frequency for all the notes in the scale.


Polyphony is the ability to run mutliple channels of music waves at the same time. This allows us to hit chords and run several musical tunes simultaneous. A high number of polyphony is desirable.