ast

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must[T any](result T, err error) T

Must returns the result or panics if err is not nil.

func WalkNotes added in v0.8.4

func WalkNotes(node Node, props PropertyList, f func(*Note) error) error

WalkNotes flattens notes, groups and properties and calls f for every new note.

Types

type Bar

type Bar struct {
	Pos      token.Pos
	Name     string
	DeclList NodeList
}

Bar is a bar.

func NewBar

func NewBar(pos token.Pos, name string, declList NodeList) Bar

NewBar creates a new bar.

func (Bar) WriteTo

func (b Bar) WriteTo(w io.Writer) (int64, error)

type BlockComment added in v0.8.4

type BlockComment struct {
	Text string
}

BlockComment is a block comment.

func NewBlockComment added in v0.8.4

func NewBlockComment(text string) BlockComment

NewBlockComment creates a new block comment.

func (BlockComment) WriteTo added in v0.8.4

func (c BlockComment) WriteTo(w io.Writer) (int64, error)

type CmdAssign

type CmdAssign struct {
	Pos  token.Pos
	Note rune
	Key  int
}

CmdAssign is a note assignment command.

func NewCmdAssign

func NewCmdAssign(pos token.Pos, note rune, key int64) (CmdAssign, error)

NewCmdAssign creates a note assignment command.

func (CmdAssign) WriteTo

func (c CmdAssign) WriteTo(w io.Writer) (int64, error)

type CmdChannel

type CmdChannel struct {
	Channel uint8
}

CmdChannel is a channel change command.

func NewCmdChannel

func NewCmdChannel(value int64) (CmdChannel, error)

NewCmdChannel creates a channel change command.

func (CmdChannel) WriteTo

func (c CmdChannel) WriteTo(w io.Writer) (int64, error)

type CmdControl

type CmdControl struct {
	Control   uint8
	Parameter uint8
}

CmdControl is a control change command.

func NewCmdControl

func NewCmdControl(control, value int64) (CmdControl, error)

NewCmdControl creates a control change command.

func (CmdControl) WriteTo

func (c CmdControl) WriteTo(w io.Writer) (int64, error)

type CmdPlay

type CmdPlay struct {
	Pos     token.Pos
	BarName string
}

CmdPlay is a bar play command.

func NewCmdPlay

func NewCmdPlay(pos token.Pos, barName string) (CmdPlay, error)

func (CmdPlay) WriteTo

func (c CmdPlay) WriteTo(w io.Writer) (int64, error)

type CmdProgram

type CmdProgram struct {
	Program uint8
}

CmdProgram is a program change command.

func NewCmdProgram

func NewCmdProgram(value int64) (CmdProgram, error)

NewCmdProgram creates a program change command.

func (CmdProgram) WriteTo

func (c CmdProgram) WriteTo(w io.Writer) (int64, error)

type CmdStart

type CmdStart struct{}

CmdStart is a start commad.

func (CmdStart) WriteTo

func (c CmdStart) WriteTo(w io.Writer) (int64, error)

type CmdStop

type CmdStop struct{}

CmdStop is a stop command.

func (CmdStop) WriteTo

func (c CmdStop) WriteTo(w io.Writer) (int64, error)

type CmdTempo

type CmdTempo struct {
	BPM uint16
}

CmdTempo is a tempo command.

func NewCmdTempo

func NewCmdTempo(bpm int64) (CmdTempo, error)

NewCmdTempo creates a tempo command.

func (CmdTempo) Value

func (c CmdTempo) Value() float64

Value returns the tempo value.

func (CmdTempo) WriteTo

func (c CmdTempo) WriteTo(w io.Writer) (int64, error)

type CmdTimeSig

type CmdTimeSig struct {
	Num   uint8
	Denom uint8
}

CmdTimeSig is a time signature change command.

func NewCmdTimeSig

func NewCmdTimeSig(num, denom int64) (CmdTimeSig, error)

NewCmdTimeSig creates a time signature change command.

func (CmdTimeSig) WriteTo

func (c CmdTimeSig) WriteTo(w io.Writer) (int64, error)

type CmdVelocity

type CmdVelocity struct {
	Velocity int
}

CmdVelocity is a velocity change command.

func NewCmdVelocity

func NewCmdVelocity(value int64) (CmdVelocity, error)

NewCmdVelocity creates a velocity change command.

func (CmdVelocity) WriteTo

func (c CmdVelocity) WriteTo(w io.Writer) (int64, error)

type Node

type Node interface {
	io.WriterTo
}

type NodeList

type NodeList []Node

func NewNodeList

func NewNodeList(stmt Node, inner ...Node) (list NodeList)

func (NodeList) WriteTo

func (list NodeList) WriteTo(w io.Writer) (n int64, err error)

type Note

type Note struct {
	Pos   token.Pos
	Props PropertyList
	Name  rune
}

Note is a single note.

func NewNote

func NewNote(pos token.Pos, name rune, propList PropertyList) *Note

NewNote creates a note with properties.

func (*Note) IsPause

func (note *Note) IsPause() bool

IsPause reports whether the note is a pause.

func (*Note) WriteTo

func (note *Note) WriteTo(w io.Writer) (int64, error)

type NoteGroup added in v0.8.4

type NoteGroup struct {
	Nodes NodeList
	Props PropertyList
}

NoteGroup is a group of notes with shared properties.

func NewNoteGroup added in v0.8.4

func NewNoteGroup(notes NodeList, props PropertyList) (NoteGroup, error)

NewNoteGroup creates a note group from a list of notes with shared properties.

func (NoteGroup) WriteTo added in v0.8.4

func (g NoteGroup) WriteTo(w io.Writer) (int64, error)

type PropertyList

type PropertyList []*token.Token

PropertyList is a list of note properties.

func NewPropertyList

func NewPropertyList(t *token.Token, inner interface{}) (PropertyList, error)

NewPropertyList creates a note property list.

func (PropertyList) IsLetRing added in v0.8.4

func (l PropertyList) IsLetRing() bool

IsLetRing reports whether the note must ring.

func (PropertyList) Len

func (p PropertyList) Len() int

func (PropertyList) Less

func (p PropertyList) Less(i, j int) bool

func (PropertyList) Merge added in v0.8.4

func (p PropertyList) Merge(list PropertyList) PropertyList

Merge merges list into a copy of p and returns the merged result. Unique properties are overwritten while additive properties are added.

func (PropertyList) NoteLen added in v0.8.4

func (l PropertyList) NoteLen() uint32

NoteLen returns the note duration in ticks.

func (PropertyList) NumAccent added in v0.8.4

func (l PropertyList) NumAccent() int

NumAccent reports the number of accent properties.

func (PropertyList) NumDot added in v0.8.4

func (l PropertyList) NumDot() int

NumDot reports the number of dot properties.

func (PropertyList) NumFlat added in v0.8.4

func (l PropertyList) NumFlat() int

NumFlat reports the number of flat signs.

func (PropertyList) NumGhost added in v0.8.4

func (l PropertyList) NumGhost() int

NumGhost reports the number of ghost properties.

func (PropertyList) NumMarcato added in v0.8.4

func (l PropertyList) NumMarcato() int

NumMarcato reports the number of marcato properties.

func (PropertyList) NumSharp added in v0.8.4

func (l PropertyList) NumSharp() int

NumSharp returns the number of sharp signs.

func (PropertyList) NumStaccato added in v0.8.4

func (l PropertyList) NumStaccato() int

NumStaccato reports the number of staccato properties.

func (PropertyList) Swap

func (p PropertyList) Swap(i, j int)

func (PropertyList) Tuplet added in v0.8.4

func (l PropertyList) Tuplet() int

Tuplet returns the irregular division value if the note is a tuplet.

func (PropertyList) Value added in v0.8.4

func (l PropertyList) Value() uint8

Value returns the note value (1th, 2th, 4th, 8th, 16th, 32th and so on).

func (PropertyList) WriteTo

func (p PropertyList) WriteTo(w io.Writer) (int64, error)

type SourceFile

type SourceFile struct{}

func NewSourceFile

func NewSourceFile(declList interface{}) SourceFile

Jump to

Keyboard shortcuts

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