MIDI Controlled Solenoids with Arduino and Ableton Live - Part 3

Thumbnail image of Jason Bauer
Jason Bauer
November 28, 2019 (Last Updated: ) | Reading Time: 4 minutes

This is the 3rd and final part in a 3 part series about how to control solenoids using Ableton Live and an Arduino. In case you missed them, the first 2 parts are here:

If you've been following along then at this point in time you should have your solenoids, transistors, and Arduino all ready to go.

In this article we cover the Ableton Live part of making your solenoids move. If you don't use Ableton Live for your DAW you can still learn about this final step and then translate it to how your DAW works.

MIDI Data Out of Ableton

The goal here is to get MIDI data out of Ableton and into your Arduino.

You can see that the MIDI data generated in Ableton Live flows into the USB port of an Arduino, where it is used to control solenoids.
You can see that the MIDI data generated in Ableton Live flows into the USB port of an Arduino, where it is used to control solenoids.

To get started the Arduino needs to be setup as a MIDI output device.

Ableton Live MIDI Output Devices

After running the software in the previous article, your Arduino will show up as an available MIDI output device in Ableton live. Just be sure to let your Arduino drivers detect and install.

Pick an available MIDI slot and assign your Arduino in the output column. Also, be sure to enable On under the Track column.

You need to select your Arduino under output as well as enable it under track.
You need to select your Arduino under output as well as enable it under track.

If there are no Arduino devices listed in Ableton MIDI preferences then exit and restart Ableton Live. Also, make sure that you have ran the source code from the previous article at least once.

Add Your Arduino as a MIDI External Device

This step is technically not necessary as you can select the Arduino for output using other methods directly on the track. However, this makes adding MIDI effects before your Arduino much more straightforward.

On the track that you want to generate MIDI events add the MIDI instrument called External Instrument.

The External Instrument device makes it easy to route MIDI track data to an Arduino.
The External Instrument device makes it easy to route MIDI track data to an Arduino.

In the screenshot above we've also added a Fix 127 MIDI device. This makes the velocity of all MIDI events a full 127, which is the max MIDI velocity. This is not necessary with the source code we've provided, but it's a cool MIDI effect to know about for future projects.

You can leave the MIDI channel to 1 on the External Instrument device since our code responds to MIDI events on all channels.

Arm Your Track and Play Some Notes

At this point in time you should be able to arm your track and see MIDI notes heading down to your Arduino when you play them.

You can enable the keyboard as a MIDI device and send MIDI data to your Arduino using your computer keyboard. The home row (ASDF) generates note data and the Z and X keys shift the current octave up or down.

Press Z to shift the octave down and then start pressing A to generate a C note. Try pressing Z a few more times until a low C is generated. If everything is set up right then your output transistor attached to pin 0 should blink and your kick solenoid should move.

Once you've gotten this to happen then you have full control over your Arduino and solenoids from Ableton. It's time to write some music.

Warp A Track and Write Some Drums

Once you have Ableton controlling your Arduino you are ready to bring in an MP3 or WAV file and write a drum track for it.

When you bring the MP3 file in Ableton will warp it to your current time signature as best as it can. Warping aligns the MP3 file with the beat of your track which allows you to add drums on the beat of the imported track.

Now all you need is a MIDI track to match the song. Here's the MIDI drum data that we used in our demo video:

And once again here's the video from the start of the series that shows what you can do with this setup.

The MIDI drum part only has 6 instruments corresponding to the 6 solenoids. If you don't have 6 solenoids, then use Ableton to merge some of them together. For instance, you can merge 39 (C#) and 49 (D#) if you only have 5 solenoids.

Common Problems

The most common problem when using an Arduino as a MIDI device in Ableton is when you reprogram the Arduino device Ableton can sometimes lose track of it. Usually when this happens it is still in the MIDI preferences dialog but it is in red, indicating that Ableton thinks something else has exclusive access to it.

The only solution here is to exit and restart Ableton. Sometimes a full reboot of your computer is required.

Other MIDI Projects

That wraps up our 3 part series on controlling solenoids from Ableton Live using an Arduino. Do you want to see any other MIDI projects on this site? If so, then let us know in the comments.

Comments

avatar

oscar - 2020-02-07 00:14:28

reply

Hi, your project is fantastic! Great, congratulations! I followed all your instructions and I did my own project, but I have a little problem when send Midi data from Ableton. It work, but when the BPM is high (120, 140 and more fast), the solenoid can't play all notes (skip some of them). Maybe is because note-on and note-off are so close? DO you have any idea? Is possible to fix it? Thank you again!

avatar

Jason Bauer - 2020-03-14 22:33:42

Make sure that you do not have any serial port logging happening. The serial.print functions will block and prevent everything else from happening. Turn that off and there should be no real limit to the speed of notes you can send.

avatar

Oscar - 2020-02-09 17:16:11

reply

Solved!

avatar

Matthew Lee - 2020-08-21 01:04:54

reply

First off amazing project, thank you so much for sharing this--have ordered parts and am very excited to try the build.

As far as future/other MIDI projects I'd be curious to see you adapt this project to receive MIDI input from a MIDI cable or even MIDI DIN so that your Solenoids could be mapped using a hardware sequencer rather than a laptop.

Thanks again for sharing your hard work!

avatar

Jason Bauer - 2020-09-01 20:39:30

Receiving MIDI in from a standard MIDI cable is pretty straightforward and plenty of people on the net have it documented.

What is difficult is receiving MIDI from a USB midi device, like a keyboard. You need to run in USB host mode to do this. There are some chips and dev boards that help, but it's not as simple as it seems.

avatar

Deividas - 2021-03-18 09:16:36

reply

Hello, Jason!

Would it be possible to contact you in private? E.X e-mail or so?

I am graduating in master degree in one month and I am making a sequencer driven steel drum machine. I am trying to follow your tutorial but i've encountered some questions that I would like to discuss with you, mostly powering the whole setup issues.

I could re-pay you for your time ofc.!

Please e-mail me: [email protected] Or just drop your e-mail here if possible.

Many thanks! Deividas Lithuania

avatar

Jason Bauer - 2021-03-19 17:08:51

I sent you an email.

avatar

Jan De Moor - 2023-07-16 01:21:42

reply

Hi Jason

I got the project all up and running. Glad with that. Very good instructions here.

Next challenge for me is to connect the arduino with a modular synth module: (Westlicht Performer). It has USB midi out, but also traditional midi out. From what I read in your comments, the easiest way is probably to have a jack to DIN (midi cable) out of the module and to connect it with the arduino via a midi connector connected to the arduino like this? https://docs.arduino.cc/static/14b84d01c8d76de21b9d9764319dd2b8/29114/circuit.png

Will it be plug and play? Or will I have to adjust the arduino sketch?

Thank you so much for your help!

avatar

Jason Bauer - 2023-07-16 09:05:12

From a software perspective, I think it will just work as is. The sketch sends out standard MIDI data that should be parsable by any MIDI instrument.

The only thing that might be a gotcha is the voltage output. If your Arduino has 5 volt output on the pins, then I think you'll have no problems. However, if your Arduino is outputting 3.3 volts, it might be too low for some MIDI inputs to recognize. There are many ways to convert 3.3 volt output to 5 volts, so this will not be a limitation.

My suggestion is to try it, and if it either doesn't work, or you get strange results, consider a 3.3 volt to 5 volt level translation.

Leave a reply

Thank you! Your comment has been successfully submitted. It will be approved as soon as possible.

More from Efundies