smf

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2019 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NOSMTPE int8 = 0
	SMTPE24 int8 = -24
	SMTPE25 int8 = -25
	SMTPE29 int8 = -29
	SMTPE30 int8 = -30
)

SMTPE time division midi valid codes

View Source
const (

	//TicksMaxValue midi division ticks max value with NOSMTPE
	TicksMaxValue uint16 = 0x7FFF

	//SMTPETicksMaxValue midi division ticks max value with SMTPE
	SMTPETicksMaxValue uint16 = 0xFF
)
View Source
const (
	MetaSequenceNumber    uint8 = 0x00
	MetaText              uint8 = 0x01
	MetaCopyrightNotice   uint8 = 0x02
	MetaSequenceTrackName uint8 = 0x03
	MetaInstrumentName    uint8 = 0x04
	MetaLyric             uint8 = 0x05
	MetaMarker            uint8 = 0x06
	MetaCuePoint          uint8 = 0x07
	MetaMIDIChannelPrefix uint8 = 0x20
	MetaMIDIPort          uint8 = 0x21
	MetaEndOfTrack        uint8 = 0x2F
	MetaSetTempo          uint8 = 0x51
	MetaSMTPEOffset       uint8 = 0x54
	MetaTimeSignature     uint8 = 0x58
	MetaKeySignature      uint8 = 0x59
	MetaSequencerSpecific uint8 = 0x7F
)

Meta events types

View Source
const (
	NoteOffStatus          uint8 = 0x80
	NoteOnStatus           uint8 = 0x90
	PKPressureStatus       uint8 = 0xA0
	ControllerChangeStatus uint8 = 0xB0
	ProgramChangeStatus    uint8 = 0xC0
	CKPressureStatus       uint8 = 0xD0
	PitchBendStatus        uint8 = 0xE0
)

MIDI Event status

View Source
const (
	MIDIDoubleEventSize uint32 = 3
	MIDISingleEventSize uint32 = 2
)

MIDI Event sizes

View Source
const (
	Format0 uint16 = 0
	Format1 uint16 = 1
	Format2 uint16 = 2
)

MIDI file formats

View Source
const (
	SysexStatus     uint8 = 0xF0
	SysexDataStatus uint8 = 0xF7
)

SysexStatus and SysexDataStatus is two flavors of sysex_events

View Source
const MaxChannelNumber uint8 = 0x0F

MaxChannelNumber max number of channel

View Source
const MaxDataByteSize uint8 = 0x7F

MaxDataByteSize max size for event data

View Source
const MetaStatus uint8 = 0xFF

MetaStatus for all Meta events

Variables

This section is empty.

Functions

func CheckMIDIStatus

func CheckMIDIStatus(status uint8) bool

CheckMIDIStatus checks is status MIDIEvent Status

func CheckMetaStatus

func CheckMetaStatus(status uint8) bool

CheckMetaStatus return true if status is MetaStatus

func CheckMetaType

func CheckMetaType(metaType uint8) bool

CheckMetaType return true if type is meta type

func CheckSMTPE

func CheckSMTPE(SMTPEFrames int8) bool

CheckSMTPE return true if SMTPEFrames is valid values

func CheckSingleMIDIEvent

func CheckSingleMIDIEvent(status uint8) bool

CheckSingleMIDIEvent return true for one byte size events

func CheckSysexStatus

func CheckSysexStatus(status uint8) bool

CheckSysexStatus check is status SysexStatus

Types

type Division

type Division struct {
	// contains filtered or unexported fields
}

Division represents time division struct

func NewDivision

func NewDivision(ticks uint16, SMTPEFrames int8) (*Division, error)

NewDivision creates new time division

func (*Division) GetSMTPE

func (d *Division) GetSMTPE() int8

GetSMTPE return SMTPE for division

func (*Division) GetTicks

func (d *Division) GetTicks() uint16

GetTicks return ticks for division

func (*Division) IsSMTPE

func (d *Division) IsSMTPE() bool

IsSMTPE checks is current division SMTPE

type Event

type Event interface {
	SetDtime(uint32) error
	GetDTime() uint32
	GetStatus() uint8
	GetData() []byte
	String() string
	GetChannel() uint8
	GetMetaType() uint8
}

Event represent any type of midi events

type MIDIEvent

type MIDIEvent struct {
	// contains filtered or unexported fields
}

MIDIEvent struct

func NewMIDIEvent

func NewMIDIEvent(deltaTime uint32, status uint8, channel uint8, firstDataByte uint8, secondDataByte uint8) (*MIDIEvent, error)

NewMIDIEvent create new midi event

func (*MIDIEvent) GetChannel

func (mEvent *MIDIEvent) GetChannel() uint8

GetChannel gets channel for MIDI event

func (*MIDIEvent) GetDTime

func (mEvent *MIDIEvent) GetDTime() uint32

GetDTime get events Delta time

func (*MIDIEvent) GetData

func (mEvent *MIDIEvent) GetData() []byte

GetData gets midi event data

func (*MIDIEvent) GetMetaType added in v1.0.2

func (mEvent *MIDIEvent) GetMetaType() uint8

GetMetaType get type for meta event

func (*MIDIEvent) GetStatus

func (mEvent *MIDIEvent) GetStatus() uint8

GetStatus get events status

func (*MIDIEvent) SetDtime

func (mEvent *MIDIEvent) SetDtime(deltaTime uint32) error

SetDtime sets deltaTime for event

func (*MIDIEvent) String

func (mEvent *MIDIEvent) String() string

String create string representation for MIDI event

type MIDIFile

type MIDIFile struct {
	// contains filtered or unexported fields
}

MIDIFile file struct

func NewSMF

func NewSMF(format uint16, division Division) (*MIDIFile, error)

NewSMF create new midi file

func (*MIDIFile) AddTrack

func (midi *MIDIFile) AddTrack(track *Track) error

AddTrack adds track to midi

func (*MIDIFile) GetDivision

func (midi *MIDIFile) GetDivision() Division

GetDivision return division for midi file

func (*MIDIFile) GetFormat

func (midi *MIDIFile) GetFormat() uint16

GetFormat return format for midi file

func (*MIDIFile) GetTrack

func (midi *MIDIFile) GetTrack(number uint16) *Track

GetTrack by number return nil if number > track num

func (*MIDIFile) GetTracksNum

func (midi *MIDIFile) GetTracksNum() uint16

GetTracksNum current number of tracks

func (*MIDIFile) RemoveTrack

func (midi *MIDIFile) RemoveTrack(number uint16) error

RemoveTrack remove track from midi

type MetaEvent

type MetaEvent struct {
	// contains filtered or unexported fields
}

MetaEvent struct

func NewMetaEvent

func NewMetaEvent(deltaTime uint32, metaType uint8, data []byte) (*MetaEvent, error)

NewMetaEvent Creates new meta event

func (*MetaEvent) GetChannel

func (mEvent *MetaEvent) GetChannel() uint8

GetChannel get channel for event

func (*MetaEvent) GetDTime

func (mEvent *MetaEvent) GetDTime() uint32

GetDTime return events delta time

func (*MetaEvent) GetData

func (mEvent *MetaEvent) GetData() []byte

GetData return data from MetaEvent

func (*MetaEvent) GetMetaType

func (mEvent *MetaEvent) GetMetaType() uint8

GetMetaType get type for meta event

func (*MetaEvent) GetStatus

func (*MetaEvent) GetStatus() uint8

GetStatus returns events status

func (*MetaEvent) SetDtime

func (mEvent *MetaEvent) SetDtime(deltaTime uint32) error

SetDtime sets deltaTime for event

func (*MetaEvent) String

func (mEvent *MetaEvent) String() string

String return string representation for meta event

type MidiError

type MidiError struct {
	// contains filtered or unexported fields
}

MidiError error type for midi package

func (*MidiError) Error

func (m *MidiError) Error() string

Error implements standart error interface

type SysexEvent

type SysexEvent struct {
	// contains filtered or unexported fields
}

SysexEvent for midi

func NewSysexEvent

func NewSysexEvent(deltaTime uint32, status uint8, data []byte) (*SysexEvent, error)

NewSysexEvent creataes new SysexEvent

func (*SysexEvent) GetChannel

func (sEvent *SysexEvent) GetChannel() uint8

GetChannel get channel for event

func (*SysexEvent) GetDTime

func (sEvent *SysexEvent) GetDTime() uint32

GetDTime get delta time for event

func (*SysexEvent) GetData

func (sEvent *SysexEvent) GetData() []byte

GetData get data for event

func (*SysexEvent) GetMetaType added in v1.0.2

func (sEvent *SysexEvent) GetMetaType() uint8

GetMetaType get type for meta event

func (*SysexEvent) GetStatus

func (sEvent *SysexEvent) GetStatus() uint8

GetStatus get status for event

func (*SysexEvent) SetDtime

func (sEvent *SysexEvent) SetDtime(deltaTime uint32) error

SetDtime sets deltaTime for event

func (*SysexEvent) String

func (sEvent *SysexEvent) String() string

String returns string representation of event

type Track

type Track struct {
	// contains filtered or unexported fields
}

Track midi track struct

func TrackFromArray

func TrackFromArray(events []Event) (*Track, error)

TrackFromArray create track from events array

func (*Track) AddEvent

func (t *Track) AddEvent(event Event) error

AddEvent adds events to EventsList

func (*Track) GetAllEvents

func (t *Track) GetAllEvents() []Event

GetAllEvents return array of all events in track

func (*Track) GetIterator

func (t *Track) GetIterator() *TrackIterator

GetIterator return iterator for track

func (*Track) Len

func (t *Track) Len() int

Len return number of events

func (*Track) RemoveAt

func (t *Track) RemoveAt(position uint32) error

RemoveAt removes event at position

type TrackIterator

type TrackIterator struct {
	// contains filtered or unexported fields
}

TrackIterator used for iteration over track

func (*TrackIterator) GetValue

func (iterator *TrackIterator) GetValue() Event

GetValue current value of iterator

func (*TrackIterator) MoveNext

func (iterator *TrackIterator) MoveNext() bool

MoveNext iterate to next element return true if there next element

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL