First I enabled Remote Apple Events on the Mac mini in the family room on which IndigoServer was running (System Prefs > Sharing > check Remote Apple Events and enable access only for Administrators). Second, I downloaded and installed the freeware application "MidiPipe" (http://homepage.mac.com/nicowald/SubtleSoft/) onto my Mac Pro-based DAW (Digital Audio Workstation, if you're unfamiliar with digital musician lingo). Third, I set up a "pipe" within MidiPipe. The first module of the pipe took input from the USB-MIDI-attached keyboard to which the expression pedal was connected. The second module of the pipe processed each MIDI message using AppleScript and sent a Remote Apple Event to the IndigoServer application running on the Mac mini in the family room. Below is the AppleScript I used within the MidiPipe AppleScript module to control the brightness of the music room lights.
- Code: Select all
on runme(message)
tell application "IndigoServer" of machine "eppc://<admin username>:<admin password>@media-mac.local"
set newBrightness to round (item 3 of message / 127 * 100) rounding toward zero
if (item 1 of message = 176) and (item 2 of message = 7) then
if (newBrightness mod 5) = 0 then
brighten device "Music Room Light" to newBrightness
end if
end if
end tell
end runme
This code takes all incoming MIDI Continuous Controller messages (value 176 in the first item of the MIDI message), ensures that the CC message is a volume control message (value 7 in the second item). It then converts the MIDI volume value (which has a possible range of 0 to 127) to a percentage value (range of 0 to 100). To reduce the number of brightness INSTEON messages sent, it only sets the brightness of the lights in 5 percent increments (that's what the "mod" thing does).
The code could be easily modified to use the key-on or key-off velocity to determine the brightness, or to turn on or off specific lights based on which keys are pressed.
(EDIT: Corrected math in above code).