Introduction: Open MIDI Sax: Build Your Own MIDI Wind Controller for Less Than 10€

About: Another Arduino freak :-)

Do you want to learn how to play a particular wind instrument but can't afford one? Do you want to practice playing your favorite wind instrument with your headphones without disturbing your family or neighbors? Are you a music composer that never got used to MIDI keyboards and can't afford a commercial MIDI wind electronic instrument? Do you want to try different keys/transposing configuration before trying them in a real instrument? Or are you just an electronics freak and want to make something cool? If you answered "yes" to any of the previous questions, maybe this project is for you.

As there are many kinds of wind instruments, for simplicity I will consider we want to build a saxophone-like MIDI controller, so we don't get confused with specific terms. For example, I will consider we will have keys to press, not holes to cover like in a flute. And I will consider we will have a mouth piece through we will have to blow, and not a set of bellows like the ones used in uilleann pipes. Of course, you can adapt the code, sensors and the physical build I suggest here to fit your needs.

The keys operation is based on the frets and strings operation of my previous project, the Open MIDI guitar. The mouth piece and the general cardboard shape of the saxophone are based on the MIDI wind controllers explained in https://www.kontinuumlab.com/. In particular, I recommend this video, that explains how to build the mouth sensor I use in this project.

Disclaimer: I have focused this project on circuit design and microcontroller code, keeping it as cheap as possible. As you can see in the photos and videos, I'm not a saxophone maker nor a musician. The prototype I made is perfectly functional, but it lacks of ergonomy, and it could be uncomfortable and difficult to play for real saxophonists. Be careful about carpal tunnel syndrome, or other injuries.

Features:

  • Saxophone MIDI controller with 14 keys. It can be adapted to any kind of wind instrument.
  • Connected through USB to your computer. You will need a serial to MIDI converter software (ttymidi and Hairless MIDI worked fine).
  • Can be used with any synthesizer or DAW.
  • Supports octave change key, like a real saxophone.
  • Mouth sensor supports variable note volume.
  • Configurable options via WIFI:
  • Changing initial note of the controller (allowing transposing, for example).
  • Mouth sensor calibration.
  • Default MIDI note velocity.
  • Volume changing configuration during a note playing.


Supplies

This is what I used to build my prototype. Have a look at the "Modifications/upgrades" step for other ideas that require different materials you could already have:

  • 1x ESP8266 board (D1 mini)
  • 2x MPR121 modules
  • 1x 220ohm resistor
  • 1x 47Kohm resistor
  • 1x CNY70 reflective optical sensor
  • 2x Perfboards
  • Header pins
  • Cables
  • M3 size screws, bolts and gaskets.
  • Cardboard
  • Plastic water bottle
  • Rubber hose
  • Elastic hair bands
  • Insulated tape

Tools used:

  • Pliers, scissors, soldering iron, glue gun, screwdrivers, multimeter.

Step 1: How the Open MIDI Sax Works

This prototype has two modes of operations: sax mode and configuration mode. We can switch from one mode to the other by touching the corresponding capacitive sensor in the lower part of the device. If the built-in led on on the microcontroller board is lit, that means we are in configuration mode.

  • Sax mode:

In this mode of operation (the default one), the device tries to work like a real saxophone. We simulate the keys of a sax with capacitive sensors. The mouth piece is built with an optical proximity sensor and a balloon. When we blow on the mouth piece having a particular combination of keys touched, the MIDI sax will send the appropriate MIDI message through the serial port, starting the corresponding note. This note will sound until we change keys, or stop blowing, and the MIDI sax will send the corresponding MIDI message.

The serial data is converted to MIDI data by ttymidi or Hairless MIDI, and this MIDI data is sent to your specific DAW/synthesizer software. If we change the strength of the blow, the MIDI sax will send the corresponding MIDI note volume changes. You can configure which particular MIDI messages are sent for this behavior in configuration mode.

  • Configuration mode:

In this mode of operation, the sax stops sending MIDI messages, activates the ESP8266 WIFI as an access point, and starts an HTTP server. We can now connect to the sax through our pc, laptop or smartphone, like if we were connecting to our home WIFI router. By default, the SSID of the MIDI sax is "OMS", the WIFI password is "kkkkkkkk" and its IP is 192.168.4.1. Once connected, we can access the HTTP server through a browser at "http://192.168.4.1/". If you are going to build your own MIDI controller, I suggest changing the default values accordingly in the code, so you don't have to enter configuration mode each time you are going to use it.

Using the web interface, you can change the following options:

  • Initial MIDI note: wich note sounds when you play the A# note.

According to wikipedia, saxophones "are almost always treated as transposing instruments". By default, the Open MIDI Sax will work like an Alto Saxophone. That means that if we want to get the real sound produced by an Alto Sax, we have to play the MIDI note three semitones higher.

  • Mouth sensor calibration:

The configuration web page shows the minimal and maximal mouth sensor values received in configuration mode. We should set the min and max accordingly, to adjust the sensitivity of the sensor and to avoid false notes. If we blow and refresh the webpage, the values between brackets should update. The value we introduce in "Mouth sensor min" textbox should be higher than the lowest sensor data read; and the value we introduce in "Mouth sensor max" textbox should be lower than the higher sensor data read.

  • Default velocity:

With this option we change what MIDI protocol calls "velocity". It usually refers to the note volume, but you should keep in mind that, depending on your software, it could change another parameter.

  • MIDI control change:

According to MIDI specification, once a note is playing we can't change its velocity. With this option, we change the way the MIDI sax mouth sensor works when we change the strenght of the blow while a note is playing. Depending on your particular software, one particular option could be more useful than others. We can choose between the following four options:

  • Breath messages: we send control messages for changing breath parameter.
  • Channel volume messages: we send control messages for changing channel volume.
  • Aftertouch messages: we send polyphonic key pressure messages. This option is experimental, as I wasn't able to see it working, maybe because I didn't use the right software, or simply because I did something wrong. If you have any suggestion about this, let me know.
  • No volume changing: we don't allow volume changing while a note is playing.

Step 2: An Overview of the Building Process

In the images you can see some diagrams of the Open MIDI Sax and a photo of my initial prototype. I have used an ESP8266 module, two MPR121 capacitive sensors modules, and a hand made breath sensor module based on a CNY70 proximity sensor, as explained here. The MPR121 modules are controlled through I2C, and each one provides twelve capacitive sensors. For this prototype, I needed fourteen keys, and other two for controlling the octave change and switching modes, so two MPR121 modules were enough.

Physically, we can divide the design into three parts:

  • Microcontroller and capacitive sensors
  • Mouth piece
  • Main body

Step 3: Microcontroller and Capacitive Sensors

I have used a small D1 Mini ESP8266 module. That allowed me to connect the two MPR121 capacitive sensors modules and the microcontroller to the same small 7x5cm perfboard through female pin headers. I placed this perfboard in the lower part of the MIDI controller, and soldered the cables needed for the capacitive sensors, and the ones connecting the other module, the breath sensor.

A MPR121 module can have one of these I2C addresses: 0X5A, 0X5B, 0X5C or 0x5D. Its address will depend on what you connect to the ADD pin. By default, GND is connected to this pin, so if you want to use another address different from 0X5A you will have to break the connection in between the two pads on the back side of the module, as explained here. I used a small precision screwdriver, a cutter could be used too. A multimeter is very useful here, to ensure you have broken the contact.

I draw two possible diagrams in Fritzing to guide myself in the soldering process. I recommend a glue gun to fix the pin headers to the perfboard before soldering them. Once the pin headers were soldered, I soldered the sixteen cables that were connected to the sax keys, and the octave and mode switches. Once again, a multimeter is useful here to test the sensors endpoints.

Step 4: Mouth Piece

As I've said before, watch this to see how to build the breath sensor I've built for this project. I've found some other solutions, based on microphone sensors or pressure sensors, but I think this is the easiest and more elegant solution for this task.

When you build this sensor, remember to get the balloon membrane close enough to the CNY70 module. For testing purposes, I suggest using the the analog read example, available in your Arduino IDE, together with the serial monitor and serial plotter.

I had to use quite long cables for this sensor, as I had to solder it to the microcontroller perfboard, and I placed this one on the other side of the MIDI controller. You need to connect it to the GND, VCC and A0 pins in the ESP8266.

Step 5: Main Body

For the main body I've used cardboard, and I kept it fixed with some elastic hair bands. The capacitive sensors endpoints I chose were some screws, with nuts and gaskets on the back side. The distribution of these endpoints is based on real saxophones and other electronic wind instruments. I've placed the mode switch sensor in the lower part of the MIDI controller, far enough so that it's not touched accidentally while touching the rest of the sensors.

Step 6: Code

The code is available here, and it's licensed under GPL v.3. Although updated, I still recommend Sloeber IDE over Arduino IDE. It's based on Eclipse, and it allows even navigating through the Arduino built-in functions declarations and definitions, so you can learn a lot about the Arduino API framework using Sloeber.

The code is full of comments, so you can follow its behavior if interested. Basically, in each loop:

  • I read the mouth sensor.
  • I read the config mode switch, and change controller mode if change is detected.
  • If we are in sax mode:
  • I control volume changes.
  • I control octave change.
  • I control keys touched.
  • If a valid combination of keys is pressed, and I'm blowing into the mouth piece, the controller starts a new note, stopping the previous one if it was still playing.
  •    If we are in config mode:
  • I update mouth sensor calibration information.
  • I handle the HTTP server requests, modifying options accordingly.

Please, keep in mind that, for simplicity, I don't manage errors in the web interface.

Step 7: Modifications and Upgrades

These are possible modifications/upgrades to my prototype, keeping in mind my main objective: high functionality at a low cost. If you have other suggestions, let me know:

  • Using the actually unused eight capacitive sensors for other options: better octave up/down keys, buttons for a small OLED screen,...
  • Using ESP32 or ESP32 S2 Mini module. The first one has ten built in touch sensors, and the S2 has fourteen, so if we don't need many keys, we could use these sensors instead of the MPR121 modules. This would allow us to build a really small and cheap prototype.
  • Building a more ergonomic controller. Using PVC tubes instead of cardboard could be a good option.
  • Using a better mouth piece, based in a spare one from an old instrument or a 3D printed one.

Step 8: Troubleshooting

I had two curious problems during the building of my prototype:

  • Most of the times, enabling and disabling WIFI made the connection to the board impossible. The access point appeared, but connection failed after writing password everytime. This was solved adding a delay in the code, but I still don't know if it was caused by the board, any defective soldering on the perfboard, or a particular problem of this particular microcontroller, or in the Arduino framework for it.
  • Each time I uploaded the code to the microcontroller, the MPR121 modules were not detected anymore. This happened too each time I pressed the reset button on the ESP8266 board. This problem was the reason why there are two diagrams in Fritzing for the same design, as I initially thought it was due to a poor welding in my initial board and I made another one. The problem still persists, but it's solved disconnecting the usb cable from the computer, and connecting it again. Maybe this problem is related to this.

Step 9: Final Thoughts, References and Links

As you can see in my Open MIDI guitar project here, a set of MPR121 modules is a very good option for projects with a lot of inputs. In this case, the number of capacitive sensors is significantly lower than in the guitar project, but we added some complexity with the mouth piece and the web interface through WIFI.

I hope you liked this project, making it was really funny, and I've learned new things about MIDI protocol, sensors, and WIFI use on ESP microcontrollers. Feel free to ask/suggest anything about it (materials, code, mistakes, recommended links, etc.), and let me know if you make your own MIDI wind controller.

Regarding software used, I recommend the following for Linux (I only know the basics of some of them):

  • aconnectgui, Jack (QjackCtl), Carla: for interconnections.
  • LMMS, ZynAddSubFX, Yoshimi (ZynAddSubFX fork), Fluidsynth (Qsynth), Rosegarden, Hydrogen: for composing and synthesizing.
  • qmidiroute: I discovered this software while preparing the videos for this project, and it seems excelent for debugging.

Finally, some interesting links: