North (formerly Thalmic Labs), the creator of the Myo armband, was acquired by Google in June 2020. Myo sales ended in October 2018 and Myo software, hardware and SDKs are no longer available or supported. Learn more.

#MyoCraft: Hand Made Music in Garageband

#MyoCraft: Hand Made Music in Garageband

Hey folks! We’re back with this week’s #MyoCraft. As a reminder, each week we’ll feature one script or application that does something neat. It might be just a toy that isn’t ready for the average user, or something with a more complicated setup process, or it may be a full, published script. If you’ve got something you want to share, send it my way on Twitter (@thalmicdev or at Today, we have a script to do MIDI input in Garageband with your Myo armband.

So without further adieu, here’s the script:


 scriptId = 'com.thalmic.schemes.garageband'  
    scriptTitle = "Garage Band"

    description = [[  
    * Open GarageBand (requires GarageBand 10).
    * If prompted to start a new project choose “Empty Project” then choose “Software Instrument”.
    * Select an instrument from the GarageBand Library (Synthesizers tend to sound best).
    * Spread your fingers to generate notes (the first note will take an extra second to start), and move your arm around to change the pitch.
    * To stop the music playing just select a new instrument (that’s the quickest way to kill the noise).

    My favourite GarageBand instruments to play with are “Juicy Pump Bass”, “Massive Saws”, and “Festival Lead”.  

    -- Range of pitch is pi (arm straight down to arm straight up).
    oldMin = 0;  
    oldMax = math.pi;  
    oldRange = oldMax - oldMin;

    -- Range is from C3 to C5.
    newMin = 48; --c3  
    newMax = 72; --c5  
    newRange = newMax - newMin;

    -- Initially the status is inactive.
    active = false

    function onPoseEdge(pose, edge)  
        if pose == "fingersSpread" then
            active = (edge == "on")
        elseif (pose == "doubleTap") then

    -- onPeriodic runs every ~10ms. If fingers are spread, send a note
    -- corresponding to the pitch of the wearer's arm.
    function onPeriodic()  
        -- Pitch range is from -pi/2 to pi/2, shift up by pi/2 to use absolute value.
        local value = myo.getPitch() + math.pi / 2;

        -- Convert pitch to corresponding note value.
        local pitch = (((value - oldMin) * newRange) / oldRange) + newMin;

        -- If fingers are spread, send a note.
        if active then
            myo.midi(1, "noteOn", pitch, 100)

    -- Only send notes while GarageBand is the active app.
    function onForegroundWindowChange(app, title)  
        return app == ""

    function onUnlock()  

Make sure you follow the instructions in the script comments!

Basically, what this does is let you control the pitch of a note with the pitch of your arm. It’s geared specifically towards Garage Band right now, but it could probably be used with any application that accepted MIDI input on OSX (currently, MIDI is only supported on Mac, not Windows).

You could easily imagine a few different ways to extend the script. Wave in/out to select different tracks for one. Roll or yaw to play with pitch bend or after touch. Perhaps confine the notes to a a certain scale. But this is just a quick hack, and we leave those efforts as an exercise to the reader.

Join us next week for another #MyoCraft! Don’t forget: If you have a cool script or application you want featured, let me know!

Otherwise, see you next Saturday!

You've successfully subscribed to The Lab!