Skip to content

Commit

Permalink
correct implementation of Base.copy(::Notes)
Browse files Browse the repository at this point in the history
  • Loading branch information
Datseris committed Nov 12, 2019
1 parent c53e4a6 commit bf010b7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

# v1.5.2
* Correctly implement `Base.copy(::Notes)` to copy every note, instead of copying the high-level vector (which lead to all internal notes being the same object as the non-copied version).
# v1.5.0
* `show` for midi now states the contained tracks

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MIDI"
uuid = "f57c4921-e30c-5f49-b073-3f2f2ada663e"
repo = "https://github.com/JuliaMusic/MIDI.jl.git"
version = "1.5.1"
version = "1.5.2"

[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
2 changes: 1 addition & 1 deletion src/note.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function Base.append!(n1::Notes{N}, n2::Notes{N}) where {N}
return n1
end

Base.copy(notes::Notes) = Notes(copy(notes.notes), notes.tpq)
Base.copy(notes::Notes) = Notes([copy(n) for n in notes], notes.tpq)


#######################################################
Expand Down
8 changes: 8 additions & 0 deletions test/note.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ end
n = Note(0, 1, 1, 1)
@test pitch_to_name(n.pitch) == "C-1"
end

@testset "copying notes" begin
midi = readMIDIFile("doxy.mid")
notes = getnotes(midi.tracks[4])
n2 = copy(notes)
notes[1].pitch = 1
@test n2[1].pitch 1
end

0 comments on commit bf010b7

Please sign in to comment.