LEGO MINDSTORMS MIDI trumpet

A LEGO magician automaton that can make objects appear and disappear. Support on LEGO IDEAS
LEGO Magician Automaton
March 16, 2019
A LEGOWeDo 2.0 floating spaceship model based on tensegrity
Tensegrity with LEGO: Floating Spaceship
April 27, 2020
Show all

LEGO MINDSTORMS MIDI trumpet

LEGO MINDSTORMS Trumpet that can control a MIDI synthesizer via a Bluetooth Arduino interface
LEGO MINDSTORMS Trumpet that can control a MIDI synthesizer via a Bluetooth Arduino interface

The call

In December 2018 I received the call from a Michele Scuffiotti, a guy I have known since the time I played the piano with my youth orchestra (it was 2001, and this means that I am old). He called to invite me as a guest to a television show for the local TV (TV9, Grosseto, Toscana).
Edicolacustica Circus (barely translated as Acoustic News Stand) is a musical talk show invented by Michele Scuffiotti himself and Alberto Guazzi that traces the history of the 20th century using music as a common thread. The show is enriched by a live rock band. But I was invited as a LEGO designer, not as an (ex) musician! And then? I was about to reply that my LEGO robots had nothing to do with live music, but then I had an epiphany.

What if I play with an instrument made with LEGO together with the band?

When ideas are truly powerful, you can feel a shiver of pleasure down your spine. Cool! The proposal immediately gathered the enthusiasm of the authors of the program. The huge problem was the close deadline. The live show would have been recorded in January 2019, so there was only one month to invent a LEGO musical instrument from scratch and learn to play it decently.

I wish to thank Alberto Guazzi, Michele Scuffiotti, Associazione Culturale Stop & Dintorni, to let me incorporate the original video of the show.

Brainstorming

Danny playing piano with Alessandro, Flavio, Giovanni and Matteo

I haven’t touched the keyboard (of a piano) for 10 years. My musical background is classical, and I have never learned to improvise. (If you want to know my frank opinion on Jazz, contact me and I’ll disclose it in private.) My new LEGO musical instrument was supposed to be easy to play, while allowing me to make a decent performance.
I was in trouble, because I lacked some modern music theory. So I got help from my friend Flavio Timpanaro, bassist of the band, with whom I had already played (the keyboard) in the past.

Simple: let’s do a jam session on a Blues riff. You will improvise using the notes of the Blues scale. Whatever you play, on the Blues riff it will be fine!

That was really comforting. So even a non-Jazzist like me could do it. When we met to do some brainstorming and reharsing on a real piano, Flavio was very amused by my surprise in discovering that whatever phrase I played on the Blues riff chords using notes belonging to the Blues scale, there was no way to do it wrong. It just played good to the hear.

Danny borrows his hair to Flavio
That's the way to brainstorm with someone?
My LEGO MINDSTORMS NXT trumpet features a golden NXT brick

Which LEGO musical instrument to make?

I wanted to avoid showing an instrument that was already present on stage in its real version. So my dear old EV3 EL3CTRIC GUITAR could not work.
For those who do not know it, that LEGO MINDSTORMS EV3 guitar is one of the 12 official bonus models released for the LEGO MINDSTORMS EV3 retail set 31313. With Flavio we explored the possibility of making a sort of laser harp using ultrasonic distance sensors, but it was not practical to play. So a theremin? Difficult to play and unpleasant sound if made with digital devices.

Thinking of music history, Jazz Big Bands were full of brass instruments. I could pick a small portable one. A trumpet? Why not?
Jetro de Château already made a NXT trumpet in 2010, using a 3rd party pressure sensor, and an old LEGO pneumatic pump. From its realistic working, I can guess that Jetro has some experience with real brass instruments, which I don’t have.
And there it was. We picked the trumpet as the instrument to reproduce with LEGO parts, keeping in mind that it had to be super easy to master in no time.

Which LEGO programmable brick to use?

I set my self some specifications for the LEGO musical instrument to be made:

  1. I wanted to play a pure LEGO instrument.
  2. I wanted to be able to play without getting in the way of cables connected to the mixer.
  3. My LEGO musical instrument had to sound like a real one.

A square wave buzz boop beep from a tiny speaker would not have been enough. LEGO programmable bricks can only generate square wave tones, unpleasant and weak. They cannot compete with the volume of a live rock band. Applying a microphone to the speaker of the programmable brick, or hacking it to expose the audio wires could have been possible solutions, but the sound would have remained artificial and unpleasant.

So what to choose? EV3 or NXT? Unfortunately, the EV3 has a complicated Bluetooth protocol and there was no quick and easy way to program it to send low-level Bluetooth messages (remember the very short deadline). So, also driven by nostalgia, I opted for the good old inimitable LEGO MINDSTORMS NXT! Using the text programming language NXC developed by John Hansen I could send Bluetooth messages to an Arduino board, which I would use as an interface between NXT and a MIDI synthesizer, to generate a realistic trumpet voice. Most importantly, it was the right opportunity to show off my golden NXT, a lovely gift I got from The LEGO Group back in 2010. The golden chrome plating is ideal for my LEGO trumpet!

How does it work?

The actual Arduino interface that lets the LEGO trumpet communicate via Bluetooth to a MIDI synthesizer

I soldered a custom shield for the Arduino microcontroller, to attach a HC-05 Bluetooth board and a MIDI female port to it. Arduino receives messages from the NXT via Bluetooth and forwards them to the synthesizer via the MIDI port, which is nothing more than a very slow serial port.

On the trumpet there’s a sensor positioned in place of the mouthpiece that I activate by pressing it with my lips, as if I were actually blowing into the instrument. Initially I was tickled by the idea of being able to play giving more expression to the notes using a force sensor  instead of a simple contact sensor. This input could be used to send MIDI expression messages or to play notes with variable attack (velocity). Unfortunately, this sophistication was not appreciable during the performance. For the sake of robustness and simplicity, the force sensor idea was discarded, and a bare LEGO contact sensor was used.

My LEGO MINDSTORMS trumpet sends data to the MIDI synthesizer thanks to an Arduino board connected via Bluetooth

How to become a master LEGO Blues man

The trumpet has one touch sensor that acts as the mouthpiece (see above) and three touch sensors as pistons. In order to master the Blues scale in no time, I made sure that the trumpet had a very effective – yet unrealistic – fingering. Between two notes that are one degree apart (second interval) there is only one key of difference. In other words, to play a note which is close to the one I am playing, I either release one key or press another, but I will not change the state of two keys at the same time (by releasing one and pressing another). The latter happens only around the octave jump, which is activated by using the NXT Enter button, to expand the instrument range.

This diagram shows the mapping of the Blues scale on my LEGO trumpet keys

Having 3 keys to modulate the tone, in addition to the Enter button used for the octave jump, the possible combinations would be 2 ^ 4 = 16 notes.
In reality there are 14 notes, due to a redundancy of the notes at the octave jump. It’s a small price to pay, to have a very comfortable fingering. The arrow keys of the NXT allow me to change the tonality of the scale: it takes one click to configure the trumpet to play on a riff in D minor or in E minor.
From the point of view of the performer (especially for a wimp like me), the change of tonality is transparent, and the transposed scale can be performed with the exact same fingering.

Murphy’s Law Corollary: The Manager Test

As I said above, the Edicolacustica show was recorded, but live. In other words, if you make a mistake, you’re done, as there was no time for multiple takes, or subsequent editing to the recording. And in fact, you can spot that some technical problems have plagued the ending of my performance.
At home and during reharsals, everything worked. Then, when recording the show, the bugs appeared. This is called “manager test”, “Murphy’s law” or simply bad luck. Let’s explain what the problem was.

In the video you can hear a note that remains pressed, as if it was stuck. The cause lies in the fact that some MIDI messages are not received by the synthesizer. Every time I press a key the NXT sends a MIDI Note ON message to Arduino, which forwards it to the MIDI synthesizer. When I change the note being played, a MIDI Note OFF message is generated to turn off the previously playing note, and then another MIDI Note ON message is sent to play the new one. If the Note OFF message is lost in ether, you get the stuck note problem.
It’s a fixable bug for sure, with some extra time available. But with just a month of development using my spare time, I’m happy with the result.

If any music band wants to hire my LEGO trumpet (with me attached to it, of course) to record a song or a video, I promise that I will solve all the bugs to make the performance very robust!

CLOSE
CLOSE