Mike,
Jim Menard wrote:
>
>midilib is a pure Ruby MIDI library useful for reading and writing standard
>MIDI files and manipulating MIDI event data.
How does it differ from http://raa.ruby-lang.org/project/smf/ ?
(I guess I'll go find out!
Both midilib and smf read and write standard MIDI files. smf supports MML, a
musical notation language. midilib has no such support.
midilib adds a few methods to the Track and Event classes that support
quantizing tracks and events and modifying events' times. I don't see similar
methods in smf, but I could be wrong.
Also, midilib events have an extra time_from_start ivar. Events have delta
times (time from the previous event), but Track has a method that fills in the
time_from_start values for each event. This makes track and event manipulation
easier.
Here's a quick rundown of some of the interesting midilib methods.
MIDI::Track#merge merges an array of events into the track's events.
MIDI::Track#quantize quantizes all of the events in the track.
MIDI::Track#recalc_times recalculates time_from_start for each event.
MIDI::Track#recalc_delta_from_times is the opposite of recalc_times: it
recalculates delta_time for each event from each event's time_from_start.
This is useful, for example, when merging two event lists.
MIDI::Track#sort sorts events by time_from_start (and then recalculates
delta times).
MIDI::Track#quantize quantizes every event.
MIDI::Event#quantize_by quantizes a single event.
MIDI:Event#channel?
MIDI:Event#note?
MIDI:Event#note_on?
MIDI:Event#note_off?
MIDI:Event#meta?
MIDI:Event#system?
MIDI:Event#realtime?
These methods help identify event types when you're walking a list of
events.
Finally, midilib has unit tests.
I welcome bug reports, feedback, comments, and suggestions.
Jim
···
--
Jim Menard, jimm@io.com, http://www.io.com/~jimm/
"The theory of computation states that all automatons can be emulated by a
Turing machine. I have a less abstract but more practical motto: If you can
do it on Intel, you can do it damn near anywhere!" -- Eugene O'Neil