-
Notifications
You must be signed in to change notification settings - Fork 0
/
notations.go
124 lines (100 loc) · 3.63 KB
/
notations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package mxml
import (
"encoding/xml"
"strings"
)
// Notations is the structure for notations MusicXML element.
type Notations struct {
XMLName xml.Name `xml:"notations"`
IdAttr string `xml:"id,attr,omitempty"`
PrintObjectAttr string `xml:"print-object,attr,omitempty"`
AccidentalMark []AccidentalMark `xml:"accidental-mark,omitempty"`
Arpeggiate []Arpeggiate `xml:"arpeggiate,omitempty"`
Articulations []Articulations `xml:"articulations,omitempty"`
Dynamics []Dynamics `xml:"dynamics,omitempty"`
Fermata []Fermata `xml:"fermata,omitempty"`
Footnote []Footnote `xml:"footnote,omitempty"`
Glissando []Glissando `xml:"glissando,omitempty"`
Level []Level `xml:"level,omitempty"`
NonArpeggiate []NonArpeggiate `xml:"non-arpeggiate,omitempty"`
Ornaments []Ornaments `xml:"ornaments,omitempty"`
OtherNotation []OtherNotation `xml:"other-notation,omitempty"`
Slide []Slide `xml:"slide,omitempty"`
Slur []Slur `xml:"slur,omitempty"`
Technical []Technical `xml:"technical,omitempty"`
Tied []Tied `xml:"tied,omitempty"`
Tuplet []Tuplet `xml:"tuplet,omitempty"`
IValue string `xml:",chardata"`
}
// ToMXML creates a MXML.
func (r *Notations) ToMXML() *MXML {
attributes := make(map[string]string)
children := make(map[string][]*MXML)
attributes["id"] = r.IdAttr
attributes["print-object"] = r.PrintObjectAttr
children["accidental-mark"] = make([]*MXML, len(r.AccidentalMark))
for i, c := range r.AccidentalMark {
children["accidental-mark"][i] = c.ToMXML()
}
children["arpeggiate"] = make([]*MXML, len(r.Arpeggiate))
for i, c := range r.Arpeggiate {
children["arpeggiate"][i] = c.ToMXML()
}
children["articulations"] = make([]*MXML, len(r.Articulations))
for i, c := range r.Articulations {
children["articulations"][i] = c.ToMXML()
}
children["dynamics"] = make([]*MXML, len(r.Dynamics))
for i, c := range r.Dynamics {
children["dynamics"][i] = c.ToMXML()
}
children["fermata"] = make([]*MXML, len(r.Fermata))
for i, c := range r.Fermata {
children["fermata"][i] = c.ToMXML()
}
children["footnote"] = make([]*MXML, len(r.Footnote))
for i, c := range r.Footnote {
children["footnote"][i] = c.ToMXML()
}
children["glissando"] = make([]*MXML, len(r.Glissando))
for i, c := range r.Glissando {
children["glissando"][i] = c.ToMXML()
}
children["level"] = make([]*MXML, len(r.Level))
for i, c := range r.Level {
children["level"][i] = c.ToMXML()
}
children["non-arpeggiate"] = make([]*MXML, len(r.NonArpeggiate))
for i, c := range r.NonArpeggiate {
children["non-arpeggiate"][i] = c.ToMXML()
}
children["ornaments"] = make([]*MXML, len(r.Ornaments))
for i, c := range r.Ornaments {
children["ornaments"][i] = c.ToMXML()
}
children["other-notation"] = make([]*MXML, len(r.OtherNotation))
for i, c := range r.OtherNotation {
children["other-notation"][i] = c.ToMXML()
}
children["slide"] = make([]*MXML, len(r.Slide))
for i, c := range r.Slide {
children["slide"][i] = c.ToMXML()
}
children["slur"] = make([]*MXML, len(r.Slur))
for i, c := range r.Slur {
children["slur"][i] = c.ToMXML()
}
children["technical"] = make([]*MXML, len(r.Technical))
for i, c := range r.Technical {
children["technical"][i] = c.ToMXML()
}
children["tied"] = make([]*MXML, len(r.Tied))
for i, c := range r.Tied {
children["tied"][i] = c.ToMXML()
}
children["tuplet"] = make([]*MXML, len(r.Tuplet))
for i, c := range r.Tuplet {
children["tuplet"][i] = c.ToMXML()
}
return newMXML("notations", strings.TrimSpace(r.IValue), attributes, children)
}