diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index 68dbe39..6c2390a 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -9,7 +9,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - julia-version: [1.2.0] + julia-version: [1] julia-arch: [x86] os: [ubuntu-latest] steps: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7626690..3869802 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,3 @@ jobs: - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 - with: - file: lcov.info diff --git a/Project.toml b/Project.toml index 3cae0e4..a5f1e94 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MIDI" uuid = "f57c4921-e30c-5f49-b073-3f2f2ada663e" repo = "https://github.com/JuliaMusic/MIDI.jl.git" -version = "2.0.2" +version = "2.0.3" [deps] FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" diff --git a/README.md b/README.md index d0f5004..cc6e3e8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # MIDI.jl -| **Documentation** | **Travis** | **Citation** | +| **Documentation** | **Tests** | **Citation** | |:--------:|:--------:|:------:| -|[![](https://img.shields.io/badge/docs-online-blue.svg)](https://juliamusic.github.io/JuliaMusic_documentation.jl/latest/)| [![Build Status](https://travis-ci.org/JuliaMusic/MIDI.jl.svg?branch=master)](https://travis-ci.org/JuliaMusic/MIDI.jl) | [![status](http://joss.theoj.org/papers/e0cfc67982f857ed96d906ff2266aa15/status.svg)](http://joss.theoj.org/papers/e0cfc67982f857ed96d906ff2266aa15) +|[![](https://img.shields.io/badge/docs-online-blue.svg)](https://juliamusic.github.io/JuliaMusic_documentation.jl/latest/)| [![CI](https://github.com/juliamusic/MIDI.jl/workflows/CI/badge.svg)](https://github.com/JuliaMusic/MIDI.jl/actions) | [![status](http://joss.theoj.org/papers/e0cfc67982f857ed96d906ff2266aa15/status.svg)](http://joss.theoj.org/papers/e0cfc67982f857ed96d906ff2266aa15) --- diff --git a/src/MIDI.jl b/src/MIDI.jl index 2815589..a6aa992 100644 --- a/src/MIDI.jl +++ b/src/MIDI.jl @@ -3,7 +3,6 @@ A Julia library for reading and writing MIDI files. """ module MIDI -using FileIO using Base.Unicode include("constants.jl") diff --git a/src/io.jl b/src/io.jl index d2c2cce..6831b7f 100644 --- a/src/io.jl +++ b/src/io.jl @@ -1,18 +1,17 @@ -""" - load(filename::File{format"MIDI"}) -Read a file into a `MIDIFile` data type. +# This file extends the FileIO.jl interface for filenames ending with ".mid". +# See https://juliaio.github.io/FileIO.jl/stable/implementing/#Implementing-loaders/savers -!!! note - This function must not be called explicitly. [`FileIO.load`](https://juliaio.github.io/FileIO.jl/stable/) must be called instead. -""" -function load(f::File{format"MIDI"}) +using FileIO +export load, save + +function fileio_load(f::File{format"MIDI"}) open(f) do s skipmagic(s) midifile = load(s) end end -function load(s::Stream{format"MIDI"}) +function fileio_load(s::Stream{format"MIDI"}) midifile = MIDIFile() # Skip the next four bytes - this is the header size, and it's always equal to 6. @@ -27,26 +26,16 @@ function load(s::Stream{format"MIDI"}) midifile.tpq = ntoh(read(s, Int16)) midifile.tracks = [readtrack(s.io) for x in 1:numberoftracks] - midifile + return midifile end -""" - save(filename::File{format"MIDI"}, data::MIDIFile) -Write a `MIDIFile` as a ".mid" file to the given filename. - - save(filename::File{format"MIDI"}, notes::Notes) -Create a `MIDIFile` directly from `notes`, using format 1. - -!!! note - This function must not be called explicitly. [`FileIO.save`](https://juliaio.github.io/FileIO.jl/stable/) must be called instead. -""" -function save(f::File{format"MIDI"}, data::MIDIFile) +function fileio_save(f::File{format"MIDI"}, data::MIDIFile) open(f, "w") do s - save(s, data) + fileio_save(s, data) end end -function save(s::Stream{format"MIDI"}, data::MIDIFile) +function fileio_save(s::Stream{format"MIDI"}, data::MIDIFile) write(s, magic(format"MIDI")) write(s, hton(convert(UInt32, 6))) # Header length @@ -54,14 +43,14 @@ function save(s::Stream{format"MIDI"}, data::MIDIFile) write(s, hton(convert(UInt16, length(data.tracks)))) write(s, hton(data.tpq)) - map(track->writetrack(s.io, track), data.tracks) + map(track -> writetrack(s.io, track), data.tracks) return data end -function save(s::Union{File{format"MIDI"}, Stream{format"MIDI"}}, notes::Notes) +function fileio_save(s::Union{File{format"MIDI"}, Stream{format"MIDI"}}, notes::Notes) track = MIDITrack() addnotes!(track, notes) midi = MIDIFile(1, notes.tpq, [track]) - save(s, midi) + fileio_save(s, midi) return midi end