Glovepie Wiimote Wii To Midi - Controller For Ableton Live - Tutorial

Intro

With this simple tutorial guide you will be able to build your own midi controller out of Nintendo Wii remote and fully understand what are you doing and how it works.

Its simple combination of two gestures Wiimote's pitch and roll just to give rough idea how powerful and unique midi controller can be built out of that little thing.

And trust me it can be extended much much further then you can imagine at the moment.



Some Background

The Wii Remote aka wiimote is the hand held motion sense controller for the Nintendo Wii popular video game console released by Nintendo in 2006.

It has built-in accelerometers and infrared detection allowing users to interact with and manipulate objects in games on the screen via gesture recognition.It connects to the console via Bluetooth protocols. I'm not going to give here any in-depth specification details about it ,if you wont to find out more about it just google it or try wiki pages wiimote.

Mentioning about midi is pointless if you want to build your controller you already must have some knowledge about it.

That's pretty much all we need to know before we get started.



wiimote
wiimote

What You Will Need To Get Started .


1 Desktop PC / Laptop




2 Obviously Wii Remote (wiimote)


If you already have one skip this step if not Search for it on ebay or amazon and bay one.I wouldn't recommend to buy the cheapest ones , I bought one myself when i wanted to build my midi controller and found it very frustrated I've been experiencing connection problems, often disconnection without reason or even couldn't connect it at all to my pc.They are made from cheap components.Try to buy original controller for Nintendo Wii ,new or used its relay up to you or try to borrow one from your friends and get it tested before you will spend money.

3 Bluetooth USB Dongle

If you use Laptop perhaps its already built-in ,if you use desktop buy one and try to follow rule from step above remember cheap its not always good but you may have luck.



4 GlovePIE

GlovePIE stands for Glove Programmable Input Emulator.

Its some sort of scripting / programming language emulating Input of all sorts of game controllers like Joystick , Keyboard,Mouse etc. And It can also control MIDI or OSC output and that is the best part of it (for us music makers) its mean it can be used in music word to send out midi notes ,midi / osc control messages to your favourite music software (with full midi / osc support).For full list of compatible devises see creator page.


5 Virtual Midi Cable

Virtual midi cable / driver emulate midi cables in virtual world .You can use it to connect various applications and send and receive midi data from each others.

google (virtual midi cable) for mote information.

MIDI Yoke -they are others out there but I recommend this one due to low latency .


6 A Little Bit Of Common Sense And Patient


7 Ableton Live or any music software supporting Midi

All examples of use in this tutorial are made with Ableton live

Connecting wiimote to PC / Laptop


Install your bluetooth dongle drivers and provided software.

Go to -> My Bluetooth Places -> Add a Bluetooth Device -> Search for devices

At the same time press down the 1 and 2 buttons on your Wiimote and wait until recognised by your Bluetooth dongle.Once the wiimote has been found(Bluetooth Hid Device), connect to it and make sure you dont use a passkey.

If you have done everything as instructed above your wiimote should be connected.





GlovePIE and wiimote

Let me explain some basic key words / functions we going to use with our simple GlovePie script later on.

If you have some experience with programming just skip this paragraph and don't waste your time.

var = variable

Example

var.foo = 1

Functions


Debug - It will display any message or variable in the debug box

Example

Debug = "hello"

Debug = var.foo

If you want to mix test with variable use follow syntax

Debug = "hello"+var.foo

Pressed(x) - emulate key press where x is key (letter or any sign on keyboard)

Example Pressed(One)

Round(x) - Rounds x towards nearest integer

Smooth(x) - Smooths out the value of x by averaging with the previous

EnsureMapRange(x, a, b, c, d) - Returns value x converted from the range [a, b] to the range [c, d] and values outside the range are mapped to the closest values inside the range


IF statements


If statements can have one of the following syntaxes:

if condition then statement [ ; ]

if ( condition ) [then] statement [ ; ]

if condition [then] [begin] [ { ]

statement [ ; ]

statement [ ; ]

...

[ } ] [end [if]] [ ; ]

if condition [then] [begin] [ { ]

statement [ ; ]

statement [ ; ]

...

[ } ] [end] else [begin] [ { ]

statement [ ; ]

statement [ ; ]

...

[ } ] [end [if]] [ ; ]


Example


if pressed(one) then midi.Control2 = 1

if key one (1) pressed value of midi control no 2 is set to 1


Glovepie MIDI


Setting Up Midi Ports


Go To GlovePie -> CP-Settings

Select Midi From drop down menu.Click on audio tab and set Out to : Midi Yoke :1 in midi section on the bottom of the tab.

You can set other MIDI output port you want GlovePIE to use, like this:

midi.DeviceOut = 2

or just use

midi. if you want to use default midi device selected via CP-Settings menu.

midi.Control2 = 1

midi.control2 - use controller no 2 on default midi out device and set value to 1

Midi Map Range is 1 - 127


Wimote's Pitch And Roll

Pitch is the vertical angle. It is 90 degree when the controller is pointing at the ceiling, -90 degree when it is pointing at the ground, 0 degree when it is flat, and a value in between for angles in between. Pitch never goes past 90 degree.

Example

to get values of wimotes' Pitch use

Wiimote.Pitch

var.roll = Wiimote.Pitch

assign values of Wiimote.Pitch function to variable var.pitch

Roll is how much the top is tilted towards the right. It is -180 or +180 degree when the controller is upside-down, -90 degree when it is on its left side, +90 degree when it is on its right side. and 0 degree when it is flat.

Example

to get values of wimotes' roll use

Wiimote.Roll

var.roll = Wiimote.Roll

assign values of Wiimote.Roll function to variable var.roll

Wimote's Pitch And Roll Rotations
Wimote's Pitch And Roll Rotations


Pitch and Roll attempt to filter out accelerations. This may make them slightly jagged, especially when the controller is moving. You can use SmoothPitch and SmoothRoll if you don’t mind getting the wrong result if the controller moves, but you do want it to be smooth.

SmoothPitch and SmoothRoll should not be confused with the Smooth function. SmoothPitch and SmoothRoll are not smoothed or filtered in any way. You can still use the Smooth function to filter either SmoothPitch or normal Pitch for example.

Lets try to put all we have learnt so far together

This very basic script we going to use pitch,roll and debug function and we try out if wiimote is properly connected to PC / Laptop and if can be used in glovePie.


Script 1

/*
First Script - basic functions and wiimote test
Nintendo Wii Remote (Wiimote) Midi Controller For Ableton Live - Guide How To Do This 
Example of how to get values of wiimote's Pitch and Roll finction
And display simple message in Debug box using Debug function

*/

    var.roll = Wiimote.Roll
    var.pitch = Wiimote.Pitch

    debug = "Roll " + Var.roll + "  " + "Pitch " + Var.pitch


/*
Please note if you followed all steps correctly from this Tutorial
you should be getting message in debug box in a format similar to the one below

    Roll + - xx.xx degrees  Pitch  + - xx.xx degrees

Czes mazaki

*/

Lets take it one step further and add IF statement and Wiimote.up function

Wiimote.up function return values true if Up pressed

Script 2

/*
script2
Nintendo Wii Remote (Wiimote) Midi Controller For Ableton Live - Guide How To Do This 

Example of how to get values of wiimote's Pitch and Roll finction and use of If statement
Lets take it a one step further
And display simple message in Debug box using Debug function

*/
    If(wiimote.up){
       var.roll = Wiimote.Roll
       var.pitch = Wiimote.Pitch
       debug = "Wiimote Up Pressed  " +wiimote.up + " Roll " + Var.roll + "  " + "Pitch " + Var.pitch
       }

/*
Please note if you followed all steps correctly from this Tutorial
you should be getting message in debug box in a format similar to the one below

    Wiimote Up Pressed  True  Roll + - xx.xx degrees  Pitch  + - xx.xx degrees

  Czes Mazaki

*/

Midi Conversion

Right we already gained some knowledge about simple scripting in GlovePie

Now is time to learn how to convert Wiimote's Pitch and Roll Values in to midi range.

1 - 127

We going to use EnsureMapRange function to convert range from -90 to 90 degrees into new range 1 -127

variables

var.d1 = -90

var.d2 = 90

-90 and 90 represent angles

and round function

Yes Round(x) - Rounds x towards nearest integer

The reason why we going to use Round function is the out put values of EnsureMapRange

It has decimal points and we want integers 1 -127 not 1.xx etc.

EnsureMapRange(x, a, b, c, d) - Returns value x converted from the range [a, b] to the range [c, d] and values outside the range are mapped to the closest values inside the range



script 3

/*
script 3
Nintendo Wii Remote (Wiimote) Midi Controller For Ableton Live - Guide How To Do This 

Example of how to get values of wiimote's Pitch and Roll finction convert out put values
to midi range 1-127 And display simple message in Debug box using Debug function

*/
        var.d1 =-90
        var.d2 = 90
        Var.roll = round(EnsureMapRange(Wiimote.Roll, var.d1,var.d2,1,127))
        Var.pitch = round(EnsureMapRange(Wiimote.Pitch, var.d1,var.d2,1,127))

       debug = "Converting values to midi range 1-127 " + " Roll " + Var.roll + "  " + "Pitch " + Var.pitch
       }

/*
Please note if you followed all steps correctly from this Tutorial
you should be getting message in debug box in a format similar to the one below

    Converting values to midi range 1-127  Roll + xxx  Pitch  xxx

    Czes Mazaki

*/

Setting Up Midi Yoke In Ableton Live

Ableton Midi Yoke Set Up
Ableton Midi Yoke Set Up

Wiimote Midi Mapping Script For Ableton

At the moment you may think why relay need script like that .

We wont relay need it in this example because we going to map only 3 values but in future when you will decide to map more functions to your wii remote and use wiimote.up wiimote.down buttons to control various devices you will realize how helpful it is.

Simple Midi Mapper for Ableton Live

script 4
Nintendo Wii Remote (Wiimote) Midi Controller For Ableton Live - Guide How To Do This 
Simple Midi Mapper for Ableton Live

*/

   //maps device on/off switches

     if pressed(one) then midi.Control2 = 1

   //map wimote's roll gesture to macro knobs or any knobs / sliders

     if pressed(two) then midi.Control3 = 1

   //map wimote's Pitch gesture to macro knobs or any knobs / sliders

    if pressed(three) then midi.Control4 = 1


/*

    Czes Mazaki

*/

Enter Midi Map Mode

Midi Map Mode
Midi Map Mode

Once You entered Midi map mode in ableton select device you want map controllers to and press

keyboard keys 1 - 3 each at the time and assign conntrolers


Example

CC 34 Key 1 - Device on/Off

CC 35 Key 2 - Filter Freq

CC 36 Key 2 - Filter LFO Freq

Now is time To test It Out

Hold down wiimote.up button and enjoy pitch and Roll functions :)

You can Map these controllers to any device

script 5

/*
script 5
Nintendo Wii Remote (Wiimote) Midi Controller For Ableton Live - Guide How To Do This 
Simple script controling  Ableton Live device

*/

    var.de1 =-90
    var.de2 = 90
    var.roll = round(EnsureMapRange(Wiimote.Roll, var.de1,var.de2,1,127))
    var.pitch = round(EnsureMapRange(Wiimote.Pitch, var.de1,var.de2,1,127))

    debug = Var.roll + "  " + Var.pitch
        if wiimote.up then
           Midi.Control2 = 1
           Midi.Control3 = Var.roll
           Midi.Control4 = Var.pitch
        else
           Midi.Control2 = 0
           Midi.Control3 = 1
           Midi.Control4 = 1
       endif



/*

    Czes Mazaki

*/

Download script4 and 5

http://www.easy-share.com/3FAF2A34ED1F11E09676002481FAD55A/script 4 and 5.rar

Outro

This is not the end it was just simple idea of how to create simple midi controller. It can be extended of use wiimote.up,down,left,right buttons.You will be able to control 4 devices with 3 controllers assign to it. Imagine if you could use combination of A / B button held with other button . You could control 16 devices.If you decide to go further try to play with x,y,z data. You could control 16 effects 4 parameters on each .How about connecting nun-chuck or using 2 wiimotes .There is many possibilities.Enjoy!!

tag cloud

nintendo wii nintendo bluetooth controller wii remote desktop pc midi wiimote daw ableton live midi controller nunchuck nintendo wii remote wiimote controller glovepie scripts wiimote wiimote scripts connect wiimote pc wiimote glovepie wiimote windows pc wiimote wiimote computer sync wiimote wiimote remote connect wiimote to pc wiimote on pc wiimote for pc glovepie wiimote glovepie wiimote script midi at ableton live midi wiimote pitch roll midi virtual cable midi device virtual midi cable default midi device midi yoke bluetooth hid device virtual midi control midi osc build midi controller glovepie website glove programmable input emulator controller nintendo wii wiimote sync wii wiimote glovepie midi cable WYVAFHA6JK4C


Comments 3 comments

easylearningweb profile image

easylearningweb 5 years ago

Wow, extensive detailed first hub...thanks for sharing this information. Welcome to Hubpages and good luck with you writing.

Regards

Easylearningweb


Relys 4 years ago

Best write up ever. It's a shame it took forever to find this gem!


Jonny Hotchkiss 10 months ago

thanks buddy, very useful.

noticed a little ctrl+c/v error in ya pitch explanation.

Example

to get values of wimotes' Pitch use

Wiimote.Pitch

var.roll = Wiimote.Pitch

assign values of Wiimote.Pitch function to variable var.pitch

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working