1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#![forbid(unsafe_code)]
use thiserror::Error;
/// Errors raised while reading or writing a Standard MIDI File.
#[derive(Debug, Error, Clone, PartialEq, Eq)]
pub enum SmfError {
/// The `MThd`/`MTrk` chunk header was malformed.
#[error("invalid header at byte {offset}")]
InvalidHeader {
/// Byte offset of the bad header.
offset: usize,
},
/// The byte stream ended before the structure was complete.
#[error("unexpected end of file at byte {offset}")]
UnexpectedEof {
/// Byte offset where more input was expected.
offset: usize,
},
/// A variable-length quantity was not terminated within four bytes.
#[error("invalid VLQ at byte {offset}")]
InvalidVlq {
/// Byte offset where the VLQ began.
offset: usize,
},
/// The header requested SMPTE division, which is not supported.
#[error("unsupported SMPTE division 0x{raw:04x} at byte {offset}")]
UnsupportedSmpteDivision {
/// Byte offset of the division field.
offset: usize,
/// The raw division value.
raw: u16,
},
/// A data byte appeared with no running status in effect.
#[error("malformed running status at byte {offset}")]
MalformedRunningStatus {
/// Byte offset of the offending data byte.
offset: usize,
},
/// A status byte that the reader does not handle was encountered.
#[error("unsupported MIDI status 0x{status:02x} at byte {offset}")]
UnsupportedStatus {
/// Byte offset of the status byte.
offset: usize,
/// The unsupported status byte.
status: u8,
},
/// A channel message carried an out-of-range data byte.
#[error("invalid channel payload at byte {offset}")]
InvalidChannelData {
/// Byte offset of the bad data.
offset: usize,
},
/// The header format and the track count are inconsistent (for example,
/// format 0 with more than one track).
#[error("SMF format/track count mismatch")]
FormatTrackMismatch,
/// An event time could not be represented exactly at the file resolution.
#[error("event time cannot be represented exactly at target TPQ")]
InexactEventTime,
/// Track events were not monotonic in absolute time, yielding a negative
/// delta.
#[error("track events are not monotonic in absolute time")]
NegativeDelta,
}