This project has moved. For the latest updates, please go here.

Using from Powershell

Topics: Samples
Jun 1, 2015 at 3:18 AM
Edited Jun 1, 2015 at 3:24 AM
Just in case a non-programmer (like me) want to control a Midi device from ProwerShell. It is very easy thanks to Midi.Net
formatting all wrong so get it from https://gist.github.com/imorrish/c71fa667cd588b4a8275#file-poshmididemo-ps1

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}
}
$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()
}