Documentation
¶
Overview ¶
package midi
Index ¶
- Variables
- func AFlatMaj() []byte
- func AMaj() []byte
- func AMin() []byte
- func BFlatMaj() []byte
- func BFlatMin() []byte
- func BMaj() []byte
- func BMin() []byte
- func CMaj() []byte
- func CMin() []byte
- func CSharpMin() []byte
- func DFlatMaj() []byte
- func DMaj() []byte
- func DMin() []byte
- func DSharpMin() []byte
- func EFlatMaj() []byte
- func EFlatMin() []byte
- func EMaj() []byte
- func EMin() []byte
- func FMaj() []byte
- func FMin() []byte
- func FSharpMaj() []byte
- func FSharpMin() []byte
- func GFlatMaj() []byte
- func GMaj() []byte
- func GMin() []byte
- func GSharpMin() []byte
- func MetaChannel(ch uint8) []byte
- func MetaCopyright(text string) []byte
- func MetaCuepoint(text string) []byte
- func MetaDevice(text string) []byte
- func MetaInstrument(text string) []byte
- func MetaKey(key uint8, isMajor bool, num uint8, isFlat bool) []byte
- func MetaLyric(text string) []byte
- func MetaMarker(text string) []byte
- func MetaMessage(typ byte, data []byte) []byte
- func MetaMeter(num, denom uint8) []byte
- func MetaPort(p uint8) []byte
- func MetaProgram(text string) []byte
- func MetaSMPTE(hour, minute, second, frame, fractionalFrame byte) []byte
- func MetaSequenceNo(no uint16) []byte
- func MetaSequencerData(data []byte) []byte
- func MetaTempo(bpm float64) []byte
- func MetaText(text string) []byte
- func MetaTimeSig(numerator, denominator, clocksPerClick, demiSemiQuaverPerQuarter uint8) []byte
- func MetaTrackSequenceName(text string) []byte
- func MetaUndefined(typ byte, data []byte) []byte
- func ParseStatus(b byte) (messageType uint8, messageChannel uint8)
- func ReadByte(rd io.Reader) (byte, error)
- func ReadMetaData(tp MessageType, rd io.Reader) (data []byte, err error)
- func ReadNBytes(n int, rd io.Reader) ([]byte, error)
- func ReadUint24(rd io.Reader) (uint32, error)
- func SysEx(msg []byte) []byte
- type Channel
- type Driver
- type Filter
- type In
- type Message
- func (m Message) BPM() float64
- func (msg Message) Change() int8
- func (msg Message) Channel() int8
- func (msg Message) Controller() int8
- func (m Message) Is(t MessageType) bool
- func (m Message) IsAllOf(ts ...MessageType) bool
- func (m Message) IsNot(t MessageType) bool
- func (m Message) IsNoteEnd() bool
- func (m Message) IsNoteStart() bool
- func (m Message) IsOneOf(ts ...MessageType) bool
- func (msg Message) Key() int8
- func (m Message) Meter() (num, denom uint8)
- func (msg Message) Pitch() (relative int16, absolute int16)
- func (msg Message) Pressure() int8
- func (msg Message) Program() int8
- func (m Message) String() string
- func (msg Message) Text() string
- func (m Message) TimeSig() (numerator, denominator, clocksPerClick, demiSemiQuaverPerQuarter uint8)
- func (msg Message) Velocity() int8
- type MessageType
- type Out
- type Port
- type Receiver
- type Sender
- type SenderTo
Constants ¶
This section is empty.
Variables ¶
var ChannelType = map[uint8]MessageType{ 0: Channel0, 1: Channel1, 2: Channel2, 3: Channel3, 4: Channel4, 5: Channel5, 6: Channel6, 7: Channel7, 8: Channel8, 9: Channel9, 10: Channel10, 11: Channel11, 12: Channel12, 13: Channel13, 14: Channel14, 15: Channel15, }
var EOT = MetaMessage(byteEndOfTrack, nil)
EndOfTrack you should not use this. Use the smf package instead.
var ErrPortClosed = fmt.Errorf("ERROR: port is closed")
ErrPortClosed should be returned from a driver when trying to write to a closed port.
Functions ¶
func AFlatMaj ¶
func AFlatMaj() []byte
AFlatMaj returns the MIDI key signature meta message for Ab Major
func BFlatMaj ¶
func BFlatMaj() []byte
BFlatMaj returns the MIDI key signature meta message for Bb Major
func BFlatMin ¶
func BFlatMin() []byte
BFlatMin returns the MIDI key signature meta message for Bb Minor
func CSharpMin ¶
func CSharpMin() []byte
CSharpMin returns the MIDI key signature meta message for C# Minor
func DFlatMaj ¶
func DFlatMaj() []byte
DFlatMaj returns the MIDI key signature meta message for Db Major
func DSharpMin ¶
func DSharpMin() []byte
DSharpMin returns the MIDI key signature meta message for D# Minor
func EFlatMaj ¶
func EFlatMaj() []byte
EFlatMaj returns the MIDI key signature meta message for Eb Major
func EFlatMin ¶
func EFlatMin() []byte
EFlatMin returns the MIDI key signature meta message for Eb Minor
func FSharpMaj ¶
func FSharpMaj() []byte
FSharpMaj returns the MIDI key signature meta message for F# Major
func FSharpMin ¶
func FSharpMin() []byte
FSharpMin returns the MIDI key signature meta message for F# Minor
func GFlatMaj ¶
func GFlatMaj() []byte
GFlatMaj returns the MIDI key signature meta message for Gb Major
func GSharpMin ¶
func GSharpMin() []byte
GSharpMin returns the MIDI key signature meta message for G# Minor
func MetaChannel ¶
func MetaCopyright ¶
func MetaCuepoint ¶
func MetaDevice ¶
func MetaInstrument ¶
func MetaMarker ¶
func MetaMessage ¶
func MetaProgram ¶
func MetaSequenceNo ¶
func MetaSequencerData ¶
func MetaTimeSig ¶
Raw returns the raw MIDI data
func MetaTrackSequenceName ¶
func MetaUndefined ¶
func ParseStatus ¶
ParseStatus parses the status byte and returns type and channel
This is a slightly modified variant of the readStatusByte function from Joe Wass. See the file midi_functions.go for the original.
func ReadMetaData ¶
func ReadMetaData(tp MessageType, rd io.Reader) (data []byte, err error)
func ReadNBytes ¶
ReadNBytes reads n bytes from the reader
func ReadUint24 ¶
ReadUint24 parse a 3-byte 24 bit integer from a Reader. It returns the 32-bit value and an error. This is a slightly modified variant of the parseUint24 function from Joe Wass. See the file midi_functions.go for the original.
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.
type Filter ¶
type Filter []MessageType
type In ¶
type In interface { Port SenderTo // 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 struct { Type MessageType Data []byte }
func NewMessage ¶
func ReadChannelMessage ¶
Read reads a channel message
func (Message) Change ¶
Change returns the MIDI controllchange a number from 0 to 127 or -1, if it is no controller message
func (Message) Channel ¶
Channel returns the MIDI channel - a number from 0 to 15 or -1, if it is no channel message or an invalid channel number
func (Message) Controller ¶
Controller returns the MIDI controller - a number from 0 to 127 or -1, if it is no controller message
func (Message) Is ¶
func (m Message) Is(t MessageType) bool
func (Message) IsAllOf ¶
func (m Message) IsAllOf(ts ...MessageType) bool
func (Message) IsNot ¶
func (m Message) IsNot(t MessageType) bool
func (Message) IsNoteEnd ¶
IsNoteEnd checks, if we have a de facto note end, i.e. a NoteoffMsg or a NoteOnMsg with velocity == 0
func (Message) IsNoteStart ¶
IsNoteStart checks, if we have a de facto note start, i.e. a NoteOnMsg with velocity > 0
func (Message) IsOneOf ¶
func (m Message) IsOneOf(ts ...MessageType) bool
func (Message) Key ¶
Key returns the MIDI key - a number from 0 to 127 or -1, if it is no noteOn / noteOff / PolyAfterTouch message or an invalid key
func (Message) Text ¶
Text returns the text for the meta messages
Lyric Copyright Cuepoint Device Instrument Marker Program Text TrackSequenceName
type MessageType ¶
type MessageType uint64
const ( ChannelMsg MessageType = 1 << iota MetaMsg RealTimeMsg SysCommonMsg SysExMsg NoteOnMsg NoteOffMsg ControlChangeMsg PitchBendMsg AfterTouchMsg PolyAfterTouchMsg ProgramChangeMsg MetaChannelMsg MetaCopyrightMsg MetaCuepointMsg MetaDeviceMsg MetaEndOfTrackMsg MetaInstrumentMsg MetaKeySigMsg MetaLyricMsg MetaTextMsg MetaMarkerMsg MetaPortMsg MetaSeqNumberMsg MetaSeqDataMsg MetaTempoMsg MetaTimeSigMsg MetaTrackNameMsg MetaSMPTEOffsetMsg MetaUndefinedMsg MetaProgramNameMsg TimingClockMsg TickMsg StartMsg ContinueMsg StopMsg ActiveSenseMsg ResetMsg SysExStartMsg SysExEndMsg SysExCompleteMsg SysExEscapeMsg SysExContinueMsg MTCMsg SongSelectMsg SPPMsg UndefinedMsg TuneMsg Channel0 Channel1 Channel2 Channel3 Channel4 Channel5 Channel6 Channel7 Channel8 Channel9 Channel10 Channel11 Channel12 Channel13 Channel14 Channel15 )
const UnknownMsg MessageType = 0
func Clear ¶
func Clear(b, flag MessageType) MessageType
func GetMessageType ¶
func GetMessageType(msg []byte) (mType MessageType)
func GetMetaMessage ¶
func GetMetaMessage(b byte) MessageType
func Set ¶
func Set(b, flag MessageType) MessageType
func Toggle ¶
func Toggle(b, flag MessageType) MessageType
func (MessageType) Is ¶
func (b MessageType) Is(flag MessageType) bool
func (MessageType) IsAllOf ¶
func (b MessageType) IsAllOf(flags ...MessageType) bool
func (MessageType) IsNot ¶
func (b MessageType) IsNot(flag MessageType) bool
func (MessageType) IsOneOf ¶
func (b MessageType) IsOneOf(flags ...MessageType) bool
func (MessageType) String ¶
func (m MessageType) String() string
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 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 Receiver ¶
type Receiver interface { // Receive receives a MIDI message. deltamicrosec is the delta to the previous note in microseconds (^-6) Receive(m Message, deltamicrosec int64) }
Receiver receives MIDI messages.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
drivers
|
|
midicatdrv
Module
|
|
portmididrv
Module
|
|
rtmididrv
Module
|
|
rtmididrv/imported/rtmidi
Module
|
|
webmididrv
Module
|
|
webmididrv/example
Module
|
|
listports
Module
|
|
logger
Module
|
|
simple
Module
|
|
smf0player
Module
|
|
smf0recorder
Module
|
|
smfplayer
Module
|
|
smfrecorder
Module
|
|
internal
|
|
tools
|
|
midicat/cmd/midicat
Module
|
|
midispy
Module
|
|
midispy/cmd/midispy
Module
|
|
smflyrics
Module
|