Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrListenStopped = fmt.Errorf("ERROR: stopped listening")
View Source
var ErrPortClosed = fmt.Errorf("ERROR: port is closed")
View Source
var ( // REGISTRY is the registry for MIDI drivers REGISTRY = map[string]Driver{} )
Functions ¶
Types ¶
type Driver ¶
type Driver interface { // Ins returns the available MIDI input ports. Ins() ([]In, error) // Outs returns the available MIDI output ports. Outs() ([]Out, error) // String returns the name of the driver. String() string // Close closes the driver. Must be called for cleanup at the end of a session. Close() error }
Driver is a driver for MIDI connections. It may provide the timing delta to the previous message in micro seconds. It must send the given MIDI data immediately.
type In ¶
type In interface { Port // Listen listens for incoming messages. It returns a function that must be used to stop listening. // The onMsg callback is called for every non-sysex message. The onMsg callback must not be nil. // The config defines further listening options (see ListenConfig) // The listening must be stopped before the port may be closed. Listen( onMsg func(msg []byte, milliseconds int32), config ListenConfig, ) ( stopFn func(), err error, ) }
In is an interface for a MIDI input port
func InByNumber ¶
InByNumber opens the midi in port with the given number
type ListenConfig ¶
type ListenConfig struct { // TimeCode lets the timecode messages pass through, if set TimeCode bool // ActiveSense lets the active sense messages pass through, if set ActiveSense bool // SysEx lets the sysex messaes pass through, if set SysEx bool // SysExBufferSize defines the size of the buffer for sysex messages (in bytes). // SysEx messages larger than this size will be ignored. // When SysExBufferSize is 0, the default buffersize (1024) is used. SysExBufferSize uint32 // OnErr is the callback that is called for any error happening during the listening. OnErr func(error) }
ListenConfig defines the configuration for in port listening
type Out ¶
Out is an interface for a MIDI output port.
func OutByNumber ¶
OutByNumber opens the midi out port with the given number
type Port ¶
type Port interface { // Open opens the MIDI port. An implementation should save the open state to make it // save to call open when the port is already open without getting an error. Open() error // Close closes the MIDI port. An implementation should save the open state to make it // save to call close when the port is already closed without getting an error. Close() error // IsOpen returns wether the MIDI port is open. IsOpen() bool // Number returns the number of the MIDI port. It is only guaranteed that the numbers are unique within // MIDI port groups i.e. within MIDI input ports and MIDI output ports. So there may be the same number // for a given MIDI input port and some MIDI output port. Or not - that depends on the underlying driver. Number() int // String represents the MIDI port by a string, aka name. String() string // Underlying returns the underlying implementation of the driver Underlying() interface{} }
Port is an interface for a MIDI port. In order to be lockless (for realtime), a port is not threadsafe, so none of its method may be called from different goroutines.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
Package midicatdrv provides a Driver to connect via the program midicat (from the tools).
|
Package midicatdrv provides a Driver to connect via the program midicat (from the tools). |
Package portmididrv provides an Driver to connect via portmidi.
|
Package portmididrv provides an Driver to connect via portmidi. |
imported/portmidi
Package portmidi provides PortMidi bindings.
|
Package portmidi provides PortMidi bindings. |
Package rtmididrv provides a Driver to connect via rtmidi.
|
Package rtmididrv provides a Driver to connect via rtmidi. |
Package testdrv provides a Driver for testing.
|
Package testdrv provides a Driver for testing. |
Package webmididrv provides a Driver to connect to MIDI ports in the browser (via webmidi).
|
Package webmididrv provides a Driver to connect to MIDI ports in the browser (via webmidi). |
example
Module
|
Click to show internal directories.
Click to hide internal directories.