Skip to content

Commit 2823207

Browse files
authored
Merge pull request #110 from aminya/removemissing
Removemissing
2 parents bff35a0 + ec71b00 commit 2823207

File tree

8 files changed

+1524
-26
lines changed

8 files changed

+1524
-26
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"]

src/@aml/@aml_parse.jl

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ function aml_parse(expr::Expr)
2424

2525
args_param = Vector{Union{Expr,Symbol}}(undef, argsnum) # Expr(:parameters)[]
2626
args_var = Vector{Union{Expr,Symbol}}(undef, argsnum)
27-
args_defaultvalue = Vector{Any}(undef, argsnum)
28-
args_type = Vector{Union{Missing,Type, Symbol, Expr}}(undef, argsnum)
29-
args_name =Vector{Union{Missing,String}}(undef, argsnum)
30-
args_function = Vector{Union{Missing, Symbol, Function}}(undef, argsnum)
31-
args_literaltype = Type[]
27+
args_defaultvalue = Vector{Any}(missing, argsnum)
28+
args_type = Vector{Union{Type, Symbol, Expr}}(undef, argsnum)
29+
args_name =Vector{Union{Missing,String}}(missing, argsnum)
30+
args_function = Vector{Union{Missing, Symbol, Function}}(missing, argsnum)
31+
args_literaltype = Vector{Union{Missing, Type}}(missing, argsnum)
3232
struct_name = "name"
3333
struct_nodetype = AbsDocOrNode
34-
struct_function = Array{Union{Missing, Symbol, Function},0}(undef)
34+
struct_function = Array{Union{Missing, Symbol, Function},0}(missing)
3535

3636
for iData = 1:datanum # iterating over arguments of each type argument
3737

@@ -44,7 +44,7 @@ function aml_parse(expr::Expr)
4444
# Single struct name - "aml name"
4545
if isa(ei, String)
4646

47-
struct_function[1]=missing # function
47+
# struct_function[1]=missing # function
4848

4949
# Self-name checker
5050
if ei == "~"
@@ -69,7 +69,7 @@ function aml_parse(expr::Expr)
6969
# Literal only empty"aml name"
7070
if isa(ei, Tuple{Type,String})
7171

72-
struct_function[1]=missing # function
72+
# struct_function[1]=missing # function
7373

7474
# Self-name checker
7575
if ei[2] == "~"
@@ -137,7 +137,7 @@ function aml_parse(expr::Expr)
137137
elseif ei.args[1] isa Union{Symbol,Expr} # var/var::T, "name"
138138

139139
# Def Value
140-
args_defaultvalue[iArg] = missing
140+
# args_defaultvalue[iArg] = missing
141141

142142
# Type Checker
143143
lhs = ei.args[1]
@@ -168,7 +168,7 @@ function aml_parse(expr::Expr)
168168
if length(ei.args[2]) == 2 # literal
169169

170170
argAmlType = ei.args[2][1]
171-
push!(args_literaltype, argAmlType) # literal type
171+
args_literaltype[iArg] = argAmlType # literal type
172172

173173
ni = ei.args[2][2]
174174

@@ -180,7 +180,7 @@ function aml_parse(expr::Expr)
180180
end
181181

182182
else
183-
push!(args_literaltype, AbsNormal) # non-literal
183+
args_literaltype[iArg] = AbsNormal # non-literal
184184

185185
ni = ei.args[2]
186186

@@ -198,8 +198,8 @@ function aml_parse(expr::Expr)
198198
fun = ei.args[3] # function
199199
args_function[iArg] = fun
200200

201-
else # function name isn't given
202-
args_function[iArg] = missing
201+
# else # function name isn't given
202+
# args_function[iArg] = missing
203203
end
204204

205205

@@ -249,7 +249,7 @@ function aml_parse(expr::Expr)
249249
if length(ei.args[2].args[2]) == 2 # literal
250250

251251
argAmlType = ei.args[2].args[2][1]
252-
push!(args_literaltype, argAmlType) # literal type
252+
args_literaltype[iArg] = argAmlType # literal type
253253

254254
ni = ei.args[2].args[2][2]
255255

@@ -261,7 +261,7 @@ function aml_parse(expr::Expr)
261261
end
262262

263263
else
264-
push!(args_literaltype, AbsNormal) # non-literal
264+
args_literaltype[iArg] = AbsNormal # non-literal
265265

266266
ni = ei.args[2].args[2]
267267

@@ -280,8 +280,8 @@ function aml_parse(expr::Expr)
280280
fun = ei.args[2].args[3] # function
281281
args_function[iArg] = fun
282282

283-
else # function name isn't given
284-
args_function[iArg] = missing
283+
# else # function name isn't given
284+
# args_function[iArg] = missing
285285
end
286286

287287
########################
@@ -295,8 +295,8 @@ function aml_parse(expr::Expr)
295295
defVal = ei.args[2]
296296

297297
args_defaultvalue[iArg] = defVal
298-
args_name[iArg] = missing # ignored for creating aml
299-
args_function[iArg] = missing # ignored for creating aml
298+
# args_name[iArg] = missing # ignored for creating aml
299+
# args_function[iArg] = missing # ignored for creating aml
300300

301301
var = ei.args[1]
302302

@@ -311,8 +311,8 @@ function aml_parse(expr::Expr)
311311
defVal = ei.args[2]
312312

313313
args_defaultvalue[iArg] = defVal
314-
args_name[iArg] = missing # ignored for creating aml
315-
args_function[iArg] = missing # ignored for creating aml
314+
# args_name[iArg] = missing # ignored for creating aml
315+
# args_function[iArg] = missing # ignored for creating aml
316316

317317
var = lhs.args[1]
318318
varType = lhs.args[2] # Type
@@ -337,8 +337,8 @@ function aml_parse(expr::Expr)
337337

338338
# Type Checker
339339
if ei isa Symbol # var
340-
args_name[iArg] = missing # argument ignored for aml
341-
args_function[iArg] = missing # ignored for creating aml
340+
# args_name[iArg] = missing # argument ignored for aml
341+
# args_function[iArg] = missing # ignored for creating aml
342342

343343
args_type[iArg] = String
344344

@@ -348,8 +348,8 @@ function aml_parse(expr::Expr)
348348
args_var[iArg] = var
349349

350350
elseif ei.head == :(::) && ei.args[1] isa Symbol # var::T
351-
args_name[iArg] = missing # argument ignored for aml
352-
args_function[iArg] = missing # ignored for creating aml
351+
# args_name[iArg] = missing # argument ignored for aml
352+
# args_function[iArg] = missing # ignored for creating aml
353353

354354
var = ei.args[1]
355355
varType = ei.args[2] # Type

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)