mscx

package
v0.0.0-...-16c129e Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package mscx parses MuseScore 3 `*.mscx` or `*.mscz` files into Go structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArticulationElement

type ArticulationElement struct {
	Name string `xml:"name,attr,omitempty"`

	Velocity string `xml:"velocity"`
	GateTime string `xml:"gateTime"`
}

ArticulationElement represents the XML data of the same name.

type BarLine

type BarLine struct {
	Subtype string `xml:"subtype"`
}

type BarLineSpan

type BarLineSpan int

func (BarLineSpan) MarshalXML

func (b BarLineSpan) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

type Bracket

type Bracket struct {
	Type int    `xml:"type,attr"`
	Span int    `xml:"span,attr"`
	Col  string `xml:"col,attr,omitempty"`
}

Bracket represents the XML data of the same name.

func (*Bracket) MarshalXML

func (b *Bracket) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

type CallbackFn

type CallbackFn func(filename string, content []byte)

CallbackFn is an optional function that will be called with each file entry found in the ZIP.

type Channel

type Channel struct {
	Name string `xml:"name,attr"`

	ChannelElements []any
	// Controller []*Controller `xml:"controller"`
	// Program    Program       `xml:"program"`
	Synti string `xml:"synti"`
	Mute  int    `xml:"mute,omitempty"`
}

Channel represents the XML data of the same name.

func (*Channel) MarshalXML

func (c *Channel) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

func (*Channel) UnmarshalXML

func (c *Channel) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

Implements encoding.xml.Unmarshaler interface

type Chord

type Chord struct {
	Dots         int        `xml:"dots,omitempty"`
	DurationType string     `xml:"durationType"`
	Lyrics       []*Lyrics  `xml:"Lyrics"`
	Spanner      []*Spanner `xml:"Spanner"`
	Note         []*Note    `xml:"Note"`
}

type Clef

type Clef struct {
	Staff string `xml:"staff,attr,omitempty"`

	ConcertClefType     string `xml:"concertClefType,omitempty"`
	TransposingClefType string `xml:"transposingClefType,omitempty"`

	Text string `xml:",chardata"`
}

Clef represents the XML data of the same name.

type Controller

type Controller struct {
	Ctrl  int `xml:"ctrl,attr"`
	Value int `xml:"value,attr"`
}

func (*Controller) MarshalXML

func (c *Controller) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

type DefaultClef

type DefaultClef struct {
	Type  string // One of: "", "Concert", "Transposing"
	Value string `xml:",chardata"`
}

func (*DefaultClef) MarshalXML

func (d *DefaultClef) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

type DistOffset

type DistOffset float64

func (DistOffset) MarshalXML

func (d DistOffset) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

type Drum

type Drum struct {
	Pitch int `xml:"pitch,attr"`

	Head     int    `xml:"head"`
	Line     int    `xml:"line"`
	Voice    int    `xml:"voice"`
	Name     string `xml:"name"`
	Stem     int    `xml:"stem"`
	Shortcut string `xml:"shortcut,omitempty"`
}

type Dynamic

type Dynamic struct {
	Subtype  string `xml:"subtype"`
	Velocity int    `xml:"velocity,omitempty"`
}

type EndSpanner

type EndSpanner struct {
	ID int `xml:"id,attr"`
}

type HairPin

type HairPin struct {
	ID int `xml:"id,attr"`

	Subtype      string       `xml:"subtype"`
	VeloChange   int          `xml:"veloChange,omitempty"`
	Segment      *Segment     `xml:"Segment"`
	BeginText    *TextElement `xml:"beginText"`
	ContinueText *TextElement `xml:"continueText"`
}

type ImageElement

type ImageElement struct {
	Pos      *TextPos  `xml:"pos"`
	Path     string    `xml:"path"`
	LinkPath string    `xml:"linkPath"`
	Size     ImageSize `xml:"size"`
}

type ImageSize

type ImageSize struct {
	W float64 `xml:"w,attr"`
	H float64 `xml:"h,attr"`
}

type Instrument

type Instrument struct {
	LongName           string `xml:"longName,omitempty"`
	ShortName          string `xml:"shortName,omitempty"`
	TrackName          string `xml:"trackName"`
	MinPitchP          string `xml:"minPitchP,omitempty"`
	MaxPitchP          string `xml:"maxPitchP,omitempty"`
	MinPitchA          string `xml:"minPitchA,omitempty"`
	MaxPitchA          string `xml:"maxPitchA,omitempty"`
	TransposeDiatonic  string `xml:"transposeDiatonic,omitempty"`
	TransposeChromatic string `xml:"transposeChromatic,omitempty"`
	InstrumentID       string `xml:"instrumentId"`

	UseDrumset int     `xml:"useDrumset,omitempty"`
	Drum       []*Drum `xml:"Drum"`

	Clef *Clef `xml:"clef"`

	StringData *StringData `xml:"StringData"`

	Articulation []*ArticulationElement `xml:"Articulation"`
	Channel      []*Channel             `xml:"Channel"`
}

Instrument represents the XML data of the same name.

type KeySig

type KeySig struct {
	Accidental string `xml:"accidental"`
}

type LayerTag

type LayerTag struct {
	ID  string `xml:"id,attr"`
	Tag string `xml:"tag,attr"`
}

LayerTag represents the XML data of the same name.

type LayoutBreak

type LayoutBreak struct {
	Subtype string `xml:"subtype"`
}

type Location

type Location struct {
	Fractions string `xml:"fractions"`
}

type Lyrics

type Lyrics struct {
	No       int    `xml:"no,omitempty"`
	Syllabic string `xml:"syllabic,omitempty"`
	TicksF   string `xml:"ticks_f,omitempty"`
	Text     string `xml:"text,omitempty"`
}

type Measure

type Measure struct {
	Len    string `xml:"len,attr,omitempty"`
	Number int    `xml:"number,attr,omitempty"`

	Irregular   int      `xml:"irregular,omitempty"`
	Voice       []*Voice `xml:"voice"`
	StartRepeat string   `xml:"startRepeat,omitempty"`
	EndRepeat   string   `xml:"endRepeat,omitempty"`

	// older versions
	KeySig        *KeySig  `xml:"KeySig"`
	TimeSig       *TimeSig `xml:"TimeSig"`
	Tempo         *Tempo   `xml:"Tempo"`
	TimedElements []any
}

Measure represents the XML data of the same name.

func (*Measure) MarshalXML

func (m *Measure) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

Implements encoding.xml.Marshaler interface

func (*Measure) UnmarshalXML

func (m *Measure) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

Implements encoding.xml.Unmarshaler interface

type MetaTag

type MetaTag struct {
	Name string `xml:"name,attr"`

	Text string `xml:",chardata"`
}

MetaTag represents the XML data of the same name.

type MuseScore

type MuseScore struct {
	Version string `xml:"version,attr"`

	ProgramVersion  string `xml:"programVersion"`
	ProgramRevision string `xml:"programRevision"`
	Score           Score  `xml:"Score"`
}

MuseScore represents MuseScore 3 data in XML.

type NextPrev

type NextPrev struct {
	Location *Location `xml:"location"`
}

type Note

type Note struct {
	Pitch int `xml:"pitch"`
	TPC   int `xml:"tpc"`
}

type Page

type Page struct {
	System System `xml:"System"`
}

type PageLayout

type PageLayout struct {
	PageHeight  float64        `xml:"page-height"`
	PageWidth   float64        `xml:"page-width"`
	PageMargins []*PageMargins `xml:"page-margins"`
}

type PageList

type PageList struct {
	Page []*Page `xml:"Page"`
}

type PageMargins

type PageMargins struct {
	Type string `xml:"type,attr"`

	LeftMargin   float64 `xml:"left-margin"`
	RightMargin  float64 `xml:"right-margin"`
	TopMargin    float64 `xml:"top-margin"`
	BottomMargin float64 `xml:"bottom-margin"`
}

type Part

type Part struct {
	Staff      []*PartStaff `xml:"Staff"`
	Show       string       `xml:"show,omitempty"`
	TrackName  string       `xml:"trackName"`
	Instrument *Instrument  `xml:"Instrument"`
}

Part represents the XML data of the same name.

type PartStaff

type PartStaff struct {
	ID string `xml:"id,attr"`

	StaffType     StaffType `xml:"StaffType"`
	StaffElements []any
}

PartStaff represents the XML data of the same name.

func (*PartStaff) MarshalXML

func (p *PartStaff) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

func (*PartStaff) UnmarshalXML

func (p *PartStaff) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

Implements encoding.xml.Unmarshaler interface

type Program

type Program struct {
	Value string `xml:"value,attr"`
}

Program represents the XML data of the same name.

func (Program) MarshalXML

func (p Program) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

type Rest

type Rest struct {
	DurationType string `xml:"durationType"`
}

type Score

type Score struct {
	LayerTag        LayerTag      `xml:"LayerTag"`
	CurrentLayer    int           `xml:"currentLayer"`
	Synthesizer     *Synthesizer  `xml:"Synthesizer"`
	Division        int           `xml:"Division"`
	Style           *Style        `xml:"Style"`
	ShowInvisible   int           `xml:"showInvisible"`
	ShowUnprintable int           `xml:"showUnprintable"`
	ShowFrames      int           `xml:"showFrames"`
	ShowMargins     int           `xml:"showMargins"`
	MetaTags        []*MetaTag    `xml:"metaTag"`
	PageList        *PageList     `xml:"PageList"`
	Part            []*Part       `xml:"Part"`
	Staffs          []*ScoreStaff `xml:"Staff"`
}

Score represents the XML data of the same name.

type ScoreStaff

type ScoreStaff struct {
	ID string `xml:"id,attr"`

	VBox    *VBox      `xml:"VBox"`
	Measure []*Measure `xml:"Measure"`
}

ScoreStaff represents the XML data of the same name.

type ScoreZip

type ScoreZip struct {
	// MetaInf
	MuseScore MuseScore `xml:"museScore"`
}

ScoreZip represents a MuseScore 3 score in `mscz` (zip'd) format.

func New

func New(buf []byte, callback CallbackFn) (*ScoreZip, error)

New reads `mscx` or `mscz` data and returns the resulting parsed score.

func NewFromFile

func NewFromFile(filename string, callback CallbackFn) (*ScoreZip, error)

NewFromFile reads a `*.mscx` or `*.mscz` file and returns the resulting parsed score.

func (*ScoreZip) XML

func (s *ScoreZip) XML() ([]byte, error)

XML renders the embedded MuseScore to XML format.

type Segment

type Segment struct {
	Subtype string   `xml:"subtype"`
	Off2    *TextPos `xml:"off2"`
	Visible int      `xml:"visible"`
}

type Slur

type Slur struct {
	Up string `xml:"up,omitempty"`
}

type Spanner

type Spanner struct {
	Type string `xml:"type,attr"`

	Slur *Slur     `xml:"Slur"`
	Next *NextPrev `xml:"next"`
	Prev *NextPrev `xml:"prev"`
}

type StaffSmall

type StaffSmall int

func (StaffSmall) MarshalXML

func (s StaffSmall) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

type StaffText

type StaffText struct {
	Pos   *TextPos `xml:"pos"`
	Style string   `xml:"style,omitempty"`
	Text  []byte   `xml:"text"`
}

type StaffType

type StaffType struct {
	Group string `xml:"group,attr"`

	Name   string `xml:"name"`
	Lines  int    `xml:"lines,omitempty"`
	KeySig *int   `xml:"keysig,omitempty"`
}

StaffType represents the XML data of the same name.

type StringData

type StringData struct {
	Frets  int   `xml:"frets"`
	String []int `xml:"string"`
}

type Style

type Style struct {
	ConcertPitch         int         `xml:"concertPitch,omitempty"`
	PageLayout           *PageLayout `xml:"page-layout"`
	PageWidth            float64     `xml:"pageWidth,omitempty"`
	PageHeight           float64     `xml:"pageHeight,omitempty"`
	PagePrintableWidth   float64     `xml:"pagePrintableWidth,omitempty"`
	UseStandardNoteNames int         `xml:"useStandardNoteNames,omitempty"`
	Spatium              float64     `xml:"Spatium"`
}

Style represents the XML data of the same name.

type StyleEnum

type StyleEnum string
const (
	Composer StyleEnum = "Composer"
	Subtitle StyleEnum = "Subtitle"
	Title    StyleEnum = "Title"
	Tuplet   StyleEnum = "Tuplet"
)

type SynthVals

type SynthVals struct {
	Val []*Val `xml:"val"`
}

type Synthesizer

type Synthesizer struct {
	Master   *SynthVals `xml:"master"`
	Fluid    *SynthVals `xml:"Fluid"`
	Zerberus *SynthVals `xml:"Zerberus"`
	Zita1    *SynthVals `xml:"Zita1"`
}

type System

type System struct {
}

type Tempo

type Tempo struct {
	Tempo      float64  `xml:"tempo"`
	FollowText int      `xml:"followText,omitempty"`
	Pos        *TextPos `xml:"pos"`
	Visible    int      `xml:"visible"`
	Text       []byte   `xml:"text"`
}

type TextElement

type TextElement struct {
	Pos   *TextPos  `xml:"pos"`
	Style StyleEnum `xml:"style,omitempty"`
	Text  []byte    `xml:"text"`
}

type TextPos

type TextPos struct {
	X float64 `xml:"x,attr"`
	Y float64 `xml:"y,attr"`
}

type Tick

type Tick int64

type TimeSig

type TimeSig struct {
	SigN            string `xml:"sigN"`
	SigD            string `xml:"sigD"`
	ShowCourtesySig int    `xml:"showCourtesySig,omitempty"`
}

type UnhandledError

type UnhandledError struct {
	Type   string
	Name   string
	Offset int64
}

func (*UnhandledError) Error

func (u *UnhandledError) Error() string

type VBox

type VBox struct {
	Height string         `xml:"height"`
	Text   []TextElement  `xml:"Text"`
	Image  []ImageElement `xml:"Image"`
}

type Val

type Val struct {
	ID int `xml:"id,attr"`

	Text string `xml:",chardata"`
}

type Voice

type Voice struct {
	KeySig        *KeySig  `xml:"KeySig"`
	TimeSig       *TimeSig `xml:"TimeSig"`
	TimedElements []any
}

func (*Voice) MarshalXML

func (v *Voice) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error

Implements encoding.xml.Marshaler interface

func (*Voice) UnmarshalXML

func (v *Voice) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

Implements encoding.xml.Unmarshaler interface

Jump to

Keyboard shortcuts

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