Vintage Phone USB MIDI Controller

This is the USB MIDI controller version of the Vintage Phone MIDI Controller.  As the USB MIDI support is much easier in CircuitPython than MicroPython, this is also a version of the keypad controller code for CircuitPython too.

2021-04-05 17.01.50

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

These are the key tutorials for the main concepts used in this project:

If you are new to microcontrollers, see the Getting Started pages.

Parts list

  • Raspberry Pi Pico
  • Old “keypad” phone
  • USB MIDI device
  • Breadboard and jumper wires

The Circuit

This uses my “Pico-d” old phone keypad as fully described here: Vintage Phone MIDI Controller.  The only difference is that this time we don’t need an additional MIDI interface, as we’re going to use the USB connection.

I’m still using my “cut down” Raspberry Pi Pico, as described in that previous post.

Note: make sure you are using a USB lead that supports data.  My first attempts turned out to be using a power-only lead which is no good for this project.

The Code

The core principles of the code are the same, but there are a number of changes required to complete the switch over from MicroPython to CircuitPython:

  • Use of “machine” and “machine.Pin” is replaced with “board” and “digitalio”.
  • The use of “busio” for the uart is removed, as we’ll be using the USB MIDI interface instead.

Once the Pico has been set up to use CircuitPython (full details here), then it will need the Adafruit MIDI library installing (which is available from here).  I only copied over the adafruit_midi directory from the “lib” area to the “lib” area on my CircuitPython drive on the Pico.

To use USB MIDI in CircuitPython is relatively straightforward.  It needs initialising, which is largely a case of doing the following:

import usb_midi
import adafruit_midi
from adafruit_midi.note_off import NoteOff
from adafruit_midi.note_on import NoteOn
from adafruit_midi.program_change import ProgramChange

usb_midi = adafruit_midi.MIDI(
    midi_out=usb_midi.ports[1],
    out_channel=0
)

Then I can use the usb_midi.send() function with the MIDI message helper functions NoteOn(), NoteOff() and ProgramChange().

To be honest the biggest pain was actually moving all the IO handling from machine.Pin to the CircuitPython digitalio routines and having to use logical names (like “board.GP20”) instead of simple pin numbers (20), but that could be my lack of understanding of how CircuitPython expects these things to work.

In the photo at the top of the page you can see my USB MIDI phone keypad hooked up to my MT-32Pi.

Find it on GitHub here.

Closing Thoughts

USB MIDI is relatively straight forward in CircuitPython, but I do find the way it links to GPIO cumbersome.  At some point I’ll create a version of the code that can be used with either CircuitPython or MicroPython and I’m keeping on eye out for USB MIDI support in MicroPython too.

Having a USB version of the phone is very convenient though as it now just needs a single lead to the device it is controlling, for both power and data.  No other connections are required.

Next up will be to do something with the phone’s handset.  I’m still thinking about how best to use it, but some kind of positional interface to a synthesizer is my current thinking.

Of course, it would also be possible from here to turn the keypad into an additional numerical keypad for a PC – all the main ingredients are here, but it would be sending USB HID keycodes rather than MIDI.  But I like it as a music controller.

Kevin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s