Skip to content

Commit

Permalink
Add MIDI format (#323)
Browse files Browse the repository at this point in the history
* Add MIDI format

* Add tests for midi files
  • Loading branch information
VasanthManiVasi committed Apr 25, 2021
1 parent bf57b7f commit 8932b89
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/registry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,5 @@ add_format(format"vega", (), [".vega"], [:Vega => UUID("239c3e63-733f-47ad-beb7-
add_format(format"FCS", "FCS", [".fcs"], [:FCSFiles => UUID("d76558cf-badf-52d4-a17e-381ab0b0d937")])

add_format(format"HTML", (), [".html", ".htm"], [MimeWriter, SAVE])

add_format(format"MIDI", "MThd", [".mid", ".midi", ".MID"], [:MIDI => UUID("f57c4921-e30c-5f49-b073-3f2f2ada663e")])
Binary file added test/files/doxy.MID
Binary file not shown.
Binary file added test/files/doxy.mid
Binary file not shown.
Binary file added test/files/doxy.midi
Binary file not shown.
14 changes: 14 additions & 0 deletions test/query.jl
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,20 @@ let file_dir = joinpath(@__DIR__, "files"), file_path = Path(file_dir)
@test position(io) == 0
end
end
@testset "MIDI detection" begin
q = query(joinpath(file_dir, "doxy.mid"))
@test typeof(q) <: File{format"MIDI"}
q = query(joinpath(file_dir, "doxy.midi"))
@test typeof(q) <: File{format"MIDI"}
q = query(joinpath(file_dir, "doxy.MID"))
@test typeof(q) <: File{format"MIDI"}
@test magic(format"MIDI") == b"MThd"
open(q) do io
@test position(io) == 0
skipmagic(io)
@test position(io) == 4
end
end
end

@testset "Query from IOBuffer" begin
Expand Down

0 comments on commit 8932b89

Please sign in to comment.