From dddf5a0cb0213c4465515f3a9f12500be4225560 Mon Sep 17 00:00:00 2001 From: Grant Brown Date: Mon, 3 Jan 2022 04:05:50 -0600 Subject: [PATCH] Minor changes to help with multiple-track files (#153) * Change default MIDIFile type to 1 as discussed in #152 * Add a warning for format 0 files with n-tracks > 1 * Bump minor version and update CHANGELOG --- CHANGELOG.md | 4 +++- Project.toml | 2 +- src/io.jl | 6 ++++++ src/midifile.jl | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c0616a..445b9e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ 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). - +# v2.1.0 +* Default value of `MIDIFile.format` changed from 0 to 1 +* Warning introduced to `fileio_save` for format 0 files with multiple tracks # v2.0.0 ## Breaking * `MIDIEvent` and `MetaEvent` are abstract types and they cannot be used directly. diff --git a/Project.toml b/Project.toml index 13fb2a6..0b00b49 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.4" +version = "2.1.0" [deps] FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" diff --git a/src/io.jl b/src/io.jl index 6831b7f..7d45e34 100644 --- a/src/io.jl +++ b/src/io.jl @@ -36,6 +36,12 @@ function fileio_save(f::File{format"MIDI"}, data::MIDIFile) end function fileio_save(s::Stream{format"MIDI"}, data::MIDIFile) + if data.format == UInt8(0) && length(data.tracks) > 1 + @warn("MIDI file-type 0 only supports a single track. Consider using "* + " format 1, or converting your file using type1totype0! to convert "* + " type 1 data to type 0 data.") + end + write(s, magic(format"MIDI")) write(s, hton(convert(UInt32, 6))) # Header length diff --git a/src/midifile.jl b/src/midifile.jl index 87e0e11..7e3e76b 100644 --- a/src/midifile.jl +++ b/src/midifile.jl @@ -28,7 +28,7 @@ function Base.show(io::IO, midi::MIDIFile) end -MIDIFile() = MIDIFile(0,960,MIDITrack[]) +MIDIFile() = MIDIFile(1,960,MIDITrack[]) """ qpm(midi)