View Full Version : using osculator and midipipe to play a musical-scale on a wiimote

04-25-2012, 01:26 AM
Hello osculator-wiimote users,

I've been working on a wiimote musical composition, making use of 3 general wiimote gestures:

1) Striking - like striking a drum - accomplished using the osculator "MIDI Note" feature, attached to the accel param.

2) Swinging - like waving a wand - accomplished using the osculator "MIDI Note w/ Params", triggered by a button, and using "Note Params" to set musical-pitch and velocity based on wiimote-pitch and roll. Note: this is enhanced by enabling in osculator Parameters/IO/MIDI Notes w Params settings/CHECK ON Emulate Pitch Bend Wheel.

3) Discrete Positions [the focus of this post] - like placing the wiimote in a specific spacial area (such as into different mailbox cubbies) to trigger different pitches - I accomplished this by combining osculator and midipipe. Osculator sends out MIDI CC (controller) signals associated with a parameter such as wiimote-pitch, and a trigger event using MIDI Note. Osculater sends these MIDI signals to a shared MIDI bus, such as IAC Bus 1. Midipipe then takes input from that MIDI bus, and applies an applescript trigger shown below, and then sends the new output do a different MIDI buss (ex: IAC Bus 2). This script is effectively similar to the osculator MIDI Note w/ Params, except that I am able to control which specific notes are returned -- in my current case, I'm using the wiimote-pitch parameter, to define areas of an arc that correspond with notes from a pentatonic minor scale [Cm: C, Eb, F, G, Bb, C] (vs. returning several chromatic notes [C, Db, D, Eb, E, F]).

-- script for MidiPipe to take control input and transform it to note-on events for a pentatonic scale
-- to be used with a Wii remote, and WiiToMidi or OSCulator
-- created 2012-04-03 donfede@casagrau.org

property InputController : 40 -- MIDI CC controller we are watching to calculte pitch value
property InputChannel : 4 -- listen to input from MIDI channel 4 only
property InputTrigger : 24 -- note-on/off event we are watching for (C0)
property FlagNotesOff : 0 -- flag to also send an all notes off command with the note event (0 == off)
property NewOutNote : 0
on runme(message)

-- look for 176 MIDI CC Status message from the controller we are watching
if ((item 1 of message = (175 + InputChannel) ) and (item 2 of message = InputController)) then
-- convert message to a Note-On event for the correct note.
-- divide the spectrum into fifths for pentatonic minor scale
if (item 3 of message is less than 22) then
set NewOutNote to 48 -- C4 (do)
else if (item 3 of message is less than 43) then
set NewOutNote to 51 -- Eb4 (me)
else if (item 3 of message is less than 64) then
set NewOutNote to 53 -- F4 (fa)
else if (item 3 of message is less than 85) then
set NewOutNote to 55 -- G4 (sol)
else if (item 3 of message is less than 106) then
set NewOutNote to 58 -- Bb4 (te)
else if (item 3 of message is less than 129) then
set NewOutNote to 60 -- C5 (do)
end if -- item 3 analyze

end if -- check for MIDI CC 176

-- look for for note on/off triggers to respond to, using the note value extracted above
if ((item 1 of message = (143 + InputChannel)) and (item 2 of message = InputTrigger)) or ((item 1 of message = (127 + InputChannel)) and (item 2 of message = InputTrigger)) then
-- set item 2 of message to (item 1 of NewOutNoteRef)
set item 2 of message to NewOutNote
set item 3 of message to 100 -- static volume of 100/127 to start with

if (FlagNotesOff = 1) then
-- insert CC 123 (all notes off) and then add the new note-on event
set returnMessage to {(175 + InputChannel), 123, 0, item 1 of message, item 2 of message, item 3 of message}
set returnMessage to {item 1 of message, item 2 of message, item 3 of message}
end if -- notes off check
return returnMessage
end if -- respond to triggers
end runme

Hopefully someone may find this useful.


04-25-2012, 11:37 AM
That is a great resource.
I did not know that MIDI Pipe had scripts, so for people that prefer to use MIDI over OSC, this is very useful and easy to set up.

04-28-2012, 06:37 PM
You mention "MIDI over OSC"... I read over the OSC example to provide D-Pad functionality you posted here ( http://www.osculator.net/forum/threads/1669-Request-for-how-to-use-WiiMote-D-Pad-to-switch-between-MIDI-Channels-(Ableton-Live)?p=7566&viewfull=1#post7566 ); but, I'm not clear how "if-then" logic can be hooked into OSC. Any pointers?


04-28-2012, 09:24 PM
Hi donfede,

I think it is unclear to you because IMHO the tools to easily process OSC are lacking at the moment. Also, OSCulator need improvements in this area. The problem is hard to tackle because:

1. OSC is relatively new compared to MIDI
2. OSC is still evolving
3. MIDI is less dynamic than OSC, and most of the messages are easily defined and understood. OSC has a total freedom and lacks the semantics MIDI has.

Compared to MIDI, OSC has the advantages of carrying a more rich set of data types, an friendlier message naming (a string like "/button/press" compared to MIDI binary stream), and a better resolution when using number types (integer, float, etc.).

With OSCulator, you can do some simple processing like what you point out in the thread you shared.
If you need more "if-then" style processing, then you will have to use more powerful tools like PureData, Max/MSP or Processing.