Raspberry Pi as MIDI to CV device.
I programmed the Raspberry Pi to control voltage and respond to MIDI so I can play the Korg Monotron with a keyboard.
The Korg Monotron is a good sounding synthesizer for a relatively cheap price (~$40). One drawback of the Korg Monotron is that it uses a ribbon controller to determine the pitch so it is very hard to control the pitch accurately, and almost impossible to be in tune by yourself.
Luckily, Korg has developed this little synth with hacking in mind. These instructions will show you how to use a Raspberry Pi as a cheap MIDI-to-CV controller so you can use the Korg Monotron just like any other MIDI instrument.
This is the first DIY MIDI-to-CV controller that allows you to automatically tune the Monotron voltage-to-frequencies and only has three components (and no PCBs!). Other solutions - like the MIDI-IF kit or Arduino-based midi2cv - require extensive soldering, dozens of components, and require manual tuning.
Overview
Adding MIDI to the Korg Monotron basically requires converting MIDI input to voltage. The following introductions will work on several CV synthesizers (I think) and are not necessarily specific to the Monotron. Here we are using a cheap DAC (the MCP4725) to send voltages from the Raspberry Pi. The Raspberry Pi uses a Python script midi2cv.py which listens for MIDI and controls the DAC.
The magic trick here is that I added a tuning function into the Raspberry Pi (in midi2cv.py) so you can automatically determine the relationship between voltage and frequency to tune any CV synth. It works by connecting the audio output of your synth to the Raspberry Pi (via USB audio connector) and then computing the FFT to find the fundamental frequency of tones controlled by various voltages.
Below is a step-by-step instruction to take a Korg Monotron and a Raspberry Pi and make it MIDI capable. There are only two solder points and no PCBs and no breadboards!
Requirements
- Raspberry Pi (~$15 on ebay)
- USB audio adapter (~$16, but ~$5 if you by used)
- Korg Monotron (~$55)
- MCP4725 (~$5)
- Female-to-female jumper cables (~$6)
- Soldering iron (~$17)
- MIDI keyboard (optional)
Part 1: Hacking the Monotron
We need to first be able to send voltages to the Korg Monotron. To do this we need to connect a wire with the hot voltage and a wire with the ground to the Monotron using soldering.
Solder two wires to the Monotron PCB
Simply unscrew the back of the Monotron and pull out the back. There are four screws, two of them are next to the batteries.
Take the Monotron apart, carefully, and you will see the back of the PCB has some gold pads with labels! Korg designed this PCB for us to hack :). Solder one wire to the gate
pad and solder another wire to the GND
pad (both wires should be female on the opposite end).
I realize we are not using pitch
, but for some reason gate
also can be voltage-controlled and acts as a gate (if voltage > 0) and pitch. If you want to watch someone solder, check out this great Youtube video for how to solder to the Korg Monotron.
Now just close it up, and move the wires so they stick out under the volume control. You can screw everything back together, just make sure not to go too tight.
Hook up wires to the Raspberry Pi
First let’s wire up the the MCP4725 to the Raspberry Pi. Attach MCP4725 SDA
, SCL
, GND
, VDD
to the Raspberry Pi’s GPIO 2 (SDA)
, GPIO 3 (SCL)
, Ground
, and 5V power
, respectively. Check the Raspberry Pi pin-out schematic for more details.
Now attach the Monotron “gate
” wire to the “VOU
” of the MCP4725. Attach the Monotron “GND
” wire to any ground pin of a Raspberry Pi (schematic).
That’s it! No extra breadboard or PCBs necessary!
Part 2: Tuning the Monotron
The Monotron uses a voltage controlled oscillator (VCO).The Monotron voltages can be modified by the INT
and the trim pot and these will affect the frequencies for a given voltage. Every time these are altered (or anytime it seems out of tune), you need to tune it. That is, you need to determine which voltage will produce which frequency.
Luckily, instead of tuning each note manually, we can use the Raspberry Pi to self-calibrate it for us!
Installing pre-requisites on Raspberry Pi
Use SSH to get into your Raspberry Pi and install the following prerequisites:
> sudo apt update
> sudo apt install python3 python3-pip python3-numpy portaudio19-dev sox gnuplot ffmpeg
> sudo -H python3 -m pip install loguru click mido python-rtmidi adafruit-circuitpython-mcp4725 termplotlib aubio
Now download the midi2cv.py
script:
> wget https://raw.githubusercontent.com/schollz/midi2cv-pi/master/midi2cv.py
Great, now we are ready to tune the synth.
Gettin’ in tune
Connect the USB audio to the Raspberry Pi. Then connect the headphone out of the Monotron into the recording line-in with a stereo 1/8" cable.
Important: Make sure to change the Monotron settings so it is outputting pure tones. Use the following settings for each knob (0 means all the left, 100 means all the way right):
RATE
: 0INT
: anywhere you want (don’t change it after tuning, though)CUTOFF
: 100TIME
: 0FEEDBACK
: 0
Now ssh into the Raspberry Pi and run the following Python script:
> python3 midi2cv.py --tune
This will take about 30 seconds as the Raspberry Pi cycles through voltages (1-5V) while recording in resulting audio. The audio is captured using the USB audio adapter. The captured audio is analyzed using a FFT to determine the fundamental frequency. These voltage-frequency pairs will then be plotted and fit with an exponential curve.
The fit from this curve is saved onto the Raspberry Pi so that when you play the Monotron it will be able to convert the MIDI to frequency and then convert that to voltage.
Now you are ready to play!
4. Play the Monotron!
Using a MIDI keyboard
Simply attach a USB MIDI keyboard to the Raspberry Pi and then run:
> python3 midi2cv.py --play
Now the keyboard will automatically trigger the Raspberry Pi to set the voltage of the Monotron, in tune!
Using MIDI sequencing
A keyboard is not necessary to play the Monotron. You can use another program I wrote to sequence MIDI instruments from a simple text file: miti.
First make sure you have portmidi, and download the binary for miti
(or you can build it yourself):
> sudo apt install libportmidi-dev
> wget https://github.com/schollz/miti/releases/download/v0.4.1/miti_arm.tar.gz
> tar -xvzf miti_arm.tar.gz
> sudo mv miti /usr/local/bin/
Then create a new sequencing file. The sequencing is easy to write and understand and documented thoroughly. Here we will make a simple three-chord arpeggio.
In a file names song1.miti
write:
pattern a
instruments midi through
tempo 120
legato 95
F2 A C F A C F A C F A C F A C F
E2 G C E G C E G C E G C E G C E
D2 F A C D F A C D F A C D F A C
D2 F A C D F A C D F A C D F A C
The “midi through
” indicates that we will send the output to the MIDI through port. Now, in one terminal run the midi2cv
program:
> python3 midi2cv.py --play
And in another terminal run miti
to start sequencing:
> miti --play song1.miti
That’s it! You should hear some music. You can edit the song1.miti
file in real-time to make any changes to the sequencing.
Questions?
If you find any problems, feel free to let me know. Find me on instagram (@infinitedigits) or Twitter (@yakczar). DMs are open.