Skip to content

emshotton/thumble

 
 

Repository files navigation

Thumble

A MIDI controller in the shape of a video game controller (e.g. xbox), but using mechanical-keyboard buttons.

How it's designed musically; how to play it

Hold it like an Xbox controller. Play it like a kalimba, with your thumbs.

The diagonal keys are notes; the 3 keys in the middle are extra function keys. The joystick is for pitch bends.

Musical notes

Unlike a kalimba, the notes are arranged piano style. There's one octave starting at B on the left and ascending to Bb on the right. Like a piano, white keys are on the bottom row and black keys are on the top row (except for B).

Because we use Shepard Tones (more below), you can play a melody so that it wraps off one side of the keyboard and back onto the other side, without noticing a jump in octaves.

Special keys

The middle keys S, T, and U are for special purposes. Currently:

  • S is volume down (like a multimedia keyboard -- controlling the computer volume)
  • T is volume up
  • U is a SHIFT key
    • SHIFT - B toggles between MIDI channel 0 and 1
    • SHIFT + a white key tranposes the keyboard to different octaves. F gets you the default octave.

...but check the source code for the latest changes to the special keys.

The middle keys could possibly do other things like:

  • play specific MIDI pitches where drum sounds can be set up, that would ignore the transpose settings and pitch bends.

Joystick

The joystick is not programmed yet (TODO), but it will do pitch bends. Left/right will bend by a half step, and up/down will bend by a whole step.

It could also act as a mod wheel on one axis and a pitch bend on the other axis.

Shepard Tones

There's only room for 12 notes, but wouldn't it be nice if you could wrap around the edge when playing a melody without jumping an octave?

We use an auditory illusion called Shepard Tones to make this possible. Each key actually plays several octaves of that note at the same time, but with louder notes in the middle octaves, to maintain the loudest note in the same octave despite the illusion of constantly ascending tones.

As you go up, the higher octaves fade away and the lower octaves fade in to take their place, until you wrap around seamlessly.

For example:

  • C plays C1 at 50% and C2 at 50% volume.
  • D plays D1 at 58% and D2 at 42%.
  • ...etc, with the upper octave fading away until we get to the middle of the scale and the upper octave is gone. Then we start bringing in the octave below...
  • F plays F1 at 92% and F2 at 8%.
  • F# plays F#1 at 100%
  • G plays G0 at 8% and G1 at 92%
  • and eventually we end up back where we started:
  • B plays B0 at 42% and B1 at 58%

Hardware

  1. Arduino / microcontroller: Feather 32u4 basic proto, from Adafruit. If these are out of stock, look for the exact same thing on Amazon (sold by Adafruit).
  2. Cherry MX compatible keyswitches (x 15)
  3. Keycaps (x 15)
    • I used these XDA profile keycaps because they're pretty flat on top so it's easy to slide your thumbs around
  4. This joystick from Adafruit
  5. Some wires
  6. Soldering equipment

Alternative hardware

The Elite-C uses the same chip as the Feather, but the physical hardware is better. It's smaller, and it has a strong USB-C port, while the Feather's USB-Micro port tends to rip off if the cord is pulled.

However the Elite-C can't be flashed from the Arduino IDE (because it uses the DFU bootloader instead of the Caterina bootloader that's normal for Arduino boards.) You have to use the command line to flash it, and I'm not sure how to compile the code for it or make sure it supports MIDI-over-USB.

If you know how to solve that problem, you can use the Elite-C instead. Note though that the case is designed for the Feather, which is larger.

Case

The case is laser cut from 7 layers of 1/8 inch material (3mm). I used plywood and glued the layers, or you could use acrylic and figure out some screw holes. The SVG files are in the case folder.

3mm plywood is too thick for the keyswitches to grab onto with their little latches. You'll have to glue them into place (TODO: with what glue?).

The joystick and microcontroller are also a bit loose in the case; you'll have to improvise a way to keep them stable. Maybe a spare piece of wood to pack the space below them.

The top layer SVG is flipped so that the laser smoke marks end up inside the case instead of outside. Case level 4 is hollow, make three of those to stack up enough interior space for wiring.

Assembly sequence

  1. Software setup:
    1. Install the Arduino IDE and set it up as described below.
    2. Flash software to the microcontroller before you do anything else, just to make sure you can. You won't be able to test it though.
  2. Case:
    1. Laser-cut case layers from plywood.
    2. Align plywood layers, test-fitting keyswitches to ensure precise alignment. (The keyswitches will not clip in securely; we glue them in a later step.)
    3. Glue all plywood layers except the back panel.
    4. Sand and finish the plywood. Round off the edges of the handle to make it more comfortable to hold and to remove the burned part.
  3. Assembly:
    1. Glue in the keyswitches, being carful not to get glue on the metal contacts.
    2. Put in the joystick and microcontroller and affix them somehow.
    3. Soldering time.
  4. Testing:
    1. Test device functionality, press buttons, connect to MIDI software and see if it works. Try using a "midi spy" program like Midi Monitor to observe the MIDI events it's sending.
  5. Final packaging:
    1. Add more supports around the back of the joystick and microcontroller to hold them steady in their little caves when squeezed by the back panel. Maybe glue some scrap wood?
    2. Also add some scrap wood to hold the USB port tight when the back cover is on. The USB port tends to get ripped out when the cable is yanked. Some superglue might help here if you're careful.
    3. Put the back panel on with wood screws, or use M2.5 machine screws in the provided holes. You might need to open it again later.
    4. Put keycaps on the keyswitches.

Arduino setup

  1. Install the official Arduino IDE. The "hourly build" is free, the others cost money.
  2. In the Arduino IDE, install the Adafruit board profiles using instructions from Adafruit. Specifically, the Adafruit board manager URL to add is https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
  3. Set board: Adafruit Feather 32u4 basic proto
  4. Add libraries: MIDIUSB

Open the arduino code in thumble_001_arduino. Hit the checkmark button to see if it compiles with no problems.

To send the code to the board, press the button with the right arrow. You do not need to press the reset button on the board when flashing it.

The firmware code

This code will turn the microcontroller into a USB MIDI input device, like a piano keyboard, that can be used with any other hardware (ipad, laptop, etc).

This is not based on any existing mechanical keyboard firmware because it's fairly simple.

Soldering

We can wire each key directly between GND and an input pin, since we don't have many keys. (Otherwise in a bigger keyboard we'd build a key matrix using diodes.)

For simplicity, a few GND wires can run along tracks in the case and connect to every key. Then attach a signal wire from each key to a unique pin on the microcontroller.

We use 15 digital input pins for keys.

The joystick uses up two analog inputs and needs a ground and 3v wire too.

Wiring diagram (click to enlarge):

You can adjust the key-to-pin assignments in the code if you soldered things a bit differently. Look for the #define KEY00_PIN lines around line 90.

About

hardware for a MIDI instrument

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%