Skip to main content

Crate oxisound_smf

Crate oxisound_smf 

Source
Expand description

Standard MIDI File (SMF / .mid) parser and player.

§Usage

use oxisound_smf::{parse, SmfFormat, SmfEvent};

// Minimal Format-0 SMF (1 track, 480 ticks/beat, one NoteOn)
let bytes: Vec<u8> = vec![
    0x4D, 0x54, 0x68, 0x64, 0x00, 0x00, 0x00, 0x06,
    0x00, 0x00, 0x00, 0x01, 0x01, 0xE0,
    0x4D, 0x54, 0x72, 0x6B, 0x00, 0x00, 0x00, 0x08,
    0x00, 0x90, 0x3C, 0x40,
    0x00, 0xFF, 0x2F, 0x00,
];
let file = parse(&bytes).unwrap();
assert_eq!(file.format, SmfFormat::SingleTrack);
assert_eq!(file.tracks.len(), 1);

Structs§

SmfError
Parse error returned by parse.
SmfFile
A fully parsed SMF file.
SmfPlayer
Merges all tracks from an SmfFile and provides a chronologically sorted event stream with wall-clock timestamps.
SmfTrack
One track extracted from an SMF file.
TempoMap
Accumulated tempo map built from all tracks in an SmfFile.
TrackEvent
A single event within a track, with its delta-tick offset from the previous event.

Enums§

Division
SMF time division — either ticks-per-beat or SMPTE frame-based.
SmfEvent
All event kinds that can appear in an SMF track.
SmfFormat
SMF file format variant (header word 0).

Functions§

parse
Parse a Standard MIDI File from a raw byte slice.
ticks_to_seconds
Convert a tick duration to seconds given a fixed tempo (convenience function).
write_smf
Encode an SmfFile to SMF bytes suitable for writing to a .mid file.