Skip to content

Instantly share code, notes, and snippets.

@imorrish
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imorrish/c71fa667cd588b4a8275 to your computer and use it in GitHub Desktop.
Save imorrish/c71fa667cd588b4a8275 to your computer and use it in GitHub Desktop.
PowerShell to control Midi device
#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