Skip to content

Commit a452d49

Browse files
committed
feat(fermata): add fermata support
1 parent 209489f commit a452d49

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

internal/entity/renderer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ type NoteRenderer struct {
6262
Tie *Slur
6363
Articulation *Articulation
6464
Barline *musicxml.Barline
65+
Fermata *musicxml.Femata
6566
// internal use
6667
IsLengthTakenFromLyric bool
6768
IndexPosition int

internal/musicxml/entity.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,22 @@ type Tuplet struct {
336336
Braket Bool `xml:"braket,attr"`
337337
}
338338

339+
type FemataType string
340+
341+
const (
342+
FermataTypeUpright FemataType = "upright"
343+
FermataTypeInverted FemataType = "inverted"
344+
)
345+
346+
type Femata struct {
347+
Type FemataType `xml:"type,attr"`
348+
}
349+
339350
type NoteNotation struct {
340351
Slur []NotationSlur `xml:"slur" json:",omitempty"`
341352
Tied *Tie `xml:"tied" json:",omitempty"`
342353
Articulation *NotationArticulation `xml:"articulations" json:",omitempty"`
354+
Fermata *Femata `xml:"fermata"`
343355

344356
// TODO: stacking tuplets / tuplet inside the tuplet
345357
Tuplet *Tuplet `xml:"tuplet"`

internal/staff/align.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,18 @@ func (rsa *renderStaffAlign) RenderWithAlign(ctx context.Context, canv canvas.Ca
182182
if n.Strikethrough {
183183
canv.Line(n.PositionX+10, y-16, n.PositionX, y+5, "fill:none;stroke:#000000;stroke-linecap:round;stroke-width:1.45")
184184
}
185+
186+
if n.Fermata != nil {
187+
fermataUnicode := `𝄐`
188+
posX := float64(n.PositionX) - (rsa.Lyric.CalculateLyricWidth(fmt.Sprintf("%d", n.Note)) / 2)
189+
190+
fmt.Fprintf(
191+
canv.Writer(),
192+
`<text x="%.3f" y="%.3f" style="font-family:Noto Music;font-size:200%%"> %s </text>`,
193+
posX, float64(y)-17.5, fermataUnicode,
194+
)
195+
}
196+
185197
}
186198
fmt.Fprintf(canv.Writer(), `<title>Width: %d</title>`, n.Width)
187199
canv.Gend()

internal/staff/staff.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ func (si *staffInteractor) RenderStaff(ctx context.Context, canv canvas.Canvas,
115115
TimeModifications: note.TimeModification,
116116
}
117117

118+
if note.Notations != nil && note.Notations.Fermata != nil {
119+
renderer.Fermata = note.Notations.Fermata
120+
}
121+
118122
staffInfo.Multiline = staffInfo.Multiline || renderer.IsNewLine
119123

120124
// text above the measure

0 commit comments

Comments
 (0)