How to connect your Mini.mu to PureData

I was very fortunate enough to be made one of the prototype versions of Helen Leigh Steers amazing Mini.mu gloves, it uses micro:bit to create a gestural controller and is aimed at getting younger people into the more fun/physical things that coding and tech can do. I’ve been pushing what this little, cheap product can do and have already had great success in connecting it up to physical instruments and puredata.

I struggled getting the micro:bits connecting via radio/serial and into puredata, I definitely couldn’t have managed it using the micro:bits blocks editor which is the easiest/user friendliest way to start coding. So, I found a work around which I thought would be useful for anyone else wanting to connect micro:bits to puredata.

This works with 2 micro:bits, communicating over radio, sending MIDI data into Puredata. This obviously limits you to the range of MIDI values, but is more than enough to get some really great results.

The first thing you need to do is install the MIDI extension for your Blocks Editor. Search for MIDI and you’ll get the option for either bluetooth-midi or midi. I used midi, feel free to explore the other option.

extensions

So next we load up our .hex files with the following codes for sending/receiving.

RecieveBlocks
This one receives the signals, and is on a micro:bit hooked into your USB port

 

SendBlocks
This one sends the values of the rotation of the micro:bit to the one plugged into your computer. This one will sit inside your glove.

One important thing to note, is that the “rollx” blocks have to be white, and not red variables. For some reason it just didn’t work if I tried to load a variable named rollx.

Now, before you open up puredata, you’ll need two more small programmes to make this work. All the documentation for the MIDI library is in here, and it mentions the need for a bridge between serial and our midi devices, so Hairless MIDI is the first thing you need. This converts incoming Serial data into MIDI packages. The second thing you’ll need is loopMIDI, which is a brilliant programme that acts as a virtual connection for MIDI devices. I use this one to make PureData and Reaper talk to each other too.

So, your two other programmes will look like this:

HairlessMIDI
Hairless MIDI
loopMIDI
loopMIDI

So, now you have all this set up, you can open up puredata, select loopMIDI as a MIDI input device and use [notein 1] as your method of recieving data.

This is the patch I used in the video above to simply turn the incoming stream into a sinewave.

PureData

Obviously, you can do whatever you want with the incoming data, and I’ll be posting a few more complex patches soon (once I’ve made them) showing the potential of mini.mu and puredata.

NOTE/UPDATE:

There may be some other issues with connecting things together if you’re on not Windows 10 or on Macs, but thanks to Neill Bogie, there may be work arounds:

Instructions for mac users (LoopMIDI is windows-only, so mac users must enable their IAC Driver):
https://gist.github.com/nbogie/309848134aede2e57ee80a4b752b0294#file-mini-mu-to-pd-on-mac-md

Windows versions prior to windows 10, users will first need to install the mbed windows serial port driver before Hairless MIDI Bridge will see the microbit as a COM port, following these instructions: https://os.mbed.com/docs/latest/tutorials/windows-serial-driver.html … (Making sure to have the microbit connected during install). Source: microbit support https://support.microbit.org/support/solutions/articles/19000022103-how-do-i-use-the-serial-port-with-a-micro-bit-on-windows

11 Comments Add yours

  1. Neill B says:

    Also, for windows versions prior to windows 10, users will first need to install the mbed windows serial port driver before Hairless MIDI Bridge will see the microbit as a COM port, following these instructions: https://os.mbed.com/docs/latest/tutorials/windows-serial-driver.html … (Making sure to have the microbit connected during install). Source: microbit support https://support.microbit.org/support/solutions/articles/19000022103-how-do-i-use-the-serial-port-with-a-micro-bit-on-windows

  2. Neill B says:

    Here are some alternative instructions for mac users (LoopMIDI is windows-only, so mac users must enable their IAC Driver):
    https://gist.github.com/nbogie/309848134aede2e57ee80a4b752b0294#file-mini-mu-to-pd-on-mac-md Feel free to integrate these into this tutorial however, if you want.

  3. Neill B says:

    Going further:

    Looking again at the makecode MIDI library docs, there’s a nice way to set up client and bridge so that you can just write MIDI code on the client (glove) microbit(s) and not have to keep changing the bridge when you want to add more aspects to the stream of data.

    I’ve broken it out into separate programs.

    This goes on your bridge microbit:
    https://makecode.microbit.org/_bVdR919toUD3

    and then use the following as a starting point for your glove microbit(s):
    https://makecode.microbit.org/_gpC7fsikRbEW

    … then you can simply call ANY of the MIDI functions from the glove microbit, and they’ll be forwarded directly to serial by the bridge microbit, with no further changes necessary to the bridge microbit!

    For the curious: the grayed out code in the start block is essential on the glove microbit. It says: hey midi library, whenever you get told to do midi stuff, I actually want you to send the message over radio! The reason it is grayed is that it’s (necessarily) written in a form of javascript that can’t currently be broken down into blocks. But it is still run by the microbit, so don’t delete it!

    Anyway, this should speed up prototyping a LOT!

  4. xoan xil says:

    Thanks for sharing. It is very helpful!

    Do you know if it is possible to send data from puredata to microbit in order to control a servo?

    1. That is an interesting question! I’m sure there is a way but I have not looked into it. What sort of project are you planning? There may be a simpler method already tried and tested.

  5. tom karches says:

    You commented about being limited to certain values with the radio. I’ve not seen this mentioned anywhere else. Could you elaborate?

    1. I couldn’t find a way to send more than one value per MIDI Channel. Strictly speaking MIDI was never designed for this kind of communication, so my way of connecting microbit to puredata is a bit hacked together!

      BUT, you can have multiple MIDI channels on one microbit sending different sensor data. So it is possible to have pitch and roll and buttons and all sorts being sent.

      1. tom karches says:

        Does this have to do with the size of the data packets?

      2. Nope. Not at all. MIDI is designed for simple musical communication so just isn’t designed to handle more than a few basic messages. Serial data would be way better to handle this but I didn’t have time to figure out the puredata side of that. OSC would probably work nicely too but again, i didn’t have time and it would involve more in depth coding.

  6. tom karches says:

    I’m thinking about ways to use this in an educational setting. I’ve just spent a few hours with the microbit so there is still more to discover. Having the control input split across multiple channels would probably work ok in Pure Data. though OSC would be simpler to process in PD.

    1. You can have multiple microbits sending info into one PD patch too. Which is useful for groups of people.

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