ghakuf
A Rust library for parsing/building SMF (Standard MIDI File).
Examples
ghakuf
has parse module and build module separatory.
Perser
ghakuf
's parser is made by Event-driven online algorithm. You must prepare original handler implementing Handler trait to catch SMF messages. Any number of handlers you can add for parser if you want.
use *;
use *;
use path;
let path = new;
let mut handler = HogeHandler;
let mut reader = new.unwrap;
let _ = reader.read;
Builder
ghakuf
build SMF by Message enums. Message enum consists of MetaEvent, MidiEvent, SysExEvent, and TrackChange. You can use running status if you want. At track change, you should use not only MetaEvent::EndOfTrack message, but also TrackChange message.
use *;
use *;
use path;
let tempo: u32 = 60 * 1000000 / 102; //bpm:102
let write_messages: = vec!;
let path = new;
let mut writer = new;
writer.running_status;
for message in &write_messages
let _ = writer.write;
Supported SMF Event
You can use three type events. In Message enum, these events have delta time and data.
Meta Event
- SequenceNumber
- TextEvent
- CopyrightNotice
- SequenceOrTrackName
- InstrumentName
- Lyric
- Marker
- CuePoint
- MIDIChannelPrefix
- EndOfTrack
- SetTempo
- SMTPEOffset
- TimeSignature
- KeySignature
- SequencerSpecificMetaEvent
MIDI Event
- NoteOff { ch: u8, note: u8, velocity: u8 }
- NoteOn { ch: u8, note: u8, velocity: u8 }
- PolyphonicKeyPressure { ch: u8, note: u8, velocity: u8 }
- ControlChange { ch: u8, control: u8, data: u8 }
- ProgramChange { ch: u8, program: u8 }
- ChannelPressure { ch: u8, pressure: u8 }
- PitchBendChange { ch: u8, data: i16 }
System Exclusive Event
- (F0 event)
- (F7 event)
License
ghakuf
is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.
See LICENSE-APACHE, and LICENSE-MIT for details.