smf

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: MIT Imports: 12 Imported by: 2

README

smf

Various tools to deal with Standard MIDI Files (SMF).

Note: If you are reading this on Github, please note that the repo has moved to Gitlab (gitlab.com/gomidi/smf) and this is only a mirror.

Installation

go get -u gitlab.com/gomidi/smf/cmd/smf

Usage

smf help
extract lyrics from an SMF file
smf lyrics -f='your-midi-file.mid'

documentation:

smf help lyrics
set tempo based on a metronome track

set the tempo based on the metronome beats on the second track

smf metro -f='input.mid' -o='ouput.mid' -t=1

documentation:

smf help metro
see content of SMF file
smf cat -f='your-midi-file.mid'

documentation:

smf help cat

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyToNote added in v0.0.6

func KeyToNote(key uint8) string

func ShowMessage added in v0.0.6

func ShowMessage(msg midi.Message) string

Types

type Bar

type Bar struct {
	Song      *Song
	No        uint16
	TimeSig   [2]uint8
	Positions Positions
	AbsPos    uint64
}

func (*Bar) AddPosition

func (b *Bar) AddPosition() *Position

func (*Bar) Columns

func (b *Bar) Columns() []string

func (*Bar) EndPos

func (b *Bar) EndPos() uint64

func (*Bar) Length

func (b *Bar) Length() uint64

func (*Bar) SetMessageByRelTicks

func (b *Bar) SetMessageByRelTicks(ticks uint64, trackNo uint16, msg midi.Message)

func (*Bar) SortPositions

func (b *Bar) SortPositions()

type Position

type Position struct {
	Bar      *Bar
	Comment  string
	Mark     string
	Beat     uint8
	Tempo    float32
	Fraction [2]float64
	Messages []*TrackMessage
}

func (*Position) AbsTicks

func (p *Position) AbsTicks() uint64

func (*Position) AddMessage

func (p *Position) AddMessage(track uint16, msg midi.Message)

func (*Position) GetMessage

func (p *Position) GetMessage(track uint16) *TrackMessage

func (*Position) SetMessage

func (p *Position) SetMessage(track uint16, msg midi.Message)

func (*Position) WithinFraction

func (p *Position) WithinFraction(ticks uint64) bool

type Positions

type Positions []*Position

func (Positions) Len

func (p Positions) Len() int

func (Positions) Less

func (p Positions) Less(a, b int) bool

func (Positions) Swap

func (p Positions) Swap(a, b int)

type Song

type Song struct {
	CopyRight  string
	Properties map[string]string
	Bars       []*Bar
	Tracks     []*Track
	// contains filtered or unexported fields
}

func New

func New() *Song

func ReadSMF

func ReadSMF(file string) (*Song, error)

func (*Song) AddBar

func (s *Song) AddBar(pos uint64, num, denom uint8) *Bar

func (*Song) AddTrack

func (s *Song) AddTrack(withContent bool, channel int8) *Track

func (*Song) BarLines

func (s *Song) BarLines() string

func (*Song) LastTrack

func (s *Song) LastTrack() *Track

func (*Song) NoOfContentTracks

func (s *Song) NoOfContentTracks() (no uint16)

func (*Song) RenumberBars

func (s *Song) RenumberBars()

func (*Song) RenumberTracks

func (s *Song) RenumberTracks()

func (*Song) Save

func (s *Song) Save(file string) error

func (*Song) TrackWidth

func (s *Song) TrackWidth(i int) uint8

type TempoChange

type TempoChange struct {
	AbsPos   uint64
	TempoBPM float64
}

type TempoChanges

type TempoChanges []*TempoChange

func (TempoChanges) Len

func (p TempoChanges) Len() int

func (TempoChanges) Less

func (p TempoChanges) Less(a, b int) bool

func (TempoChanges) Swap

func (p TempoChanges) Swap(a, b int)

type TimeSig

type TimeSig struct {
	AbsPos uint64
	Num    uint8
	Denom  uint8
}

type TimeSigs

type TimeSigs []*TimeSig

func (TimeSigs) Len

func (p TimeSigs) Len() int

func (TimeSigs) Less

func (p TimeSigs) Less(a, b int) bool

func (TimeSigs) Swap

func (p TimeSigs) Swap(a, b int)

type Track

type Track struct {
	Song        *Song
	No          uint16
	Channel     int8 // -1 == not defined
	Name        string
	Instrument  string
	Solo        bool
	Mute        bool
	RecordArm   bool
	WithContent bool
	External    bool // for non editable track
}

type TrackMessage

type TrackMessage struct {
	TrackNo  uint16
	AbsPos   uint64
	Message  midi.Message
	Position *Position
}

Directories

Path Synopsis
cmd
smf module
ui module

Jump to

Keyboard shortcuts

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