midix

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTrackSequenceName   = "crd"
	DefaultInstrument          = "Piano"
	DefaultTicksPerQuoaterNote = 960
)

Variables

View Source
var (
	DefaultProgram = gm.Instr_AcousticGrandPiano.Value()
)

Functions

func GetInPortNames

func GetInPortNames() []string

func GetOutPortNames

func GetOutPortNames() []string

Types

type Close

type Close struct {
}

func (Close) Call

func (Close) Call(t *smf.Track, deltaticks uint32)

type FixedTrack

type FixedTrack struct {
	TrackNo int
}

func NewFixedTrack

func NewFixedTrack(no int) *FixedTrack

func (*FixedTrack) IsOpType

func (*FixedTrack) IsOpType()

type MIDIReader

type MIDIReader struct{}

func NewReader

func NewReader() *MIDIReader

func (MIDIReader) Events

func (r MIDIReader) Events(rd io.Reader) iter.Seq[smf.TrackEvent]

func (MIDIReader) Play

func (r MIDIReader) Play(rd io.Reader, outPortName string) error

type MIDIWriter

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

func NewWriter

func NewWriter(
	ticksPerQuoaterNote uint16,
	set *TrackSetController,
	instrument string,
	program uint8,
) *MIDIWriter

func (*MIDIWriter) Close

func (w *MIDIWriter) Close()

func (*MIDIWriter) Key

func (w *MIDIWriter) Key(key uint8, isMajor bool, num uint8, isFlat bool)

func (*MIDIWriter) Lyric

func (w *MIDIWriter) Lyric(text string)

func (*MIDIWriter) Marker

func (w *MIDIWriter) Marker(text string)

func (*MIDIWriter) Meter

func (w *MIDIWriter) Meter(num, denom uint8)

func (*MIDIWriter) Note

func (w *MIDIWriter) Note(value float64, velocity uint8, key ...uint8) error

func (*MIDIWriter) Rest

func (w *MIDIWriter) Rest(value float64)

func (*MIDIWriter) Tempo

func (w *MIDIWriter) Tempo(bpm int)

func (*MIDIWriter) Text

func (w *MIDIWriter) Text(text string)

func (MIDIWriter) WriteTo

func (w MIDIWriter) WriteTo(out io.Writer) (int64, error)

type MetaInstrument

type MetaInstrument struct {
	Text string `json:"text"`
}

func (MetaInstrument) Call

func (m MetaInstrument) Call(t *smf.Track, deltaticks uint32)

type MetaKey

type MetaKey struct {
	Key     uint8 `json:"key"`
	IsMajor bool  `json:"is_major"`
	Num     uint8 `json:"num"`
	IsFlat  bool  `json:"is_flat"`
}

func (MetaKey) Call

func (m MetaKey) Call(t *smf.Track, deltaticks uint32)

type MetaLyric

type MetaLyric struct {
	Text string `json:"text"`
}

func (MetaLyric) Call

func (m MetaLyric) Call(t *smf.Track, deltaticks uint32)

type MetaMarker

type MetaMarker struct {
	Text string `json:"text"`
}

func (MetaMarker) Call

func (m MetaMarker) Call(t *smf.Track, deltaticks uint32)

type MetaMeter

type MetaMeter struct {
	Num   uint8 `json:"num"`
	Denom uint8 `json:"denom"`
}

func (MetaMeter) Call

func (m MetaMeter) Call(t *smf.Track, deltaticks uint32)

type MetaTempo

type MetaTempo struct {
	BPM float64 `json:"bpm"`
}

func (MetaTempo) Call

func (m MetaTempo) Call(t *smf.Track, deltaticks uint32)

type MetaText

type MetaText struct {
	Text string `json:"text"`
}

func (MetaText) Call

func (m MetaText) Call(t *smf.Track, deltaticks uint32)

type MetaTrack

type MetaTrack struct{}

func NewMetaTrack

func NewMetaTrack() *MetaTrack

func (*MetaTrack) IsOpType

func (*MetaTrack) IsOpType()

type MetaTrackSequenceName

type MetaTrackSequenceName struct {
	Text string `json:"text"`
}

func (MetaTrackSequenceName) Call

func (m MetaTrackSequenceName) Call(t *smf.Track, deltaticks uint32)

type NoteOff

type NoteOff struct {
	Channel uint8 `json:"channel"`
	Key     uint8 `json:"key"`
}

func (NoteOff) Call

func (n NoteOff) Call(t *smf.Track, deltaticks uint32)

type NoteOn

type NoteOn struct {
	Channel  uint8 `json:"channel"`
	Key      uint8 `json:"key"`
	Velocity uint8 `json:"velocity"`
}

func (NoteOn) Call

func (n NoteOn) Call(t *smf.Track, deltaticks uint32)

type OpFunc

type OpFunc interface {
	Call(t *smf.Track, deltaticks uint32)
}

type OpType

type OpType interface {
	IsOpType()
}

type ProgramChange

type ProgramChange struct {
	Channel uint8 `json:"channel"`
	Program uint8 `json:"program"`
}

func (ProgramChange) Call

func (p ProgramChange) Call(t *smf.Track, deltaticks uint32)

type Reader

type Reader interface {
	Events(r io.Reader) iter.Seq[smf.TrackEvent]
	Play(r io.Reader, outPortName string) error
}

type Track

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

func NewTrack

func NewTrack() *Track

func (*Track) Add

func (t *Track) Add(op *TrackOp)

func (*Track) AddTickDelta

func (t *Track) AddTickDelta(tickDelta uint32)

func (Track) Apply

func (t Track) Apply(tt *smf.Track)

func (Track) Len

func (t Track) Len() int

type TrackNoSelector

type TrackNoSelector interface {
	Select(opType OpType) int
}

type TrackNoSelectorImpl

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

func NewTrackNoSelector

func NewTrackNoSelector(trackNum int) (*TrackNoSelectorImpl, error)

func (TrackNoSelectorImpl) Select

func (t TrackNoSelectorImpl) Select(opType OpType) int

type TrackOp

type TrackOp struct {
	TickDelta uint32 `json:"tickdelta"`
	Func      OpFunc `json:"func"`
	Type      OpType `json:"type"`
}

func NewTrackOp

func NewTrackOp(tickDelta uint32, opType OpType, opFunc OpFunc) *TrackOp

func (TrackOp) Call

func (op TrackOp) Call(t *smf.Track)

type TrackSet

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

func NewTrackSet

func NewTrackSet(list []*Track) *TrackSet

func NewTrackSetFromTrackNum

func NewTrackSetFromTrackNum(trackNum int) *TrackSet

func (*TrackSet) Add

func (ts *TrackSet) Add(trackNo int, op *TrackOp)

func (TrackSet) Get

func (ts TrackSet) Get(i int) *Track

func (TrackSet) Len

func (ts TrackSet) Len() int

type TrackSetController

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

func NewTrackSetController

func NewTrackSetController(set *TrackSet, selector TrackNoSelector) *TrackSetController

func NewTrackSetControllerFromTrackNum

func NewTrackSetControllerFromTrackNum(trackNum int) (*TrackSetController, error)

func (*TrackSetController) Add

func (c *TrackSetController) Add(op *TrackOp)

func (*TrackSetController) Distribute

func (c *TrackSetController) Distribute(op *TrackOp)

func (TrackSetController) Set

func (c TrackSetController) Set() *TrackSet

type Writer

type Writer interface {
	Note(value float64, velocity uint8, key ...uint8) error
	Tempo(bpm int)
	Meter(num, denom uint8)
	Key(key uint8, isMajor bool, num uint8, isFlat bool)
	Text(text string)
	Lyric(text string)
	Marker(text string)
	Close()
	Rest(value float64)
	WriteTo(out io.Writer) (int64, error)
}

Jump to

Keyboard shortcuts

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