Skip to content

Commit

Permalink
add midi virtual null device
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviergodart committed Oct 30, 2024
1 parent 6d2f6d6 commit 9e4fc76
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions midi/midi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
package midi

import (
"errors"
"log"
"sync"

gomidi "gitlab.com/gomidi/midi/v2"
"gitlab.com/gomidi/midi/v2/drivers"
_ "gitlab.com/gomidi/midi/v2/drivers/rtmididrv" // autoregisters driver
rtmidi "gitlab.com/gomidi/midi/v2/drivers/rtmididrv" // autoregisters driver
)

const (
Expand Down Expand Up @@ -60,12 +59,13 @@ type midi struct {
// New creates a new midi. It retrieves the connected midi
// devices and starts a new goroutine for each of them.
func New() (Midi, error) {
devices := gomidi.GetOutPorts()
if len(devices) == 0 {
return nil, errors.New("no midi drivers")
virtualDevice, err := drivers.Get().(*rtmidi.Driver).OpenVirtualOut("no output device")
if err != nil {
return nil, err
}
devices := gomidi.GetOutPorts()
midi := &midi{
devices: devices,
devices: append(devices, virtualDevice),
}
midi.start()
return midi, nil
Expand Down

0 comments on commit 9e4fc76

Please sign in to comment.