Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var MidiCmd = &cobra.Command{
Use: "midi",
Short: "A brief description of your command",
Long: ``,
}
MidiCmd represents the midi/midi command
View Source
var MidiDeviceCmd = &cobra.Command{ Use: "devices", Short: "Prints info about all devices", Long: ``, Run: func(cmd *cobra.Command, args []string) { if err := portmidi.Initialize(); err != nil { fmt.Println(err) os.Exit(1) } defer func() { if err := portmidi.Terminate(); err != nil { log.Fatal(err) } }() num := portmidi.CountDevices() fmt.Printf("Found %d devices. \n", num) if num == 0 { return } for i := 0; i < num; i++ { info := portmidi.Info(portmidi.DeviceID(i)) if info == nil { fmt.Println("Unable to read default output devices") os.Exit(1) } printDevice(portmidi.DeviceID(i), info) } fmt.Println("Default device: ") deviceID := portmidi.DefaultOutputDeviceID() info := portmidi.Info(deviceID) if info == nil { fmt.Println("Unable to read default output devices") os.Exit(1) } printDevice(deviceID, info) }, }
MidiDeviceCmd represents the MidiDevices command
View Source
var MidiDumpCmd = &cobra.Command{ Use: "dump", Short: "Dump incoming midi commands", Long: ``, Run: func(cmd *cobra.Command, args []string) { if err := portmidi.Initialize(); err != nil { fmt.Println(err) os.Exit(1) } defer func() { if err := portmidi.Terminate(); err != nil { log.Fatal(err) } }() var d portmidi.DeviceID if deviceID == "" { d = portmidi.DefaultOutputDeviceID() } else { i, err := strconv.Atoi(deviceID) if err != nil { fmt.Printf("Failed to transform deviceID %q to int: %v\n", deviceID, err) } d = portmidi.DeviceID(i) } i := portmidi.Info(d) if i == nil { fmt.Printf("Unable to find input interface %d \n", d) os.Exit(1) } fmt.Printf("Using midi device %d \n", d) in, err := portmidi.NewInputStream(d, 1024) if err != nil { fmt.Println(err) os.Exit(1) } fmt.Printf("Starting dump for midi interface %d ... \n", d) events := in.Listen() for event := range events { fmt.Printf("%x\t%d\t%d\n", event.Status, event.Data1, event.Data2) } }, }
MidiDumpCmd represents the MidiDevices command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.