Last active
August 29, 2015 14:22
-
-
Save imorrish/c71fa667cd588b4a8275 to your computer and use it in GitHub Desktop.
PowerShell to control Midi device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Example using https://midinet.codeplex.com/ to control MIDI device | |
#Copy the following DLL's from above CodePlex project into path you want to use in the script | |
add-type -path 'C:\Users\IAN\Documents\WindowsPowerShell\Modules\Midi\CannedBytes.dll' | |
add-type -path 'C:\Users\IAN\Documents\WindowsPowerShell\Modules\Midi\CannedBytes.IO.dll' | |
add-type -path 'C:\Users\IAN\Documents\WindowsPowerShell\Modules\Midi\CannedBytes.Midi.dll' | |
$midiInCaps = new-object CannedBytes.Midi.MidiInPortCapsCollection | |
$midiOutCaps = new-object CannedBytes.Midi.MidiOutPortCapsCollection | |
"Input Devices-----------------------------" | |
For($i=0; $i -lt $midiInCaps.Count; $i++){ | |
"Device ID: $i Name: " + $midiInCaps[$i].Name | |
} | |
"Output Devices-----------------------------" | |
For($j=0; $j -lt $midiOutCaps.Count; $j++){ | |
"Device ID: $j Name: " + $midiOutCaps[$j].Name | |
if ($midiOutCaps[$j].Name -eq 'CMD MICRO'){$CMD=$j} #Update with your device | |
} | |
$midiOut = new-Object CannedBytes.Midi.MidiOutPort | |
$midiOut.Open($CMD) | |
If($midiOut){ | |
#Flash the left play button | |
$midiData = new-object CannedBytes.Midi.midiData | |
$midiData.Status=144 #Note on decimal | |
$midiData.Parameter1=23 #Play button on CMD Micro | |
$midiData.Parameter2=1 # 1=Green 2=Flash | |
$midiOut.ShortData($midiData) | |
$midiOut.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment