Micro Midi Synthesizer




Introduction: Micro Midi Synthesizer


This instructable demonstrates the use of the VLSI VS1053b Audio and Midi DSP chip in its real-time Midi mode. In this mode it acts as a 64 voice polyphonic GM (General Midi) Midi synthesizer. An Arduino Uno standalone micro controls an OLED display, three buttons (Function Select and Up or Down, and passes the Midi data stream through to the audio DSP. The music board chosen was the Adafruit VS1053 codec breakout board, but a Sparkfun music breakout board was also successfully tested. The Adafruit VS1053b libraries were used instead of the much larger SFEMP3 Library (recommended by Sparkfun even though they also have their own set of libraries), because I found the Adafruit code easier to understand.

Most of the code used to control the audio/midi DSP was developed using an Arduino Uno connected to the audio/midi breakout board through a breadboard. After the functions were found to work satisfactory the Uno was used as a programmer for a standalone ATmega 328 which was then put on a small 30x20 size Veroboard together with the 6N139 opto-isolator IC required on the Midi input socket (a 5 pin DIN). Also connected was a small (64x48) OLED shield, three buttons, a Midi activity LED, and a +5 volt barrel connector for power and the audio stereo output connector added. The power requirements are very modest - about 20 mA at 5 volt.

Step 1: Parts List

ATmega328 Micro 28 pin DIP + 28 pin DIP socket
6N138 or 6N139 optoisolator + 4 pin DIP socket
Wemos 64x48 I2C OLED Display or similar
Adafruit VS1053b Codec breakout board
3 miniature pushbuttons
5 pin DIN Midi socket PCB mount preferred
Small LED any colour.
Barrel type power socket for the 5v supply
Stereo audio socket to connect to an amplifier or headphones
Resistors: 7 x 10k, 2 x 470 ohm, 2 x 220 ohm
Capacitors: 0.1uF 50v plastic, 10uf 25v electrolytic, 2 x 27 pF ceramic
Small pieces of Veroboard (30 strips by 20 columns, and 4 strips by 16 columns), ABS plastic enclosure about 85x55x25mm, wiring and a few screws nuts and washers.

Step 2: Construction

The lid of the enclosure houses the OLED Display, the three buttons that are mounted on another small piece of Veroboard, and the barrel power connector. The main Vero circuit board has two holes to fix the Music breakout board above the ATmega328. For connection details please refer to the Fritzing strip board diagram.

The programmed ATmega328 (please refer to the next section for the code) is then inserted into its socket followed by the 6N139 and everything is connected up.

The LED is used as a Midi activity indicator and was mounted on the front side of the enclosure. It is connected to the D2 output of the ATmega328 via a 470 ohm resistor.

The OLED Display use the 3.3 volt output from the Adafruit board for power - it requires less than 20 mA.

Try swapping the two Midi Din connections if you do not hear any audio when you first use the synth.

Step 3: Software

Details of the sketch that should be uploaded to the ATmega328 is given in MidA.ino. There are seven functions available:

Option P: Change Program - change the GM Midi Instrument from 1 to 128 (I used 0 to 127) such as a Piano or Synth sound.
Option B: Change the Instrument bank between Melodic (Bank 0) and Percussion (Bank 1).
Option V: Adjust the volume from 1 to 10.
Option C: Change the Midi channel that the Synth will respond to. The choices are Channel 0, channel 1, channel 9 (percussion), channel 0 and 9, and channel 1 and 9.
Option R: Switch the Reverb effect on or off.
Option S: Save the current parameters to Eeprom memory (Up) or Read (Down) it back from the Eeprom memory. This is because settings are otherwise not saved when powering down.
Option X: Send an all notes off message (Midi Reset).

An eighth option is not yet implemented - this will bypass the ATmega as a Midi filter and connect the output of the optoisolator directly to the Rx pin of the DSP board.

Note that the VS1053b boots in a real-time Midi mode by loading a 1039 byte compressed patch during booting - this also increases the size of the Midi buffer and filters system exclusive Midi data bytes. Details of this patch can be found on the VLSI website.

A slightly modified version of the Adafruit Graphics library had been used to cater for the 64x48 pixel resolution of the OLED Display - please refer to the links given at the end for Mr Mcauser. A list of the required libraries is given in the sketch code.

Importantly when the sketch is executed for the first time on the ATmega328 whether it is on an Uno or standalone, the code will load parameter presets from the ATmega328 Eeprom that may not be valid. In that case you can either write all zeroes to the Eeprom using the X option with the down button, or comment out the line in the void setup function that loads values from the Eeprom when it is first started, adjust your instruments etc. to your liking, and then save your presets with the S option Up button.

Credit is given to all the persons and entities mentioned for their code and libraries..

Step 4: Links

Step 5: Using the Sparkfun Board With the Adafruit Libraries

The table in the picture explains how to connect either the Adafruit or the Sparkfun Music Boards to use another library.



    • Tiny Home Contest

      Tiny Home Contest
    • Metalworking Contest

      Metalworking Contest
    • Fix It! Contest

      Fix It! Contest

    18 Discussions

    Hello! I hope you are fine. Again I started doing this project with a new MIDI keyboard with MIDI Port Available.

    Dear, kindly tell me where is the fault; as I have made a MIDI Circuit with 6n138 IC following nuts and volts tutorial and its is working with Arduino with default example program MIDI Input but the same is not working when I load your Code to make Micro-Midi-Synth with Breakout VS1053 and Arduino Mega. And I have added "MIDI.h" library with your code.

    Can you please tell where is the fault or can please provide you email so that I can send you the code.

    thanks & regards

    5 replies

    Hello Sammym1 - Please give me details about how you constructed your circuit? - you will not need the Arduino midi library with this synth. If possible make4 sure the synth is working before you test it with the Midi keyboard - is the display menu reacting when you press the function button for example?

    Dear I am using 16X2 LCD LCD is showing the name of Instruments like : Accoustic Grand Piano, Gunshot but possibly function button is not working. And, for you information I used 6N138 output to Mega - RX pin and VS1053 Breakout RX Pin to Arduino TX pin but no audio output. Kindly help.

    kindly provide your Email ID so that I can communicate.

    thank you for your kind attention. I will take some time and then I will confirm you again. thanks & regards

    Ok if I understand your setup correctly you changed two things - the display and the Arduino is not an Uno but a Mega?

    You can try this:

    Connect the output of the 6N138 via the 220 ohm resistor directly to the VS10563 RX and disconnect the Mega TX from the RX of the VS1053

    Make sure your keyboard is transmitting on midi channel 0 and see if you get any audio output - if the VS1053 is in the correct real-time midi mode it will work without the mega sending it midi notes. You still need the mega in the beginning to load the VS1053 real-time midi code though

    Are you using the Adafruit VS1053 board?

    Hello! At First Thanks for this great project.

    In this project I want to to add a "USB-A Jack" for receiving MIDI Message from the Korg MS-20 Synth to the Arduino. Can you tell me the way to to add that ?


    8 replies

    I searched for the Korg MS20 and it seems to be a very nice analog synth with a pitch to CV converter. That means if you can find a CV to Midi note converter (they must exist) you can send Midi note messages to the Arduino micro-midi box.

    Note that the Arduino midi box does not transmit any midi messages - it only receives them and produce the corresponding voice output

    I am not sure how you can add a usb connection (in or out) to the Korg - an Arduino teensy can definitely translate the CV of you Korg and send them out through either a midi interface or its own usb port. For input there are Teensy circuits where the Teensy acts as a USB to midi converter and if you add a Midi to CV converter you can talk to your Korg via a PC usb interface

    I do not have current links but search for "Teensy Midi CV concert" perhaps

    Best wishes

    Tobias van Dyk

    Hello! Thanks you for your reply which made me clear about the doubts. Till now I have not connected the MIDI Port as I do not have midi keyboard right now.

    However, I tried to upload your code in Arduino and it sucessfully loaded but I replaced the OLED with 16*2 Character lcd and it worked and displayed "Percussion etc" but the buttons are not working as I am pressing the buttons but the changes are not reflecting on the LCD.

    My questions are :

    1) Are the resistors mandatory with Arduino Uno for working with the buttons ? If not then where the fault might be occured ?

    2) Is it mandatory to flash the sd card of VS1053 with the VLSI Patch to get the output?

    Thanks & Regards

    You will need a Midi connection to use the synthesizer but first get the buttons and VS1053 working
    1. The pull-down resistors are needed because in the code you have:
    if (BtnNextState)
    i.e. the button when pressed pulls the input high else if you used the internal pullup resistors on the Arduino you must change the code
    if (!BtnNextState) and connect the button to the ground

    2. Yes the patch puts the VS1053 in Real-time Midi mode and allocates a larger Midi input buffer.

    The patch is loaded automatically every time you run the sketch but it is not written to VS1053 flash memory - it is written to the VS1053 user ram.

    If you know how to do it comment out most of te code in the loop function and put in a small test to check if you can detect whether the button presses are recognized

    Best wishes
    Tobias van Dyk

    Sorry I only just now saw the SD Card part - you do not need an SD card - you can take it out

    That means your code is all and everything which means patch written in the form of code and I just need to connect midi port to get the signal from the instrument ?


    Yes the code includes the VS1053 patch and you do not need to load anything else
    Best wishes

    That means I just need to download the patch from the VLSI website and put into the root sd card of VS1053 - or any other procedure ?


    No the patch is included in the sketch it is the const static word plugin[1039] PROGMEM = { part of the code
    You do not need any SD cards to run the sketch

    best wishes

    Sorry I only just now saw the SD Card part - you do not need an SD card - you can take it out

    Fritzing Veroboard updated: Earth from Adafruit VS1053b now to correct hole and Midi activity LED added.

    Thanks for sharing :)