Use anything as a MIDI/OSC controller with GlovePIE

Share your favorite Ableton Live tips, tricks, and techniques.
forge
Posts: 17422
Joined: Wed Apr 21, 2004 9:47 am
Location: Queensland, AU
Contact:

Use anything as a MIDI/OSC controller with GlovePIE

Post by forge » Mon Mar 31, 2008 4:02 am

this has started in this thread:
http://www.ableton.com/forum/viewtopic.php?t=68280

but it's kind of outgrown it - GlovePIE is not just about using the Wiimote as a controler, although that is why I got into it, instead it allows you to use just about any hardware to send MIDI or OSC messages, including the mouse, trackpad, keyboard, joystick

GlovePIE is free here:
http://carl.kenner.googlepages.com/glovepie_download

it requires a bit of geekiness, although you can just get scripts off other people and paste them in, or load up script files, and the scripting is actually not that hard to get your head around really

SO this thread can be a repository for any GlovePIE scripts or tips

so I'll start by reposting the most useful postings in the other thread

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Wimote D-pad mouse wrote:here's a little script I just knocked up to control the mouse cursor with the Wiimote D-Pad

B is left click and A is right click

mouse.DirectInputX = mouse.DirectInputX - 15*deadzone(wiimote.Left)
mouse.DirectInputX = mouse.DirectInputX + 15*deadzone(wiimote.Right)
mouse.DirectInputY = mouse.DirectInputY + 15*deadzone(wiimote.Down)
mouse.DirectInputY = mouse.DirectInputY - 15*deadzone(wiimote.up)
Mouse.LeftButton = Wiimote.B
Mouse.RightButton = Wiimote.A

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Angstrom wrote:glovePie is just so excellent.

I've not really thought of a decent reason for using a Wiimote, but glovePIE has opened up the avenues for so many daft things it is untrue.
Multiple Keyboards
You can read from multiple keyboards with GlovePIE, if you have Windows XP. You will probably need extra USB keyboards. Multiple keyboards are rare, and not especially useful. You can’t write to multiple keyboards, because I haven’t seen any programs other than mine that can tell which keyboard you used.

Just put a number after the word keyboard, like this:
midi.BassDrum1 = keyboard2.Enter

It uses RawInput instead of DirectInput for reading multiple keyboards, so sometimes you can get better or worse results just by changing one of your “keyboard”s to a “keyboard1” so that it uses RawInput instead. You only need to mention keyboard1 once in your script to force it to use RawInput. RawInput will conflict with some exclusive-mode DirectInput software.

You can tell how many keyboards there are with Keyboard.Count. You can tell whether a keyboard exists with Keyboard2.Exists.
now, with 16 USB keyboards I think I could have a very cool interface!



today I have been controlling sampler from a USB skateboard game controller, lean forward and the filter opens, lean back and it closes. Very useless, but funny.

next I think I might try a bit of Speech recognition to midi.
that will certainly look like shite on stage. but again, entertaining for me.
Just use the said( ) function like this:
Enter = said(“drumfill”)

That will press the “Enter” key, whenever you say “drumfill” into the microphone.

You can also use the AskedFor( ) function like this:
Enter = AskedFor(“drumfill”)

The AskedFor function will only trigger if you say something like “can I please have a drumfill?”. It will not trigger if you just say “drumfill”
I altered that text a bit from the manual, I swapped the word Rocket Launcher for Drumfill. :)


------
more fun : get extra screen real estate.
It shifts the entire screen contents in any direction, exposing new desktop space. For example :

Screen.ScrollX =(Joystick1.x)*Screen.Width

will scroll the screen left and right and will triple the usable size of your screen !

I think this will be very useful for session a view that is 20 times wider than the screen :)

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

mouse as XYZ controller part 1 wrote:
I have been trying to use more than one mouse so that I can have 1 wireless mouse that I use as an X/Y/Z controller (wheel is Z)

this works

midi1.channel2.Control21 = MapRange(Mouse3.DirectInputX, 10,-10, 1,0)
midi1.channel2.Control22 = MapRange(Mouse3.DirectInputY, 10,-10, 1,0)

but it is erratic as hell - I need to figure out the right range to map or the right units to map in - I read in the manual that Mouse is either measured in 'Mickeys' (normally 400dpi) when using mouse.DirectInput but the example here

Pie.MouseDPI = 800
midi.BassDrum1 = mouse.DirectInputX < -0.5 inches
midi.CrashCymbal1 = mouse.DirectInputX > 0.5 inches
debug = mouse.DirectInputX in inches

is for a mouse that's 800 dpi and triggers those samples when moving 0.5 in to the left or right - I dont want that, I want it to sweep from 0-127 from left to right

using those settings here makes it jump from 0-127

not sure if that last debug line is needed

the mouse movement seems to reset itself every couple of centimetres and jump back to 0 - so moving left to right the mapped control in Live just keeps sweeping very quickly from 0-127
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Controlling Lives macros with a Wiimote using instant mapping wrote: Ok! here is a script I've been working on - I started with Chris Vine's script then went through and tried to pick out the relevant bits, checking against the manual

This script allows you to control knobs using the Roll and pitch motions and combined with Live's Instant mapping I'm using 8 of the Wiimote's buttons to choose which of the 8 macro controls to control in Live independently (so when the left button on the D-Pad is held the Roll motion turns Macro 1 on the selected device...etc) all the controls and buttons are described in the comments

this creates a nice little magic wand that lets you choose your knob then turn it

a nice added feature is the LEDs on the Wiimote follow which macro is selected - as there are only 4 LEDs then macros 5-8 are also represented by LEDs 1-4

on the Wiimote X is the roll from left side down buttons to the left, 90 degrees round to horizontal with the buttons facing up, Y is the next 90 degrees round to buttons facing right and Z is the Tilt and follows where the Wiimote points vertically, pointing at the ceiling or floor

pressing the "home" button makes controls 41-43 active which respond to x,y,z of the Wiimote which I've used for a Grain delay amount/feedback and pitch

at the moment the B trigger is set to enable controls 30,31,32 which I'm using as a reverb send and havent decided what else yet

you press the keys on the keyboard a,q,w,e,r,t,y,u,i,o,p,k,l to assign each of the control numbers in Live, because the motion of the Wiimote can make it difficult to assign controls

To use this with instant mapping you will need to set up the UserConfiguration.txt file so the encoders receive controls 33-40 - or you can change them in GLove PIE to whatever you want

so create a folder "GlovePIE" in C:\Documents and Settings\yourname\Application Data\Ableton\Live 7.0.2\Preferences\User Remote Scripts and save the UserConfiguration.txt file with your encoder settings in to it

then make sure your Wiimote is connected via Bluetooth, paste the following script into Glove PIE and hit run

you will also need MIDI yoke. This script uses "midi1" which on my system is "MIDI yoke NT 1" but you can use a different one by using the "replace all" in Glove PIE's search menu and replacing "midi1" with whatever number you want

so here's the script:
Script wrote: //Forge's Ableton script to control Macros with instant mapping
//thanks to Chris Vine

//pressing A triggers C0
midi1.channel3.C0 = Wiimote1.A

//these variables are created to help smooth the controls
//I'm exploring how to make it smoother
var.xRot = smooth((Wiimote1.gx * 30), 10)
var.yRot = smooth((Wiimote1.gy * 30), 10)
var.zRot = smooth((Wiimote1.gz * 30), 10)


//press keys to Map MIDI controls in Live - Wii changes too much to map
//easily - control30 uses A just because I added it later
//this is not case sensitive, a different command is probably needed to
// select case - I will explore better key commands with modifiers later

midi.Control30 = Keyboard.a

midi.Control31 = Keyboard.Q

midi.Control32 = Keyboard.W

midi.Control33 = Keyboard.E

midi.Control34 = Keyboard.R

midi.Control35 = Keyboard.T

midi.Control36 = Keyboard.Y

midi.Control37 = Keyboard.U

midi.Control38 = Keyboard.I

midi.Control39 = Keyboard.O

midi.Control41 = Keyboard.P

midi.Control42 = Keyboard.k

midi.Control43 = Keyboard.l


/* if B is pressed these controls are active
using a range of 13 to -13 seems to allow for a full MIDI knob sweep
rolling 90 deg left to right from Wii left side down with buttons to the left
*/

if Wiimote1.B = true {
midi1.Control30= (EnsureMapRange(var.zRot, 13,-13, 0,1))
midi1.Control31= (EnsureMapRange(var.xRot, 13,-13, 0,1))
midi1.Control32= (EnsureMapRange(var.yRot, 13,-13, 0,1))
}


//with Left D-pad button held, roll controls Macro 1 and
//LED 1 lights up
if Wiimote1.Left = true {
midi3.Control33= (EnsureMapRange(var.xRot, 13,-13, 0,1))
Wiimote1.Led1 = true
wait 100 ms
Wiimote1.Led1 = false
}

//with Up D-pad button held, roll controls Macro 2 and
//LED 2 lights up
if Wiimote1.up = true {
midi3.Control34= (EnsureMapRange(var.xRot, 13,-13, 0,1))
Wiimote1.Led2 = true
wait 100 ms
Wiimote1.Led2 = false
}

//with Right D-pad button held, roll controls Macro 3 and
//LED 3 lights up
if Wiimote1.Right = true {
midi3.Control35= (EnsureMapRange(var.xRot, 13,-13, 0,1))
Wiimote1.Led3 = true
wait 100 ms
Wiimote1.Led3 = false
}

//with Down D-pad button held, roll controls Macro 4 and
//LED 4 lights up
if Wiimote1.Down = true {
midi3.Control36= (EnsureMapRange(var.xRot, 13,-13, 0,1))
Wiimote1.Led4 = true
wait 100 ms
Wiimote1.Led4 = false
}

//with minus button held, roll controls Macro 5 and
//LED 1 lights up
if Wiimote1.Minus = true {
//midi3.Control33= (EnsureMapRange(var.zRot, 13,-13, 0,1))
midi3.Control37= (EnsureMapRange(var.xRot, 13,-13, 0,1))
Wiimote1.Led1 = true
wait 100 ms
Wiimote1.Led1 = false
}

//with plus button held, roll controls Macro 6 and
//LED 2 lights up
if Wiimote1.Plus = true {
midi3.Control38= (EnsureMapRange(var.xRot, 13,-13, 0,1))
Wiimote1.Led2 = true
wait 100 ms
Wiimote1.Led2 = false
}

////with the '1' button held, roll controls Macro 7 and
//LED 3 lights up
if Wiimote1.one = true {
midi3.Control39= (EnsureMapRange(var.xRot, 13,-13, 0,1))
Wiimote1.Led3 = true
wait 100 ms
Wiimote1.Led3 = false
}

//with the '2' button held, roll controls Macro 8 and
//LED 4 lights up
if Wiimote1.two = true {
midi3.Control40= (EnsureMapRange(var.xRot, 13,-13, 0,1))
Wiimote1.Led4 = true
wait 100 ms
Wiimote1.Led4 = false
}

// if home is pressed, these controls are active - I use them like this:
//41: Grain delay dry/wet or send; 42: GDelay Pitch,
//43: GDly feedback - this is all still being worked out
if Wiimote1.Home = true {
midi1.Control41= (EnsureMapRange(var.xRot, 13,-13, 0,1))
midi1.Control42= (EnsureMapRange(var.yRot, 13,-13, 0,1))
midi1.Control43= (EnsureMapRange(var.zRot, 13,-13, 0,1))
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

forge wrote:regarding smoothing - I'm still trying to figure that one out, you can actually change the control from 0-127 1 at a time by moving the Wiimote a bit more slowly, but you can hear a bit of stepping when moving more quickly or naturally

the only smoothing going on in this script is with this:
var.xRot = smooth((Wiimote1.gx * 30), 10)
var.yRot = smooth((Wiimote1.gy * 30), 10)
var.zRot = smooth((Wiimote1.gz * 30), 10)

I think var.xRot is the variable which is created here with the initial value of the Wiimote's X value times 30 (which is for 30 frames per second which is the timing GlovePIE is working on I think) then the 10 means it is smoothing by averaging out values of the last 10 frames - this value can be changed to anything from 1-30 (actually it's probably 0-30 but 0 would be pointless)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
lightsaber script wrote:

this requires the sounds with the script file from http://www.wiiscript.co.uk/scripts/scripts/Scripts.zip

from this site:
http://www.wiiscript.co.uk/


//LiightSaber V 1.0 by Freeman Speaketh/US of Anarchy
//Feel free to modify and redistribute, but leave this here

//Credits to the creators of Mac Saber for the sound effects


// set these to the offsets when the wiimote is at rest
// will be different for each wiimote
var.xOffset = 12
var.yOffset = -36
var.zOffset = 14

//Settings
var.Swing = 20 //Adjusts how far you have to swing
var.Rumble = true //Enables or Disables rumble
var.swingTime = 50 //Adjusts time between swings (in ms)


//Home button exits LiightSaber. Double press exits GlovePIE
if Wiimote.Home
if doubleclicked(Wiimote.Home)
ExitPie
else
wait 200 ms
ExitProgram
endif
endif

//Change these to whatever sounds you like
PlaySound("Sounds/swing0.wav") = var.A
PlaySound("Sounds/swing1.wav") = var.B
PlaySound("Sounds/swing2.wav") = var.C
PlaySound("Sounds/swing3.wav") = var.D
PlaySound("Sounds/swing4.wav") = var.E
PlaySound("Sounds/swing5.wav") = var.F

PlaySound("Sounds/on0.wav") = var.H
PlaySound("Sounds/off0.wav") = var.I

//B Toggles Saber on/off
if Wiimote.B = 1 and (var.wait = false or null)
var.wait = true
if var.onOff = false
var.H = true
wait 500 ms
var.H = false
var.onOff = true
else
var.I = true
wait 500 ms
var.I = false
var.onOff = false
endif
var.wait = false
endif

if var.onOff = false
debug = "Press B to turn your LiightSaber on!"
Wiimote.Leds = 0
Wiimote.Rumble = 0

else
wait 25 ms
Wiimote.Leds = 0

//Determines amount of swing after 100 ms
var.swingTime = var.swingTime / 2
var.xRot = Wiimote.RawForceX + var.xOffset
wait var.swingTime ms
Wiimote.Rumble = 0
wait var.swingTime ms
var.xRot1 = wiimote.RawForceX + var.xOffset - var.xRot

var.yRot = Wiimote.RawForceY + var.yOffset
wait var.swingTime ms
Wiimote.Rumble = 0
wait var.swingTime ms
var.yRot1 = wiimote.RawForceY + var.yOffset - var.yRot

var.zRot = Wiimote.RawForceZ + var.zOffset
wait var.swingTime ms
Wiimote.Rumble = 0
wait var.swingTime ms
var.zRot1 = wiimote.RawForceZ + var.zOffset - var.zRot

debug = ""

//Determines sounds played


if var.xRot1 > var.Swing
var.A = true
Wiimote.Rumble = var.Rumble
Wiimote.Leds = 15
debug = "Hit! "
else if var.xRot1 < - var.Swing
var.B = true
Wiimote.Rumble = var.Rumble
Wiimote.Leds = 15
debug = "Hit! "
else if var.yRot1 > var.Swing
var.C = true
Wiimote.Rumble = var.Rumble
Wiimote.Leds = 15
debug = "Hit! "
else if var.yRot1 < - var.Swing
var.D = true
Wiimote.Rumble = var.Rumble
Wiimote.Leds = 15
debug = "Hit! "
else if var.zRot1 > var.Swing
var.E = true
Wiimote.Rumble = var.Rumble
Wiimote.Leds = 15
debug = "Hit! "
else if var.zRot1 < - var.Swing
var.F = true
Wiimote.Rumble = var.Rumble
Wiimote.Leds = 15
debug = "Hit! "
else
var.A = false
var.B = false
var.C = false
var.D = false
var.E = false
var.F = false
endif
endif
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

wiiscript wrote:some scripts and info can be found here: http://www.wiiscript.co.uk/scripts/scripts/Scripts.zip

from this site:
http://www.wiiscript.co.uk/
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

the GlovePIE forum on WiiLi wrote:
http://www.wiili.org/forum/glovepie-f44.html
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

friend_kami
Posts: 2255
Joined: Mon May 29, 2006 10:10 pm

Post by friend_kami » Mon Mar 31, 2008 9:24 am

holyfawk i just read some script examples and i think i just found a piece of software im sure to spend too much time with.

forge
Posts: 17422
Joined: Wed Apr 21, 2004 9:47 am
Location: Queensland, AU
Contact:

Post by forge » Mon Mar 31, 2008 9:50 am

8) hmm - it just ate my weekend and half of today.... loads of fun! :D

forge
Posts: 17422
Joined: Wed Apr 21, 2004 9:47 am
Location: Queensland, AU
Contact:

Post by forge » Mon Mar 31, 2008 1:07 pm

just to add - I was confusing myself for a while there trying to route MIDI so that I could record my automation tweaks, and separately from the notes as well

I only just realised that to do this I need to use 2 MIDI yoke tracks - one to route the MIDI from Glove PIE into a track to record the automation, then another one to set as the output for that track which I then choose as the input for the Glove PIE control surface chooser in the prefs - this seems obvious now but it completely had me stumped for ages because I was thinking I was using the normal remote settings in the MIDI prefs

I use a 3rd MIDI channel for the note, but I probably only need to use a different channel

rutgermuller
Posts: 290
Joined: Thu May 31, 2007 11:27 pm

Lovely

Post by rutgermuller » Mon Mar 31, 2008 2:55 pm

Oh yeah, Glove Pie and Live create a world that is yet to be explored. Thanks for this topic and these scripts. Looking forward to more scripts, because I'm not much of a coder.

Angstrom
Posts: 14923
Joined: Mon Oct 04, 2004 2:22 pm
Contact:

Post by Angstrom » Mon Mar 31, 2008 4:48 pm

Using keyboard number keys to view groups of tracks in Session, or different user 'views'

EG: viewing tracks 1-12 in one group, tracks 13-24 in another ... etc.
So, key pressing 1 would mean that tracks 1-12 are visible, key 2 = tracks 13-24 are visible.
But if you also have a couple of VST windows that you do not want to pan, such as a synth on top which you need to see all the time they can stay fixed in place.


IMPORTANT
how to use:
  • it will only work if Live 7 is the active window, if you have a different version then alter the obvious number in the first line
  • To begin press your number keypad "+" this will increase the width of Live's window by 3, for this demo.
  • if you have no number keypad (if you are on a laptop), then you can try to change the keys for some keys you do have, change lines to if(one)Window.Left etc
  • now press the numpad keys 1 to 3 and your Live display should pan. 1 will be the browser end of the GUI, 3 will be the effects end
  • to finish press the numpad key "-" (minus)
here's the code

Code: Select all

if (Window.AfterDash =="Live 7"){
debug="Live is the active window"
if(NumPadPlus)Window.Width=  Screen.Width*3;
if(NumPadMinus)Window.Width=  Screen.Width*1;
if(NumPad0)Window.Left =Screen.Width*0
if(NumPad1)Window.Left =(Screen.Width*1)*-1
if(NumPad2)Window.Left =(Screen.Width*2)*-1
if(NumPad3)Window.Left =(Screen.Width*3)*-1
}
of course if you want everything to pan , then simply change the word Window to the word "Screen" and you can have the whole thing panning backwards and forwards.
that way you can press "4" and see all your Vsti , and press "6" to see all your effects!.

of course Live effects and instruments don't float and stay where you put them... so only VSTi would be able to do that

forge
Posts: 17422
Joined: Wed Apr 21, 2004 9:47 am
Location: Queensland, AU
Contact:

Post by forge » Mon Mar 31, 2008 5:20 pm

cool!

it's not working with my external USB keyboard on my laptop

I'll try some other keys

Angstrom
Posts: 14923
Joined: Mon Oct 04, 2004 2:22 pm
Contact:

Post by Angstrom » Mon Mar 31, 2008 5:28 pm

forge wrote:cool!

it's not working with my external USB keyboard on my laptop

I'll try some other keys
try a debug=somekeynameorother

and see if the little debug window shows True when you press.
it may be that an external keyboard might need a Keyboard2. type identifier.

----

other useful keyboard commands - 'swallow' will steal key presses to make sure that Live doesn't get them. you can swallow a key press and turn it into something else without it, say, muting a track !
Last edited by Angstrom on Mon Mar 31, 2008 5:30 pm, edited 1 time in total.

forge
Posts: 17422
Joined: Wed Apr 21, 2004 9:47 am
Location: Queensland, AU
Contact:

Post by forge » Mon Mar 31, 2008 5:28 pm

I just tried and it didnt work

I'm on a laptop with an external monitor extending the desktop vertically and an external USB keyboard plugged in

but it's probably just a bit too 3.28 am for me right now

forge
Posts: 17422
Joined: Wed Apr 21, 2004 9:47 am
Location: Queensland, AU
Contact:

Post by forge » Mon Mar 31, 2008 5:36 pm

just tried this

if (Window.AfterDash =="Live 7"){
debug="Live is the active window"
if keyboard2.l = true {
Window.Width= Screen.Width*3;
}
if keyboard2.q = true {
Window.Width= Screen.Width*1;
}
if keyboard2.w = true {
Window.Left =Screen.Width*0
}
if keyboard2.e = true {
Window.Left =(Screen.Width*1)*-1
}
if keyboard2.r = true {
Window.Left =(Screen.Width*2)*-1
}
if keyboard2.t = true {
Window.Left =(Screen.Width*3)*-1
}

but no joy either

must sleep though

forge
Posts: 17422
Joined: Wed Apr 21, 2004 9:47 am
Location: Queensland, AU
Contact:

Post by forge » Mon Mar 31, 2008 5:40 pm

Angstrom wrote: other useful keyboard commands - 'swallow' will steal key presses to make sure that Live doesn't get them. you can swallow a key press and turn it into something else without it, say, muting a track !
yes! I found this one too and was going to post it

I'm trying to work out how to do that horrible ALT+Down*3 device selecting thing by pressing a key

like :

if keyboard.q = true {
keyboard.alt+down
keyboard.alt+down
keyboard.alt+down
}

Angstrom
Posts: 14923
Joined: Mon Oct 04, 2004 2:22 pm
Contact:

Post by Angstrom » Mon Mar 31, 2008 6:07 pm

mega force focus on all racks

Code: Select all

if(NumPad0){
Key.LeftAlt + down +down +down = NumPad0
}
once you press num pad 0 any track which is selected then the rack will get selected. I mean it really wants to be selected !
and if you change track, then that rack is selected anyway ... somehow!

it's a bit mental and unfinished, but the idea works :)
it just needs a little option to choose the tracks.


BTW, those conditionals are Booleans, so you don't need to 'double check' them. Also a single '=' makes my blood run cold as a conditional check. single should always be assignment in my book. I know he allows single, but that's just evil.

rutgermuller
Posts: 290
Joined: Thu May 31, 2007 11:27 pm

Re: Use anything as a MIDI/OSC controller with GlovePIE

Post by rutgermuller » Mon Mar 31, 2008 7:41 pm

Dear Forge,

I've been trying to figure out how to use your macro control script for the last hours, but haven't been able to work it out :(. I haven't got any knowledge of Instant Mapping.

1)Bluetooth works (via the Bluesoleil stack)

2)MidiYoke works

3)Wiimote works (also in Live with other scripts)

4) I searched for this instant mapping thing in the Manual, and figured out it's unsupported :).

I edited the userconfig.txt

Is this what I need to do?

Code: Select all

Encoder1: 33
Encoder2: 34
Encoder3: 35
Encoder4: 36
Encoder5: 37
Encoder6: 38
Encoder7: 39
Encoder8: 40
Is this alright the way it is?

Code: Select all

GlobalChannel: 0
5) Then I figured I should do the following:
Image

6) After that I'm completly lost... I know I should map the keys, with the KEY map button. Should I map some of the characters 'aqwertyuiopkl' to any of the 8 macro knobs? (I also went through Live's Macro Control Tutorial but that didn't shed any light on this case)

7)...

Thanks a bunch.

rutgermuller
Posts: 290
Joined: Thu May 31, 2007 11:27 pm

Post by rutgermuller » Mon Mar 31, 2008 7:48 pm

Here's : KidQuaalude's wii to midi script I use

Code: Select all

==============================================================================*/
/*==============================================================================
Note :
This script has some performance problems when using the nunchuk or classic
controller. The result is some note-ons may be lost. Hit the wiimote 'home'
button to disable CC processing if this occurs. Hopefully this problem will be
resolved in a future release of GlovePIE.
==============================================================================*/

//initialise (this 'if' part useful for code you only need to run once)
if (var.Init = 0) then

midi.DeviceOut = 0; // default midi device
midi.DefaultChannel = 1; //midi channel
Wiimote1.Leds = 9; //set 1 and 4 leds
var.CCEnabled = true; //ccs enabled?
var.Prog1 = 1; //instrument number
var.Init = 1; // initialised (do not run again)

end if

/*==============================================================================
Wiimote #1
==============================================================================*/

/*==============================================================================
CCs
==============================================================================*/

//only if ccs enabled
if (var.CCEnabled) then

midi.Control10=(EnsureMapRange(Wiimote1.gx,1,-1,0,1))
//decrease y sensitivity
midi.Control11=(EnsureMapRange(Wiimote1.gy,1,0,0,1))
midi.Control12=(EnsureMapRange(Wiimote1.gz, 1,-1,0,1))

if (Wiimote1.HasNunchuk) then
midi.Control20=(EnsureMapRange(Wiimote1.Nunchuk.gx,1,-1,0,1));
//decrease y sensitivity
midi.Control21=(EnsureMapRange(Wiimote1.Nunchuk.gy,1,0,0,1));
midi.Control22=(EnsureMapRange(Wiimote1.Nunchuk.gz,1,-1,0,1));
midi.Control23=(EnsureMapRange(Wiimote1.Nunchuk.JoyX,-1,1,0,1));
midi.Control24=(EnsureMapRange(Wiimote1.Nunchuk.JoyY,1,-1,0,1));
end if

if (Wiimote1.HasClassic) then
midi.Control20=(EnsureMapRange(Wiimote1.Classic.Joy1X,-1,1,0,1));
midi.Control21=(EnsureMapRange(Wiimote1.Classic.Joy1Y,1,-1,0,1));
midi.Control22=(EnsureMapRange(Wiimote1.Classic.Joy2X,-1,1,0,1));
midi.Control23=(EnsureMapRange(Wiimote1.Classic.Joy2Y,1,-1,0,1));
end if

end if

/*==============================================================================
Midi Notes
==============================================================================*/

if Wiimote1.A then
//fix for multiple note-ons
if (not midi.C3) then
midi.C3 = true;
end if
else
midi.C3 = false;
end if

if Wiimote1.B then
//fix for multiple note-ons
if (not midi.D3) then
midi.D3 = true;
end if
else
midi.D3 = false;
end if

if Wiimote1.Up then
//fix for multiple note-ons
if (not midi.E3) then
midi.E3 = true;
end if
else
midi.E3 = false;
end if

if Wiimote1.Down then
//fix for multiple note-ons
if (not midi.F3) then
midi.F3 = true;
end if
else
midi.F3 = false;
end if

if Wiimote1.Left then
//fix for multiple note-ons
if (not midi.G3) then
midi.G3 = true;
end if
else
midi.G3 = false;
end if

if Wiimote1.Right then
//fix for multiple note-ons
if (not midi.A3) then
midi.A3 = true;
end if
else
midi.A3 = false;
end if

if Wiimote1.One then
//fix for multiple note-ons
if (not midi.B3) then
midi.B3 = true;
end if
else
midi.B3 = false;
end if

if Wiimote1.Two then
//fix for multiple note-ons
if (not midi.C4) then
midi.C4 = true;
end if
else
midi.C4 = false;
end if


//if classic controller connected
if (Wiimote1.HasClassic) then

if Wiimote1.Classic.a then
//fix for multiple note-ons
if (not midi.D4) then
midi.D4 = true;
end if
else
midi.D4 = false;
end if

if Wiimote1.Classic.b then
//fix for multiple note-ons
if (not midi.E4) then
midi.E4 = true;
end if
else
midi.E4 = false;
end if

if Wiimote1.Classic.x then
//fix for multiple note-ons
if (not midi.F4) then
midi.F4 = true;
end if
else
midi.F4 = false;
end if

if Wiimote1.Classic.y then
//fix for multiple note-ons
if (not midi.G4) then
midi.G4 = true;
end if
else
midi.G4 = false;
end if

if Wiimote1.Classic.Up then
//fix for multiple note-ons
if (not midi.A4) then
midi.A4 = true;
end if
else
midi.A4 = false;
end if

if Wiimote1.Classic.Down then
//fix for multiple note-ons
if (not midi.B4) then
midi.B4 = true;
end if
else
midi.B4 = false;
end if

if Wiimote1.Classic.Left then
//fix for multiple note-ons
if (not midi.C5) then
midi.C5 = true;
end if
else
midi.C5 = false;
end if

if Wiimote1.Classic.Right then
//fix for multiple note-ons
if (not midi.D5) then
midi.D5 = true;
end if
else
midi.D5 = false;
end if

if Wiimote1.Classic.LFull then
//fix for multiple note-ons
if (not midi.E5) then
midi.E5 = true;
end if
else
midi.E5 = false;
end if

if Wiimote1.Classic.RFull then
//fix for multiple note-ons
if (not midi.F5) then
midi.F5 = true;
end if
else
midi.F5 = false;
end if

if Wiimote1.Classic.ZR then
//fix for multiple note-ons
if (not midi.G5) then
midi.G5 = true;
end if
else
midi.G5 = false;
end if

if Wiimote1.Classic.ZL then
//fix for multiple note-ons
if (not midi.A5) then
midi.A5 = true;
end if
else
midi.A5 = false;
end if

if Wiimote1.Classic.Minus then
//fix for multiple note-ons
if (not midi.B5) then
midi.B5 = true;
end if
else
midi.B5 = false;
end if

if Wiimote1.Classic.Home then
//fix for multiple note-ons
if (not midi.C6) then
midi.C6 = true;
end if
else
midi.C6 = false;
end if

if Wiimote1.Classic.Plus then
//fix for multiple note-ons
if (not midi.D6) then
midi.D6 = true;
end if
else
midi.D6 = false;
end if

wait 30ms; //poll at less regular intervals

end if

//if nunchuck controller connected
if (Wiimote1.HasNunchuk) then
//remmed due to this method causing multiple note-ons on button press
//midi.G4 = Wiimote1.Nunchuk.CButton;
//midi.A4 = Wiimote1.Nunchuk.ZButton;
if Wiimote1.Nunchuk.CButton then
//fix for multiple note-ons
if (not midi.D4) then
midi.D4 = true;
end if
else
midi.D4 = false;
end if

if Wiimote1.Nunchuk.ZButton then
//fix for multiple note-ons
if (not midi.E4) then
midi.E4 = true;
end if
else
midi.E4 = false;
end if

wait 30ms; //poll at less regular intervals

end if



/*==============================================================================
Custom
==============================================================================*/

//
if (Wiimote1.Home) then
//switch
var.CCEnabled = not var.CCEnabled;

//show which mode we are in
if (var.CCEnabled) then
Wiimote1.Leds = 9; //set 1 and 4 leds
else
Wiimote1.Leds = 6; //set 2 and 3 leds
end if

//stop multiple calls while button held
wait 250ms;
end if

//program change
if Wiimote1.Plus then
if var.Prog1 < 128 then
var.Prog1 = var.Prog1 + 1;
midi.Instrument = var.Prog1;
wait 150ms;
end if
end if
if Wiimote1.Minus then
if var.Prog1 > 1 then
var.Prog1 = var.Prog1 - 1;
midi.Instrument = var.Prog1;
wait 150ms;
end if
end if

//display program
debug = "Program : " & var.Prog1
Hi!

There have already been a couple blogs about musical applications for the Wiimote on the mac from populus and ricemutt but I thought I'd blog a PC Wiimote tutorial and share my script which maps the the Wiimote to midi notes/ccs etc. Also, this script allows the use of the nunchuk peripheral and the classic controller as well as the Wiimote itself.

First of all to use my script you shall need the following :

Wiimote
Wii Nunchuk (optional)
Wii Classic Controller (optional)
A Bluetooth adapter for your PC
BlueSoleil Software (likely bundled with your bluetooth adapter)
GlovePIE software
And any app which accepts MIDI input.
My Script *updated*


Settting it Up...

1 - Start the BlueSoleil software.

2 - On your Wiimote press the 1 + 2 buttons. The leds at the bottom will now start to flash.

3 - In BlueSoleil, press the red 'sun' in the middle of the window, hopefully bluesoleil should find your wii remote (NINTENDO RVL-CNT-01).

4 - Once the device is found, right click on its icon in BlueSoleil and select 'Refresh Services'. If this fails make sure your Wiimotes leds are still flashing, if not press the 1 + 2 buttons again.

5 - Bluesoleil should have found a 'Human Interface Device' service and the mouse icon in BlueSoleil should have a square around it. Right click on this or the Wiimote icon and select 'Connect'.

6 - Once the Wiimote is connected to BlueSoleil, start the GlovePIE software and load my script.

7 - In GlovePIE under the 'CP-Settings' menu, click on the 'MIDI' item and set your default midi device to the MIDI device you would like to output to.

8 - Under the same menu, click the 'Wiimote Calibration' item and calibrate your Wiimote.

9 - Press the 'Run' button in the main GlovePIE window to execute the script. If all is well the leds on your Wiimote should stop flashing and 1 and 4 leds should be illuminated.


About the script

My script is just a general purpose one to get you started with the Wiimote. On the Wiimote the buttons are mapped as follows :

Wiimote A,B,DPad Up,Down,Left,Right,1,2 : Midi Notes

Wiimote + and - buttons : Program Change Up/Down

Wiimote Home button : Enable/Disable CCs

Wiimote X,Y,Z : MIDI CCs 10,11 and 12

Nunchuk C and Z buttons : Midi Notes

Nunchuk X,Y,Z : MIDI CCs 20,21 and 22

Nunchuk analog stick : MIDI CCs 23 and 24

Classic Controller buttons A,B,X,Y,ZL,ZR,L,R,-,+,Home,1 and 2 - Midi Notes

Classic Controller analog stick 1 : Midi CCs 20 and 21

Classic Controller analog stick 2 : Midi CCs 22 and 23

...Enjoy!
http://www.em411.com/blog/2744

forge
Posts: 17422
Joined: Wed Apr 21, 2004 9:47 am
Location: Queensland, AU
Contact:

Post by forge » Tue Apr 01, 2008 12:11 am

Angstrom wrote:mega force focus on all racks

Code: Select all

if(NumPad0){
Key.LeftAlt + down +down +down = NumPad0
}
once you press num pad 0 any track which is selected then the rack will get selected. I mean it really wants to be selected !
and if you change track, then that rack is selected anyway ... somehow!

it's a bit mental and unfinished, but the idea works :)
it just needs a little option to choose the tracks.


BTW, those conditionals are Booleans, so you don't need to 'double check' them. Also a single '=' makes my blood run cold as a conditional check. single should always be assignment in my book. I know he allows single, but that's just evil.
Angstrom - you are a legend!

incidentally I noticed in the manual there is a shorthand for things like

Mouse.DirectInputX = Mouse.DirectInputX + (gy * 30)

you can just put

Mouse.DirectInputX += (gy * 30)

Post Reply