From 775651a9c37e25a42e8e862abca53950f6339755 Mon Sep 17 00:00:00 2001 From: aminya Date: Tue, 3 Mar 2020 23:48:19 -0600 Subject: [PATCH 1/9] Alias --- src/MusicXML.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/MusicXML.jl b/src/MusicXML.jl index 857d6e9..be443c7 100644 --- a/src/MusicXML.jl +++ b/src/MusicXML.jl @@ -1,5 +1,9 @@ module MusicXML +# Alias +export MX +const MX = MusicXML + using AcuteML # I/O functions From cabb96b1e59dd5a05554260a1695d83a71db09ef Mon Sep 17 00:00:00 2001 From: aminya Date: Tue, 3 Mar 2020 23:48:31 -0600 Subject: [PATCH 2/9] @MX --- src/MusicXML.jl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/MusicXML.jl b/src/MusicXML.jl index be443c7..0d392bd 100644 --- a/src/MusicXML.jl +++ b/src/MusicXML.jl @@ -4,8 +4,36 @@ module MusicXML export MX const MX = MusicXML +macro MX(expr) + expr_string = string(expr) + expr_string = reduce(replace, + ( + r"(? "MX.ScorePartwise", + r"(? "MX.Part", + r"(? "MX.Measure", + r"(? "MX.Note", + r"(? "MX.Chord", + r"(? "MX.Unpitched", + r"(? "MX.Rest", + r"(? "MX.Pitch", + r"(? "MX.Attributes", + r"(? "MX.Time", + r"(? "MX.Transpose", + r"(? "MX.Clef", + r"(? "MX.Key", + r"(? "MX.PartList", + r"(? "MX.ScorePart", + r"(? "MX.MidiInstrument", + r"(? "MX.MidiDevice", + r"(? "MX.ScoreInstrument", + ), + init = expr_string) + return esc(Meta.parse(expr_string)) +end + using AcuteML + # I/O functions include("io.jl") # Types: From ec7f2213a37efc54f3b912d3e3aaa10cf3dcba10 Mon Sep 17 00:00:00 2001 From: aminya Date: Tue, 3 Mar 2020 23:48:42 -0600 Subject: [PATCH 3/9] @MX docstring --- src/MusicXML.jl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/MusicXML.jl b/src/MusicXML.jl index 0d392bd..826633b 100644 --- a/src/MusicXML.jl +++ b/src/MusicXML.jl @@ -4,6 +4,38 @@ module MusicXML export MX const MX = MusicXML +# Type Helper Macro +export @MX +""" + @MX + +A macro that adds `MX.` to the name of the MusicXML types. + +Since MusicXML's types are not exported from the package to avoid conflicts with the similarly named types from other libraries (such as `Dates.Time`, `MIDI.Note`), `@MX` is given that facilitates using MusicXML types. + +`@MX` assumes that all the types with these kinds of names inside in front of a macro, between `()`, or between `begin end` are MusicXML types unless explicitly written (e.g. `MIDI.Note`). + +# Examples +```julia +@MX begin + Note(pitch = Pitch(step = "C", alter = 0, octave = 4), duration = 4)) + # all the code ... +end +``` +is translated to: +```julia + MX.Note(pitch = Pitch(step = "C", alter = 0, octave = 4), duration = 4)) +``` + +Type is untouched if it is called explicitly from another library: +```julia +@MX Dates.Time(12,53,40) +``` +remains as: +```julia +Dates.Time(12,53,40) +``` +""" macro MX(expr) expr_string = string(expr) expr_string = reduce(replace, From a6b7f46f151fee30c3feed6a9f2bc6808d5867d5 Mon Sep 17 00:00:00 2001 From: aminya Date: Tue, 3 Mar 2020 23:49:20 -0600 Subject: [PATCH 4/9] Add different type usage methods --- README.md | 5 +++++ docs/src/types.md | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 239ae64..d08fecf 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,11 @@ readmusicxml, parsemusicxml ## Typess: +Since MusicXML's types are not exported from the package to avoid conflicts with the similarly named types from other libraries (such as `Dates.Time`, `MIDI.Note`), +1) you should either `import` the types yourself if you are sure that there is no conflict. +2) or us `MX.` before the type names (which `MX` is an alias for `MusicXML`) +3) or use `@MX` macro, which adds `MX.` automatically to the type names. See `@MX` docstring for examples. + ``` ScorePartwise partlist (PartList) diff --git a/docs/src/types.md b/docs/src/types.md index 40ba572..8da49c6 100644 --- a/docs/src/types.md +++ b/docs/src/types.md @@ -1,5 +1,10 @@ # Types +Since MusicXML's types are not exported from the package to avoid conflicts with the similarly named types from other libraries (such as `Dates.Time`, `MIDI.Note`), +1) you should either `import` the types yourself if you are sure that there is no conflict. +2) or us `MX.` before the type names (which `MX` is an alias for `MusicXML`) +3) or use `@MX` macro, which adds `MX.` automatically to the type names. See `@MX` docstring for examples. + ``` ScorePartwise partlist (PartList) From 632b74c2993a5f3aa2041dc049460c5c27931f6d Mon Sep 17 00:00:00 2001 From: aminya Date: Tue, 3 Mar 2020 23:49:34 -0600 Subject: [PATCH 5/9] bump AcuteML --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 89a6670..adc78ee 100644 --- a/Project.toml +++ b/Project.toml @@ -8,7 +8,7 @@ AcuteML = "6b84a0a3-a11a-41fa-a417-e600528de108" TreeViews = "a2a6695c-b41b-5b7d-aed9-dbfdeacea5d7" [compat] -AcuteML = "0.8.4" +AcuteML = "0.8.5" TreeViews = "0.3" julia = "1.1" From e3a3b5d484bacd5913c35c426786ca14bf42a19f Mon Sep 17 00:00:00 2001 From: aminya Date: Tue, 3 Mar 2020 23:50:16 -0600 Subject: [PATCH 6/9] Update examples using @MX and .MX --- README.md | 2 ++ docs/src/creating.md | 2 ++ examples/creating.jl | 2 ++ test/runtests.jl | 6 +++--- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d08fecf..4b71194 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Powerful MusicXML reading and writing package for Julia. ``` # Creating Example ```julia +@MX begin # adds `MX.` to the name of all MusicXML types using MusicXML ## Part List @@ -116,6 +117,7 @@ partlist = partlist, parts = [part_piano, part_guitar], ) +end # end @MX writemusicxml("myscore.musicxml", score) ``` diff --git a/docs/src/creating.md b/docs/src/creating.md index e1e9c5f..ca0a1c5 100644 --- a/docs/src/creating.md +++ b/docs/src/creating.md @@ -1,6 +1,7 @@ # Creating ```julia +@MX begin # adds `MX.` to the name of all MusicXML types using MusicXML ## Part List @@ -104,6 +105,7 @@ partlist = partlist, parts = [part_piano, part_guitar], ) +end # end @MX writemusicxml("myscore.musicxml", score) ``` diff --git a/examples/creating.jl b/examples/creating.jl index 62f874d..8260d6a 100644 --- a/examples/creating.jl +++ b/examples/creating.jl @@ -1,5 +1,6 @@ using MusicXML +@MX begin # adds `MX.` to the name of all MusicXML types ## Part List ### Piano midiinstrument_piano = MidiInstrument(channel= 1, program =1, volume = 100, pan =0, id = "P1-I1") @@ -101,5 +102,6 @@ partlist = partlist, parts = [part_piano, part_guitar], ) +end # end @MX writemusicxml("myscore.musicxml", score) diff --git a/test/runtests.jl b/test/runtests.jl index f1aeb8e..3770450 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,9 +5,9 @@ cd(@__DIR__) @testset "parsing example" begin include("../examples/parsing.jl") - @test scorepartwise isa ScorePartwise - @test scoreparts isa Vector{ScorePart} - @test parts isa Vector{Part} + @test scorepartwise isa MX.ScorePartwise + @test scoreparts isa Vector{MX.ScorePart} + @test parts isa Vector{MX.Part} end @testset "creating example" begin From 27a517a12a6426ce0bdb510390b1a7379f4d7050 Mon Sep 17 00:00:00 2001 From: aminya Date: Tue, 3 Mar 2020 23:50:29 -0600 Subject: [PATCH 7/9] Rename NoteX to Note --- README.md | 63 +++++++++---------- .../precompile/precompile_MusicXML.jl | 4 +- docs/src/creating.md | 58 ++++++++--------- docs/src/types.md | 4 +- examples/creating.jl | 58 ++++++++--------- src/show.jl | 2 +- src/types.jl | 13 ++-- 7 files changed, 100 insertions(+), 102 deletions(-) diff --git a/README.md b/README.md index 4b71194..87f64f2 100644 --- a/README.md +++ b/README.md @@ -40,20 +40,20 @@ attributes1_piano = Attributes( ) measure1_notes_piano = [ -NoteX(pitch = Pitch(step = "C", alter = 0, octave = 4), duration = 4), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 4), -NoteX(pitch = Pitch(step = "E", alter = 0, octave = 4), duration = 4), -NoteX(pitch = Pitch(step = "F", alter = +1, octave = 4), duration = 4), +Note(pitch = Pitch(step = "C", alter = 0, octave = 4), duration = 4), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 4), +Note(pitch = Pitch(step = "E", alter = 0, octave = 4), duration = 4), +Note(pitch = Pitch(step = "F", alter = +1, octave = 4), duration = 4), ] measure2_notes_piano = [ -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 5), duration = 1), -NoteX(pitch = Pitch(step = "G", alter = +1, octave = 5), duration = 1), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 1), -NoteX(pitch = Pitch(step = "A", alter = +1, octave = 5), duration = 1), -NoteX(rest = Rest(), duration = 4), # Rest -NoteX(pitch = Pitch(step = "A", alter = 0, octave = 5), duration = 4), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 4), +Note(pitch = Pitch(step = "G", alter = 0, octave = 5), duration = 1), +Note(pitch = Pitch(step = "G", alter = +1, octave = 5), duration = 1), +Note(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 1), +Note(pitch = Pitch(step = "A", alter = +1, octave = 5), duration = 1), +Note(rest = Rest(), duration = 4), # Rest +Note(pitch = Pitch(step = "A", alter = 0, octave = 5), duration = 4), +Note(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 4), ] measures_piano = [ @@ -77,30 +77,30 @@ attributes1_guitar = Attributes( measure1_notes_guitar = [ # G Major chord for a bar -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 16, chord = Chord()), ] measure2_notes_guitar = [ # G Major chord for half a bar -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), # G Major chord for half a bar -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), ] measures_guitar = [ @@ -225,7 +225,7 @@ ScorePartwise chromatic octaveChange double - notes (Vector{NoteX}) + notes (Vector{Note}) pitch (Pitch) step alter @@ -241,10 +241,9 @@ For fieldnames, if it is a Vector it has `s` at the end of the word. For types, names are capitalized for each word (Camel convention): ``` -ScorePartwise, Part, Measure, NoteX, Unpitched, Rest, Pitch, Attributes, Time, Transpose, Clef, Key, PartList, ScorePart, MidiInstrument, MidiDevice, ScoreInstrument +ScorePartwise, Part, Measure, Note, Chord, Unpitched, Rest, Pitch, Attributes, Time, Transpose, Clef, Key, PartList, ScorePart, MidiInstrument, MidiDevice, ScoreInstrument ``` - ## Utilities ```julia pitch2xml, xml2pitch diff --git a/deps/SnoopCompile/precompile/precompile_MusicXML.jl b/deps/SnoopCompile/precompile/precompile_MusicXML.jl index e1513d2..adf873d 100644 --- a/deps/SnoopCompile/precompile/precompile_MusicXML.jl +++ b/deps/SnoopCompile/precompile/precompile_MusicXML.jl @@ -2,12 +2,12 @@ function _precompile_() ccall(:jl_generating_output, Cint, ()) == 1 || return nothing precompile(Tuple{typeof(findfirst),Function,Array{ScorePart,1}}) precompile(Tuple{typeof(getproperty),Measure,Symbol}) - precompile(Tuple{typeof(getproperty),NoteX,Symbol}) + precompile(Tuple{typeof(getproperty),Note,Symbol}) precompile(Tuple{typeof(getproperty),PartList,Symbol}) precompile(Tuple{typeof(getproperty),ScorePartwise,Symbol}) precompile(Tuple{typeof(isnothing),Pitch}) precompile(Tuple{typeof(iterate),Array{Measure,1}}) - precompile(Tuple{typeof(iterate),Array{NoteX,1}}) + precompile(Tuple{typeof(iterate),Array{Note,1}}) precompile(Tuple{typeof(iterate),Array{Part,1}}) precompile(Tuple{typeof(println),Base.PipeEndpoint,Pitch}) precompile(Tuple{typeof(println),Pitch}) diff --git a/docs/src/creating.md b/docs/src/creating.md index ca0a1c5..c3031a3 100644 --- a/docs/src/creating.md +++ b/docs/src/creating.md @@ -28,20 +28,20 @@ attributes1_piano = Attributes( ) measure1_notes_piano = [ -NoteX(pitch = Pitch(step = "C", alter = 0, octave = 4), duration = 4), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 4), -NoteX(pitch = Pitch(step = "E", alter = 0, octave = 4), duration = 4), -NoteX(pitch = Pitch(step = "F", alter = +1, octave = 4), duration = 4), +Note(pitch = Pitch(step = "C", alter = 0, octave = 4), duration = 4), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 4), +Note(pitch = Pitch(step = "E", alter = 0, octave = 4), duration = 4), +Note(pitch = Pitch(step = "F", alter = +1, octave = 4), duration = 4), ] measure2_notes_piano = [ -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 5), duration = 1), -NoteX(pitch = Pitch(step = "G", alter = +1, octave = 5), duration = 1), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 1), -NoteX(pitch = Pitch(step = "A", alter = +1, octave = 5), duration = 1), -NoteX(rest = Rest(), duration = 4), # Rest -NoteX(pitch = Pitch(step = "A", alter = 0, octave = 5), duration = 4), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 4), +Note(pitch = Pitch(step = "G", alter = 0, octave = 5), duration = 1), +Note(pitch = Pitch(step = "G", alter = +1, octave = 5), duration = 1), +Note(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 1), +Note(pitch = Pitch(step = "A", alter = +1, octave = 5), duration = 1), +Note(rest = Rest(), duration = 4), # Rest +Note(pitch = Pitch(step = "A", alter = 0, octave = 5), duration = 4), +Note(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 4), ] measures_piano = [ @@ -65,30 +65,30 @@ attributes1_guitar = Attributes( measure1_notes_guitar = [ # G Major chord for a bar -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 16, chord = Chord()), ] measure2_notes_guitar = [ # G Major chord for half a bar -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), # G Major chord for half a bar -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), ] measures_guitar = [ diff --git a/docs/src/types.md b/docs/src/types.md index 8da49c6..5dc2b45 100644 --- a/docs/src/types.md +++ b/docs/src/types.md @@ -44,7 +44,7 @@ ScorePartwise chromatic octaveChange double - notes (Vector{NoteX}) + notes (Vector{Note}) pitch (Pitch) step alter @@ -60,7 +60,7 @@ For fieldnames, if it is a Vector it has `s` at the end of the word. For types, names are capitalized for each word (Camel convention): ``` -ScorePartwise, Part, Measure, NoteX, Unpitched, Rest, Pitch, Attributes, Time, Transpose, Clef, Key, PartList, ScorePart, MidiInstrument, MidiDevice, ScoreInstrument +ScorePartwise, Part, Measure, Note, Unpitched, Rest, Pitch, Attributes, Time, Transpose, Clef, Key, PartList, ScorePart, MidiInstrument, MidiDevice, ScoreInstrument ``` diff --git a/examples/creating.jl b/examples/creating.jl index 8260d6a..362b552 100644 --- a/examples/creating.jl +++ b/examples/creating.jl @@ -25,20 +25,20 @@ attributes1_piano = Attributes( ) measure1_notes_piano = [ -NoteX(pitch = Pitch(step = "C", alter = 0, octave = 4), duration = 4), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 4), -NoteX(pitch = Pitch(step = "E", alter = 0, octave = 4), duration = 4), -NoteX(pitch = Pitch(step = "F", alter = +1, octave = 4), duration = 4), +Note(pitch = Pitch(step = "C", alter = 0, octave = 4), duration = 4), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 4), +Note(pitch = Pitch(step = "E", alter = 0, octave = 4), duration = 4), +Note(pitch = Pitch(step = "F", alter = +1, octave = 4), duration = 4), ] measure2_notes_piano = [ -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 5), duration = 1), -NoteX(pitch = Pitch(step = "G", alter = +1, octave = 5), duration = 1), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 1), -NoteX(pitch = Pitch(step = "A", alter = +1, octave = 5), duration = 1), -NoteX(rest = Rest(), duration = 4), # Rest -NoteX(pitch = Pitch(step = "A", alter = 0, octave = 5), duration = 4), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 4), +Note(pitch = Pitch(step = "G", alter = 0, octave = 5), duration = 1), +Note(pitch = Pitch(step = "G", alter = +1, octave = 5), duration = 1), +Note(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 1), +Note(pitch = Pitch(step = "A", alter = +1, octave = 5), duration = 1), +Note(rest = Rest(), duration = 4), # Rest +Note(pitch = Pitch(step = "A", alter = 0, octave = 5), duration = 4), +Note(pitch = Pitch(step = "B", alter = 0, octave = 5), duration = 4), ] measures_piano = [ @@ -62,30 +62,30 @@ attributes1_guitar = Attributes( measure1_notes_guitar = [ # G Major chord for a bar -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 16, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 16, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 16, chord = Chord()), ] measure2_notes_guitar = [ # G Major chord for half a bar -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), # G Major chord for half a bar -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), -NoteX(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "B", alter = 0, octave = 2), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 3), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "D", alter = 0, octave = 4), duration = 8, chord = Chord()), +Note(pitch = Pitch(step = "G", alter = 0, octave = 4), duration = 8, chord = Chord()), ] measures_guitar = [ diff --git a/src/show.jl b/src/show.jl index 4870e92..f5daa1d 100644 --- a/src/show.jl +++ b/src/show.jl @@ -1,4 +1,4 @@ -MusicXMLTypes = [:ScorePartwise, :Part, :Measure, :NoteX, :Unpitched, :Rest, :Pitch, :Attributes, :Time, :Transpose, :Clef, :Key, :PartList, :ScorePart, :MidiInstrument, :MidiDevice, :ScoreInstrument] +MusicXMLTypes = [:ScorePartwise, :Part, :Measure, :Note, :Unpitched, :Rest, :Pitch, :Attributes, :Time, :Transpose, :Clef, :Key, :PartList, :ScorePart, :MidiInstrument, :MidiDevice, :ScoreInstrument] import TreeViews: hastreeview, numberofnodes, treelabel, treenode import Base: inferencebarrier, show_circular diff --git a/src/types.jl b/src/types.jl index b03a264..d0f0daf 100644 --- a/src/types.jl +++ b/src/types.jl @@ -1,5 +1,4 @@ # Types: -export ScorePartwise, Part, Measure, NoteX, Unpitched, Rest, Pitch, Chord, Attributes, Time, Transpose, Clef, Key, PartList, ScorePart, MidiInstrument, MidiDevice, ScoreInstrument ################################################################ # musicxml yes-no type @@ -380,7 +379,7 @@ The attributes element contains musical information that typically changes on me key: See [`Key`](@ref) doc -divisions: The divisions element indicates how many divisions per quarter note are used to indicate a note's duration. `NoteX.duration/Attributes.divisions` gives the actual duration of a note. Should be given based on the shortest note in the measure. If you use 16th notes give `4`, and give duration for the notes as 1. For example, if `divisions = 2`, and we have a `NoteX` with `duration = 1` this is an eighth note duration. The default value is `4`, which means each `duration = 1` means a 16th note. +divisions: The divisions element indicates how many divisions per quarter note are used to indicate a note's duration. `Note.duration/Attributes.divisions` gives the actual duration of a note. Should be given based on the shortest note in the measure. If you use 16th notes give `4`, and give duration for the notes as 1. For example, if `divisions = 2`, and we have a `Note` with `duration = 1` this is an eighth note duration. The default value is `4`, which means each `duration = 1` means a 16th note. Duration and divisions are used directly for generating sound output, so they must be chosen to take tuplets into account. Using a divisions element lets us use just one number to represent a duration for each note in the score, while retaining the full power of a fractional representation. If maximum compatibility with Standard MIDI 1.0 files is important, do not have the divisions value exceed 16383. @@ -495,7 +494,7 @@ end ################################################################ """ - NoteX + Note # Arguments ```julia @@ -524,7 +523,7 @@ tie: [More info](https://usermanuals.musicxml.com/MusicXML/Content/CT-MusicXML-note.htm) """ -@aml mutable struct NoteX "note" +@aml mutable struct Note "note" pitch::UN{Pitch} = nothing, "~" rest::UN{Rest} = nothing, "~" unpitched::UN{Unpitched} = nothing, "~" @@ -542,18 +541,18 @@ end # Arguments ```julia - attributes::UN{Attributes} = nothing, "~" -- notes::Vector{NoteX}, "note" +- notes::Vector{Note}, "note" ``` A type to hold the data for a musicxml measure attributes: See [`Attributes`](@ref) doc -notes: See [`NoteX`](@ref) doc +notes: See [`Note`](@ref) doc """ @aml mutable struct Measure "measure" attributes::UN{Attributes} = nothing, "~" - notes::Vector{NoteX}, "note" + notes::Vector{Note}, "note" end ################################################################ """ From 33c6ed2a071fd62d65cd306abde77148b80e7151 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Wed, 4 Mar 2020 05:52:30 +0000 Subject: [PATCH 8/9] Update precompile_*.jl file --- .../precompile/precompile_MusicXML.jl | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/deps/SnoopCompile/precompile/precompile_MusicXML.jl b/deps/SnoopCompile/precompile/precompile_MusicXML.jl index adf873d..eb3cfa2 100644 --- a/deps/SnoopCompile/precompile/precompile_MusicXML.jl +++ b/deps/SnoopCompile/precompile/precompile_MusicXML.jl @@ -1,16 +1,16 @@ function _precompile_() ccall(:jl_generating_output, Cint, ()) == 1 || return nothing - precompile(Tuple{typeof(findfirst),Function,Array{ScorePart,1}}) - precompile(Tuple{typeof(getproperty),Measure,Symbol}) - precompile(Tuple{typeof(getproperty),Note,Symbol}) - precompile(Tuple{typeof(getproperty),PartList,Symbol}) - precompile(Tuple{typeof(getproperty),ScorePartwise,Symbol}) - precompile(Tuple{typeof(isnothing),Pitch}) - precompile(Tuple{typeof(iterate),Array{Measure,1}}) - precompile(Tuple{typeof(iterate),Array{Note,1}}) - precompile(Tuple{typeof(iterate),Array{Part,1}}) - precompile(Tuple{typeof(println),Base.PipeEndpoint,Pitch}) - precompile(Tuple{typeof(println),Pitch}) + precompile(Tuple{typeof(findfirst),Function,Array{MusicXML.ScorePart,1}}) + precompile(Tuple{typeof(getproperty),MusicXML.Measure,Symbol}) + precompile(Tuple{typeof(getproperty),MusicXML.Note,Symbol}) + precompile(Tuple{typeof(getproperty),MusicXML.PartList,Symbol}) + precompile(Tuple{typeof(getproperty),MusicXML.ScorePartwise,Symbol}) + precompile(Tuple{typeof(isnothing),MusicXML.Pitch}) + precompile(Tuple{typeof(iterate),Array{MusicXML.Measure,1}}) + precompile(Tuple{typeof(iterate),Array{MusicXML.Note,1}}) + precompile(Tuple{typeof(iterate),Array{MusicXML.Part,1}}) + precompile(Tuple{typeof(println),Base.PipeEndpoint,MusicXML.Pitch}) + precompile(Tuple{typeof(println),MusicXML.Pitch}) precompile(Tuple{typeof(readmusicxml),String}) - precompile(Tuple{typeof(sizeof),Pitch}) + precompile(Tuple{typeof(sizeof),MusicXML.Pitch}) end From 32d6355c080cec3f975beb104424bae554315579 Mon Sep 17 00:00:00 2001 From: aminya Date: Tue, 3 Mar 2020 23:53:12 -0600 Subject: [PATCH 9/9] Add Chord to the readme --- README.md | 1 + docs/src/types.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 87f64f2..89549b7 100644 --- a/README.md +++ b/README.md @@ -235,6 +235,7 @@ ScorePartwise duration type accidental + chord (Chord) ``` For fieldnames, if it is a Vector it has `s` at the end of the word. diff --git a/docs/src/types.md b/docs/src/types.md index 5dc2b45..427f560 100644 --- a/docs/src/types.md +++ b/docs/src/types.md @@ -54,13 +54,14 @@ ScorePartwise duration type accidental + chord (Chord) ``` For fieldnames, if it is a Vector it has `s` at the end of the word. For types, names are capitalized for each word (Camel convention): ``` -ScorePartwise, Part, Measure, Note, Unpitched, Rest, Pitch, Attributes, Time, Transpose, Clef, Key, PartList, ScorePart, MidiInstrument, MidiDevice, ScoreInstrument +ScorePartwise, Part, Measure, Note, Chord, Unpitched, Rest, Pitch, Attributes, Time, Transpose, Clef, Key, PartList, ScorePart, MidiInstrument, MidiDevice, ScoreInstrument ```