GlovePIE:Stepmania with Drums

From WiiLi

Jump to: navigation, search
/*
  WiiRemoteDrum for Stepmania and MIDI for two Wiimotes
  RBuccigrossi (Butch) 11/11/2007
  Butch's version of  Will T.'s Version of Carl's version of Bob's Version of 
       Wii Drums!   No other program required.

 This script uses two Wii Remotes for the left and the right stick.

 Right controller:
  - Down stroke types "Right" and makes a closed High Hat MIDI event
  - Left stroke types "Up" and an open High Hat
  - Any stroke with an "A" types "Right" and "Up" and hits a Mid Tom
  - Any stroke with a "B" is Cymbal1
 Left controller:
  - Down stroke types "Left" and a snare
  - Right stroke types "Down" and a base drum
  - Any stroke with an "A" types "Left" and "Down" and hits a Low Tom
  - Any stroke with a "B" is Cymbal2

 For menus, the cross works for up/down/left/right on the right remote,
 "Plus" for "Enter" and "Home" for "Escape".

 When using two remotes, the left remote has the left LED lit, and
 the right remote has the right LED lit.

 So for Stepmania, you have two ways to play:
   1) Using individual strokes for each arrow
   2) Holding down the A button and using a single hit for two arrows
 Note that holds are not currently implemented

*/

// Acceleration thresholds for hits
var.xHit = 2.0
var.yHit = 2.0

if (var.init != 1){
  var.init = 1
  var.mode1 = "Y";
  var.mode2 = "Y";
  Wiimote1.Leds = 8
  Wiimote2.Leds = 1
}

var.xRot1 = Wiimote1.gx
var.yRot1 = Wiimote1.gy
var.a1 = Wiimote1.A
var.b1 = Wiimote1.B
var.xRot2 = Wiimote2.gx
var.yRot2 = Wiimote2.gy
var.a2 = Wiimote2.A
var.b2 = Wiimote2.B

var.hit1 = (var.xRot1 < -var.xHit) || (var.yRot1 < -var.yHit);
var.hit2 = (var.xRot2 >  var.xHit) || (var.yRot2 < -var.yHit);

// Drum beat triggered
if (var.hit1) then
  if (var.xRot1 >= -var.xHit) {
    var.mode1 = "Y"
  } else {
    if (var.yRot1 >= -var.yHit) {
      var.mode1 = "X"
    }
  }
}
if (var.hit2) then
  if (var.xRot2 <= var.xHit) {
    var.mode2 = "Y"
  } else {
    if (var.yRot2 >= -var.yHit) {
      var.mode2 = "X"
    }
  }
}

var.OH = var.hit1 && (var.mode1 == "X") && (not (var.a1 || var.b1))
var.H = var.hit1 && (var.mode1 == "Y") && (not (var.a1 || var.b1))
var.M = var.hit1 && var.a1
var.C1 = var.hit1 && var.b1
var.B = var.hit2 && (var.mode2 == "X") && (not (var.a2 || var.b2))
var.S = var.hit2 && (var.mode2 == "Y") && (not (var.a2 || var.b2))
var.L = var.hit2 && var.a2
var.C2 = var.hit2 && var.b2

Left = var.S || var.L || Wiimote1.Left
Down = var.B || var.L || Wiimote1.Down
Right = var.H || var.M || Wiimote1.Right
Up = var.OH || var.M || Wiimote1.Up
Enter = Wiimote1.Plus
Escape = Wiimote1.Home

Midi.volume = 100%
Midi.BassDrum1 = var.B
Midi.AcousticSnare = var.S
Midi.CrashCymbal1 = var.C1
Midi.CrashCymbal2 = var.C2
Midi.HighMidTom = var.T
Midi.LowMidTom = var.M
Midi.LowTom = var.L
Midi.ClosedHiHat = var.H
Midi.OpenHiHat = var.OH

// note, unfortunately you can't set those Midi values inside the IF
// because IF statements in GlovePIE cause it to send the midi message
// again even if it hasn't changed, whereas outside IF statements it
// only sends a MIDI message if it has changed.
Personal tools
Online Casino - best online casino reviews.
Facebook Developers - facebook applications, facebook developers, facebook development, social network application development and viral widget social media strategy