Documentation ¶
Overview ¶
Package midi provides interfaces for reading and writing of MIDI messages.
Since they are handled slightly different, this packages introduces the terminology of "live"/cable MIDI reading/writing for dealing with MIDI messages as "over the wire" (in realtime) as opposed to smf MIDI reading/writing to Standard MIDI Files (SMF).
However both variants can be used with io.Writer and io.Reader and can thus be "streamed".
This package provides a Reader and Writer interface that is common to live and SMF MIDI handling. This should allow to easily develop transformations (e.g. quantization, filtering) that may be used in both cases.
If you want a comfortable common package providing everything at a high level, use the porcelain packages
gitlab.com/gomidi/midi/reader gitlab.com/gomidi/midi/writer
The underlying core implementations can be found here:
gitlab.com/gomidi/midi/midireader (live reading) gitlab.com/gomidi/midi/midiwriter (live writing) gitlab.com/gomidi/midi/smf/smfreader (SMF reading) gitlab.com/gomidi/midi/smf/smfwriter (SMF writing) gitlab.com/gomidi/midi/smf/smftrack (SMF modification)
The core of the MIDI messages that can be written or analyzed can be found here:
gitlab.com/gomidi/midi/midimessage/channel (Channel Messages) gitlab.com/gomidi/midi/midimessage/meta (Meta Messages) gitlab.com/gomidi/midi/midimessage/realtime (System Realtime Messages) gitlab.com/gomidi/midi/midimessage/syscommon (System Common messages) gitlab.com/gomidi/midi/midimessage/sysex (System Exclusive messages)
Please keep in mind that that by the MIDI standard not all kinds of MIDI messages can be used in both scenarios.
System Realtime and System Common Messages are restricted to "over the wire", while Meta Messages are restricted to SMF files. However System Realtime and System Common Messages can be saved inside a SMF file which the help of SysEx escaping (F7).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPortClosed = fmt.Errorf("ERROR: port is closed")
ErrPortClosed should be returned from a driver when trying to write to a closed port.
var ErrUnexpectedEOF = fmt.Errorf("Unexpected End of File found.")
ErrUnexpectedEOF is returned, when an unexspected end of file is reached.
Functions ¶
func RegisterDriver ¶ added in v1.21.0
func RegisterDriver(d Driver)
Types ¶
type Driver ¶ added in v1.15.0
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.
type In ¶ added in v1.15.0
type In interface { Port // SetListener sets the callback function that is called when data arrives. SetListener(func(data []byte, deltaMicroseconds int64)) error // StopListening stops the listening. // When closing a MIDI input port, StopListening must be called before (from the driver). StopListening() error }
In is an interface for a MIDI input port
type Message ¶
type Message interface { // String inspects the MIDI message in an informative way. String() string // Raw returns the raw bytes of the MIDI message. Raw() []byte }
Message is a MIDI message.
type Out ¶ added in v1.15.0
type Out interface { Port // Write writes the given MIDI bytes over the wire and returns the bytes send // If the port is closed, ErrPortClosed must be returned. Write(b []byte) (int, error) }
Out is an interface for a MIDI output port.
type Port ¶ added in v1.15.0
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 driver to allow further adjustments. // When using the underlying driver, the user must take care of proper opening/closing etc. Underlying() interface{} }
Port is an interface for a MIDI port.
type ReadCloser ¶
ReadCloser is a Reader that must be closed at the end of reading.
type WriteCloser ¶
WriteCloser is a Writer that must be closed at the end of writing.
Directories ¶
Path | Synopsis |
---|---|
Package cc provides shortcuts for MIDI Control Change Messages
|
Package cc provides shortcuts for MIDI Control Change Messages |
examples
module
|
|
logger
Module
|
|
looper
Module
|
|
smfplayer
Module
|
|
smfrecorder
Module
|
|
sysex
Module
|
|
webmidi
Module
|
|
Package gm provides constants for instruments, drumkits and percussion keys based on the General MIDI standard.
|
Package gm provides constants for instruments, drumkits and percussion keys based on the General MIDI standard. |
internal
|
|
Package midiio provides helpers for connecting io.Readers and io.Writers to midi.Readers and midi.Writers.
|
Package midiio provides helpers for connecting io.Readers and io.Writers to midi.Readers and midi.Writers. |
Package midimessage provides helper functions for MIDI messages.
|
Package midimessage provides helper functions for MIDI messages. |
channel
Package channel provides MIDI Channel Messages
|
Package channel provides MIDI Channel Messages |
meta
Package meta provides MIDI Meta Messages
|
Package meta provides MIDI Meta Messages |
meta/key
Package key provides helper functions for key signature meta messages.
|
Package key provides helper functions for key signature meta messages. |
meta/meter
Package meter provides helper functions for time signature meta messages.
|
Package meter provides helper functions for time signature meta messages. |
realtime
Package realtime provides MIDI System Realtime Messages
|
Package realtime provides MIDI System Realtime Messages |
syscommon
Package syscommon provides MIDI System Common Messages
|
Package syscommon provides MIDI System Common Messages |
sysex
Package sysex provides MIDI System Exclusive Messages
|
Package sysex provides MIDI System Exclusive Messages |
Package midireader provides a reader for live/streaming/"over the wire" MIDI data.
|
Package midireader provides a reader for live/streaming/"over the wire" MIDI data. |
Package midiwriter provides a writer for live/streaming/"over the wire" MIDI data.
|
Package midiwriter provides a writer for live/streaming/"over the wire" MIDI data. |
Package player provides an easy way to play a SMF (Standard MIDI File).
|
Package player provides an easy way to play a SMF (Standard MIDI File). |
example/smfplayer
Module
|
|
Package reader provides an easy abstraction for reading of cable MIDI and SMF (Standard MIDI File) data.
|
Package reader provides an easy abstraction for reading of cable MIDI and SMF (Standard MIDI File) data. |
Package smf provides constants and interfaces for reading and writing of Standard MIDI Files (SMF).
|
Package smf provides constants and interfaces for reading and writing of Standard MIDI Files (SMF). |
smfreader
Package smfreader provides a reader of Standard MIDI Files (SMF).
|
Package smfreader provides a reader of Standard MIDI Files (SMF). |
smfwriter
Package smfwriter provides a writer of Standard MIDI Files (SMF).
|
Package smfwriter provides a writer of Standard MIDI Files (SMF). |
Package testdrv provides a gomidi/midi.Driver for testing.
|
Package testdrv provides a gomidi/midi.Driver for testing. |
tools
module
|
|
hyperarp
Module
|
|
midicat
Module
|
|
midispy
Module
|
|
smfimage
Module
|
|
smflyrics
Module
|
|
smfsysex
Module
|
|
smftrack
Module
|
|
v2
|
|
drivers/midicatdrv
Module
|
|
drivers/portmididrv
Module
|
|
drivers/rtmididrv
Module
|
|
drivers/webmididrv
Module
|
|
drivers/webmididrv/example
Module
|
|
example/listports
Module
|
|
example/logger
Module
|
|
example/simple
Module
|
|
example/smf0player
Module
|
|
example/smf0recorder
Module
|
|
example/smfplayer
Module
|
|
example/smfrecorder
Module
|
|
tools/midicat/cmd/midicat
Module
|
|
tools/midispy
Module
|
|
tools/midispy/cmd/midispy
Module
|
|
tools/smflyrics
Module
|
|
Package writer provides an easy abstraction for writing of cable MIDI and SMF (Standard MIDI File) data.
|
Package writer provides an easy abstraction for writing of cable MIDI and SMF (Standard MIDI File) data. |