Published on February 13, 2017
The MIDI Organ is a 5-voice musical organ that responds to MIDI messages sent to it by a separate, external keyboard or PC. It has two different organ sounds -- Farfisa and Vox -- taken from classic, 1960s "combo" organs. Check out the two MP3 demos to hear the sounds in action (Bach is Farfisa and DaVida is Vox).
The MIDI Organ consists of five subsystems:
MIDI is an established standard for communication between musical instruments. The MIDI data stream consists of messages that tell the receiving instrument which note to play (note on), which note to stop playing (note off) and many other operations. MIDI data is a stream of 8-bit bytes transmitted serially through a current loop.
The 5-pin MIDI interface translates the current loop data to the regular logic signals understood by the Arduino. The interface consists of a few simple components and is assembled on a solderless breadboard. The incoming side of the circuit receives the current loop from the sending MIDI device. Conversion is performed by an optoisolator. The outgoing side sends a logic level bit-serial data stream to the Arduino module. The Arduino receives the serial data stream on pin D1 which is the hardware serial port input (RX).
The sketch calls the Arduino MIDI library to read, recognize and respond to incoming MIDI messages. When the sketch recognizes a MIDI note on message, it finds an idle note generator and configures the note generator to play the note. When the sketch recognizes a MIDI note off message, it turns off the note generator which is playing the note.
The basic synthesis technique is interrupt-driven sample playback. Arduino TIMER1 generates interrupts at the sampling rate (22,050Hz). The interrupt handler scans five note generators. If a generator is active, the note generator reads the next sample from its assigned waveform and adds it to a variable that mixes samples from the other waveforms. The interrupt handler sends the mixed sample to the DAC subsystem via SPI. Finally, the interrupt handler goes back to sleep and waits for the next sampling interrupt.
A note generator is just a little bit of code that picks the appropriate waveform sample at the appropriate time. Each organ type (Farfisa or Vox) has twelve basic pitches corresponding to the twelve basic pitches of the musical scale. A tone generator moves an array index through the waveform for a basic pitch according to a step size as determined by a MIDI note. The step size (having values 1, 2, 4, 8, or 16) determines how fast the tone generator moves through the waveform. The bigger the step size, the higher the final pitch.
The Arduino sketch consists of four files:
You must download and include the ".h" files in order to compile the sketch. The ".h" files are needed for a complete program. All files should be downloaded to the same project directory named "MidiOrgan".
The DAC subsystem uses the same digital-to-analog converter as the DoReMi project. Please see this project for more details about the DAC circuit:
The DAC is a Microchips MCP4921 integrated circuit. The DAC and the few extra components that are needed to make it work are assembled on a solderless breadboard. The audio signal from the DAC subsystem is sent to the audio subsystem through a Proto module attached to Arduino pin D1. The Proto module sends power and ground to the audio subsystem as well as audio.
This project makes use of the "bonus" signals on the Arduino module: the 2x3 pin ICSP/SPI port and the digital output pins (D10, D11 and D13). You must solder pins to the Arduino module to make use of these signals. You only need to do this once and from then on, your Arduino will be amazingly powerful! Here are links to some helpful tips about soldering pins to the Arduino module:
This is project is based upon my first version of an Arduino-based combo organ. Follow the link below for more details including the design of the synthesis engine:
Duration: Two days (depending upon skill level)