func OpenIn(d Driver, number int, name string) (in In, err error) {
	ins, err := d.Ins()
	if err != nil {
		return nil, fmt.Errorf("can't find MIDI input ports: %v", err)
	}
	if number >= 0 {
		for _, port := range ins {
			if number == port.Number() {
				in = port
				break
			}
		}
		if in == nil {
			return nil, fmt.Errorf("can't find MIDI input port %v", number)
		}
	} else {
		if name != "" {
			for _, port := range ins {
				if strings.Contains(port.String(), name) {
					in = port
					break
				}
			}
		}
		if in == nil {
			return nil, fmt.Errorf("can't find MIDI input port %v", name)
		}
	}
	if in == nil {
		panic("unreachable")
	}
	err = in.Open()
	return
}
OpenIn opens a MIDI input port with the help of the given driver.
To find the port by port number, pass a number >= 0.
To find the port by port name, pass a number < 0 and a non empty string.
package midi
import (
	"fmt"
	"strings"
)
var drivers = map[string]Driver{}
func RegisterDriver(d Driver) {
	drivers[d.String()] = d
}
type Driver interface {
	Ins() ([]In, error)
	Outs() ([]Out, error)
	String() string
	Close() error
}
type Port interface {
	Open() error
	Close() error
	IsOpen() bool
	Number() int
	String() string
	Underlying() interface{}
}
type In interface {
	Port
	SetListener(func(data []byte, deltaMicroseconds int64)) error
	StopListening() error
}
type Out interface {
	Port
	Write(b []byte) (int, error)
}
var ErrPortClosed = fmt.Errorf("ERROR: port is closed")