E780d78f c5a5 4c95 a218 09e53905da52

invention

Get your Bach on with the Arduino MIDI organ

by pjd

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:

  1. A MIDI controller or PC-based MIDI interface to play MIDI notes.
  2. A 5-pin MIDI interface that translates the MIDI signal to logic bits.
  3. An Arduino module to interpret logic-level MIDI messages and to synthesize notes by playing back a digital audio waveform.
  4. A Small Peripheral Interface (SPI) digital-to-analog converter (DAC) to convert digital audio waveform (samples) to an audio signal.
  5. A Synth Speaker and volume control to play the audio signal.

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:

  • MidiOrgan.ino: The sketch.
  • Farf.h: Farfisa waveforms.
  • Vox.h: Vox waveforms.
  • Tables.h: Note and waveform pointer tables.

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:

http://littlebits.cc/projects/sing-doremi-with-an-arduino-spi-digital-to-analog-converter

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:

http://sandsoftwaresound.net/add-spi-to-littlebits-arduino/
http://sandsoftwaresound.net/add-spi-to-littlebits-part-2/
http://sandsoftwaresound.net/add-spi-to-littlebits-3/


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:

http://sandsoftwaresound.net/arduino/60s-combo-organ-midivox/

Duration: Two days (depending upon skill level)

How To Make It

STEP 1 : Solder 2x3 header and two 1x3 headers to Arduino module

Carefully solder the 2x3 pin header to the SPI pads on the Arduino module. Solder the two 1x3 pin headers to the analog (A2, A3, A4) pads and the digital (D10, D11, D13) pads. See the final result in the picture gallery.

STEP 2 : Assemble the Arduino subsystem

Assemble the Arduino module, button module, dimmer module, fork module, and power module as shown in the project picture gallery. Connect the USB cable to the Arduino module and your host computer. You'll need this cable in order to upload the sketch. If you have the Arduino Coding Kit, then you're good to go!

STEP 3 : Assemble the audio output subsystem

Assemble a dimmer module and Synth Speaker module on a mounting board as shown in the project picture gallery. Turn the Synth Speaker volume control all the way up. Use the dimmer module to control the volume.

STEP 4 : Assemble the DAC breadboard

E6e0a7f0 b85c 4a32 b183 f123f83c43d2

Fbfe06d2 3c6c 47cd 9276 7c35019aafb6

Assemble the DAC circuit on a small solderless breadboard. Follow the suggested breadboard component layout and connections. Check your connections against the circuit schematic to make sure that everything is hooked up correctly. Note the physical locations of the Chip Select (CS, Arduino pin D10), SCK, MOSI, audio OUT, +5V and ground connection points. You will need to connect these points to other subsystems in subsequent steps.

STEP 5 : Connect the DAC to a Proto module

5795a206 bc50 48d7 84ef f7af95039de9

Ceb692de 65b1 4463 a3e1 79d8ed30f981

A Proto module is the bridge between the Arduino, the DAC breadboard and the audio subsystem. There is connection between the Proto module and the DAC breadboard. Connect the audio output point on the breadboard to the outgoing signal from the Proto module. (This is the green wire in the pictures.) Connect the Proto module to the Arduino Pin D1 (TX) bitSnap.

STEP 6 : Connect the DAC to the Arduino SPI pins

A442e179 990b 4059 ae65 2238471e7570

Connect the SCK, MOSI, +5V and ground connection points on the breadboard to the corresponding pins in the 2x3 SPI header on the Arduino module. Only four SPI signals are used. (MISO and RESET are unused and these pins should be empty.) Connect Arduino pin D10 to the Chip Select connection point on the breadboard. (This is the yellow wire in the pictures.)

STEP 7 : Connect the Proto module to the audio subsystem

Connect the output of the DAC Proto module to the input of the audio subsystem using a littleBits Wire module.

STEP 8 : Assemble the MIDI interface breadboard

Ab119e77 0848 4098 af7e 7a939f3624de

601aa71a 9323 497d bc75 bfb995114eff

Assemble the DAC circuit on a small solderless breadboard. Follow the suggested breadboard component layout and connections. Check your connections against the circuit schematic to make sure that everything is hooked up correctly. Note the physical locations of the power (VCC), ground (GND) and MIDI data connection points. You will need to connect these points to a second Proto module in the next step.

STEP 9 : Connect the MIDI interface to a Proto module

11785066 97ad 4b3a b96e fead9a69b2e5

Connect the power, ground and MIDI data points on the breadboard to the top three screw connectors as shown. In the pictures, the brown wire is ground, the red wire is VCC (power) and the yellow wire is MIDI data. Connect the MIDI Proto module to the Arduino D0 (RX) bitSnap.

STEP 10 : Download the source code and compile it

Download the four source code files: MidiOrgan.ino, Farf.h, Vox.h and Tables.h. Put these files in a directory named "MidiOrgan". These four files must be together in the same project directory. Start the Arduino IDE and open the MidiOrgan.ino file. Click the IDE's check mark button to compile the sketch.

STEP 11 : Upload the compiled MidiOrgan sketch to the Arduino

Turn on the power. Click the IDE's upload button to send the compiled sketch to the Arduino. If you run into communication issues, read the troubleshooting instructions elsewhere on the littleBits site.

STEP 12 : Attach a MIDI controller keyboard

Connect the 5-pin MIDI input to the MIDI OUT of a keyboard controller or PC interface. Turn on the controller.

STEP 13 : Turn up the volume and play

After uploading the sketch, wait for the Arduino's LEDs to stop flashing. Turn up the volume control in the audio subsystem. Hit some keys on the keyboard controller. You should hear notes play through the Synth Speaker. Hit the change button to stop stuck notes or to switch between the Farfisa and Vox organ voices.

STEP 14 : Customize!

Here are some ideas... Replace the 5-pin MIDI interface and change the sketch to use MIDI over USB. Add new waveforms (22,050Hz, 16-bit, mono). Add littleBits synth modules to mangle the sound. Add an LED module to display note status, the organ voice, etc. Don't want to use MIDI? Use a littleBits Synth Keyboard instead.

Related Projects

Sound Activated Christmas Tree #inventasmarterhome

Basically what the title says, a sound activated Christmas Tree. You need an IR transmitter and plug, it wasn't showing up.

#Bitwars - Star Wars 5: On Hot,Han solo and Chewbacca VS Droid

We decided to reproduce a scene in star wars 5 that is Hot Han solo and Chewbacca VS Droid.In this scene, they are in a snow storm...

Animalogie project

Animalogie prototype is distributor of biscuits made for pets.  Your pet just has to put its paws on a board and animalogie...