Skip to content

Commit e11d0d8

Browse files
committed
note_graphics for measures
1 parent f245e9e commit e11d0d8

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/types.jl

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,21 @@ notes: See [`Note`](@ref) doc
585585
@aml mutable struct Measure "measure"
586586
attributes::UN{Attributes} = nothing, "~"
587587
notes::Vector{Note}, "note"
588-
@creator begin
589-
notes = note_graphics(notes, attributes)
588+
end
589+
590+
################################################################
591+
"""
592+
Finds and fixes the graphical representation of the notes for the given measures.
593+
"""
594+
function note_graphics(measures::Vector{Measure})
595+
last_attributes = Attributes()
596+
for i = 1:length(measures)
597+
if !isnothing(measures[i].attributes)
598+
last_attributes = measures[i].attributes
599+
end
600+
measures[i].notes = note_graphics(measures[i].notes, last_attributes)
590601
end
602+
return measures
591603
end
592604

593605
"""
@@ -607,7 +619,7 @@ Note(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 4),
607619
MusicXML.note_graphics(notes, Attributes())
608620
```
609621
"""
610-
function note_graphics(notes, attributes)
622+
function note_graphics(notes::Vector{Note}, attributes::Attributes)
611623
for inote=1:length(notes)
612624
actual_duration = notes[inote].duration//attributes.divisions
613625
type = note_graphics_map[actual_duration]
@@ -632,8 +644,6 @@ const note_graphics_map = Dict(
632644
# "long"
633645
# "maxima"
634646
)
635-
636-
637647
################################################################
638648
"""
639649
Part
@@ -651,8 +661,12 @@ measures: See [`Measure`](@ref) doc
651661
"""
652662
@aml mutable struct Part "part"
653663
id::String = "P1", att"~"
664+
@creator begin
665+
measures = note_graphics(measures)
666+
end
654667
measures::Vector{Measure}, "measure"
655668
end
669+
656670
################################################################
657671
"""
658672
ScorePartwise

0 commit comments

Comments
 (0)