Skip to content

Commit ec71b00

Browse files
committed
Adding MusicXML tests
1 parent 563b3cf commit ec71b00

File tree

7 files changed

+1499
-1
lines changed

7 files changed

+1499
-1
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
2121
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
2222
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
2323
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
24+
MusicXML = "521615e9-e573-4eb2-bc7e-702d55c0bb95"
2425
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2526

2627
[targets]
27-
test = ["Test", "Suppressor", "DataFrames", "Dates", "EzXML"]
28+
test = ["Test", "Suppressor", "DataFrames", "Dates", "EzXML", "MusicXML"]

test/Test.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
33
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
44
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
55
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
6+
MusicXML = "521615e9-e573-4eb2-bc7e-702d55c0bb95"
67
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

test/musicxml/creating.jl

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
using MusicXML
2+
3+
## Part List
4+
### Piano
5+
midiinstrument_piano = MidiInstrument(channel= 1, program =1, volume = 100, pan =0, id = "P1-I1")
6+
scorepart_piano = ScorePart(name = "Piano", midiinstrument = midiinstrument_piano, id = "P1")
7+
8+
### Acoustic Guitar
9+
midiinstrument_guitar = MidiInstrument(channel= 1, program =26, volume = 100, pan =0, id = "P2-I1")
10+
scorepart_guitar = ScorePart(name = "Acoustic Guitar", midiinstrument = midiinstrument_guitar, id = "P2")
11+
12+
###
13+
partlist = PartList(scoreparts = [scorepart_piano, scorepart_guitar])
14+
15+
## Part
16+
### Piano
17+
18+
attributes1_piano = Attributes(
19+
time = Time(beats = 4, beattype = 4), # 4/4
20+
divisions = 4, # we want to use 16th notes at minimum
21+
clef = [Clef(number = 1, sign = "G", line = 2), Clef(number = 2, sign = "F", line = 4)], # Piano clefs
22+
staves = 2, # Piano staves
23+
key = Key(fifths = 0, mode = "major"), # no accidentals, major key
24+
)
25+
26+
measure1_notes_piano = [
27+
NoteX(pitch = Pitch(step = "C", alter = 0, octave = 4), duration = 4),
28+
NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 4),
29+
NoteX(pitch = Pitch(step = "E", alter = 0, octave = 4), duration = 4),
30+
NoteX(pitch = Pitch(step = "F", alter = +1, octave = 4), duration = 4),
31+
]
32+
33+
measure2_notes_piano = [
34+
NoteX(pitch = Pitch(step = "G", alter = 0, octave = 5), duration = 1),
35+
NoteX(pitch = Pitch(step = "G", alter = +1, octave = 5), duration = 1),
36+
NoteX(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 1),
37+
NoteX(pitch = Pitch(step = "A", alter = +1, octave = 5), duration = 1),
38+
NoteX(rest = Rest(), duration = 4), # Rest
39+
NoteX(pitch = Pitch(step = "A", alter = 0, octave = 5), duration = 4),
40+
NoteX(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 4),
41+
]
42+
43+
measures_piano = [
44+
Measure(attributes = attributes1_piano, notes = measure1_notes_piano) # measure 1 has attributes
45+
Measure(notes = measure2_notes_piano)
46+
]
47+
48+
49+
part_piano = Part(measures = measures_piano, id = "P1")
50+
51+
52+
### Guitar
53+
54+
attributes1_guitar = Attributes(
55+
time = Time(beats = 4, beattype = 4), # 4/4
56+
divisions = 4, # we want to use 16th notes at minimum
57+
clef = [Clef(number = 1, sign = "G", line = 2), Clef(number = 2, sign = "TAB", line = 6)], # Guitar Clefs
58+
staves = 2, # Guitar staves
59+
key = Key(fifths = 0, mode = "major"), # no accidentals, major key
60+
)
61+
62+
measure1_notes_guitar = [
63+
# G Major chord for a bar
64+
NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 16, chord = Chord()),
65+
NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 16, chord = Chord()),
66+
NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 16, chord = Chord()),
67+
NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 16, chord = Chord()),
68+
NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 16, chord = Chord()),
69+
NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 16, chord = Chord()),
70+
]
71+
72+
measure2_notes_guitar = [
73+
# G Major chord for half a bar
74+
NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()),
75+
NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()),
76+
NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()),
77+
NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()),
78+
NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()),
79+
NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()),
80+
81+
# G Major chord for half a bar
82+
NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()),
83+
NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()),
84+
NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()),
85+
NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()),
86+
NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()),
87+
NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()),
88+
]
89+
90+
measures_guitar = [
91+
Measure(attributes = attributes1_guitar, notes = measure1_notes_guitar) # measure 1 has attributes
92+
Measure(notes = measure2_notes_guitar)
93+
]
94+
95+
96+
part_guitar = Part(measures = measures_guitar, id = "P2")
97+
98+
##
99+
score = ScorePartwise(
100+
partlist = partlist,
101+
parts = [part_piano, part_guitar],
102+
)
103+
104+
105+
writemusicxml("myscore.musicxml", score)

0 commit comments

Comments
 (0)