Initial commit: MIDI port discovery tool

This commit is contained in:
Ian Gulliver
2026-02-10 21:07:47 -08:00
commit 130bab4bc8
4 changed files with 44 additions and 0 deletions

5
go.mod Normal file
View File

@@ -0,0 +1,5 @@
module qrun
go 1.25.6
require gitlab.com/gomidi/midi/v2 v2.3.22

2
go.sum Normal file
View File

@@ -0,0 +1,2 @@
gitlab.com/gomidi/midi/v2 v2.3.22 h1:4Q20o6q4BDo7i/KGvnwASeytOlrPI7MwsS7F2hA7fOM=
gitlab.com/gomidi/midi/v2 v2.3.22/go.mod h1:jDpP4O4skYi+7iVwt6Zyp18bd2M4hkjtMuw2cmgKgfw=

37
main.go Normal file
View File

@@ -0,0 +1,37 @@
package main
import (
"fmt"
"os"
"gitlab.com/gomidi/midi/v2"
_ "gitlab.com/gomidi/midi/v2/drivers/rtmididrv"
)
func main() {
defer midi.CloseDriver()
inPorts := midi.GetInPorts()
outPorts := midi.GetOutPorts()
fmt.Println("MIDI Input Ports:")
if len(inPorts) == 0 {
fmt.Println(" (none)")
}
for i, port := range inPorts {
fmt.Printf(" [%d] %s\n", i, port)
}
fmt.Println("\nMIDI Output Ports:")
if len(outPorts) == 0 {
fmt.Println(" (none)")
}
for i, port := range outPorts {
fmt.Printf(" [%d] %s\n", i, port)
}
if len(inPorts) == 0 && len(outPorts) == 0 {
fmt.Println("\nNo MIDI devices found.")
os.Exit(1)
}
}