Skip to content

Commit 68882ff

Browse files
committed
run musicxml tests
1 parent 14a924a commit 68882ff

File tree

6 files changed

+44
-9
lines changed

6 files changed

+44
-9
lines changed

test/musicxml/creating.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using MusicXML
22

33
@MX begin
4-
54
## Part List
65
### Piano
76
midiinstrument_piano = MidiInstrument(channel= 1, program =1, volume = 100, pan =0, id = "P1-I1")
@@ -44,10 +43,9 @@ Note(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 4),
4443

4544
measures_piano = [
4645
Measure(attributes = attributes1_piano, notes = measure1_notes_piano) # measure 1 has attributes
47-
Measure(notes = measure2_notes_piano)
46+
# Measure(notes = measure2_notes_piano)
4847
]
4948

50-
5149
part_piano = Part(measures = measures_piano, id = "P1")
5250

5351

@@ -63,7 +61,7 @@ attributes1_guitar = Attributes(
6361

6462
measure1_notes_guitar = [
6563
# G Major chord for a bar
66-
Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 16, chord = Chord()),
64+
Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 16),
6765
Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 16, chord = Chord()),
6866
Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 16, chord = Chord()),
6967
Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 16, chord = Chord()),
@@ -73,15 +71,15 @@ Note(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 16, chord = C
7371

7472
measure2_notes_guitar = [
7573
# G Major chord for half a bar
76-
Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()),
74+
Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8),
7775
Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()),
7876
Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()),
7977
Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()),
8078
Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()),
8179
Note(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()),
8280

8381
# G Major chord for half a bar
84-
Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()),
82+
Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8),
8583
Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()),
8684
Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()),
8785
Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()),
@@ -103,6 +101,7 @@ partlist = partlist,
103101
parts = [part_piano, part_guitar],
104102
)
105103

106-
end # @MX
107-
108104
writemusicxml("myscore.musicxml", score)
105+
106+
107+
end

test/musicxml/grace.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# https://github.com/JuliaMusic/MusicXML.jl/issues/46
2+
using MusicXML
3+
4+
xml_note = parsemusicxml_partial("""
5+
<note>
6+
<grace/>
7+
<pitch>
8+
<step>G</step>
9+
<octave>4</octave>
10+
</pitch>
11+
<voice>1</voice>
12+
<type>16th</type>
13+
<stem>up</stem>
14+
<beam number="1">end</beam>
15+
<beam number="2">end</beam>
16+
</note>
17+
""")
18+
19+
MX.Note(xml_note)

test/musicxml/musicxml.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using MusicXML
2+
using Test
23

34
cd(@__DIR__)
45

@@ -13,3 +14,7 @@ end
1314
include("creating.jl")
1415
@test isfile("myscore.musicxml")
1516
end
17+
18+
@testset "grace note" begin
19+
include("grace.jl")
20+
end

test/musicxml/parsing.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using MusicXML
22
cd(@__DIR__)
3+
@MX begin
34
# Reads musicxml file and then extracts the data, builds all the types and stores them in proper format.
45
scorepartwise = readmusicxml( "musescore.musicxml")
56

@@ -15,7 +16,7 @@ parts = scorepartwise.parts
1516
# Extracting each part
1617
for part in parts
1718

18-
ind = findfirst(x -> part.id == x.id, scoreparts) # returns the index of scorepart that matches the id of part
19+
ind = Base.findfirst(x -> part.id == x.id, scoreparts) # returns the index of scorepart that matches the id of part
1920

2021
# printing the instrument name
2122
println(scoreparts[ind].name)
@@ -41,3 +42,5 @@ for part in parts
4142
iMsr+=1
4243
end
4344
end
45+
46+
end

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ end
2222
end
2323

2424
include("errors.jl")
25+
26+
27+
include("musicxml/musicxml.jl")

test/struct_empty.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@aml mutable struct NoAMLFields empty""
2+
fields
3+
end
4+
5+
@aml struct rest empty"~"
6+
end

0 commit comments

Comments
 (0)