On Thu, 2005-03-17 at 11:54 -0500, Chris La Mantia wrote:
> From: "Elias Pschernig" <elias@...>
> > I sent a patch to [AD] which adds a function get_midi_length(), which
> > returns the length of the midi in seconds. This won't help if you have
> > to use Allegro 4.0.x or another fixed version.. but else you can just
> > apply the patch, and 4.2.0 also will have that function.
> Oh, while you're in there, could you add a get_midi_time or
> get_midi_pos_seconds or some such that just does a:
> return midi_time / TIMERS_PER_SECOND;
> Or are midi_time and TIMERS_PER_SECOND global? (I don't have access to the
> source right now.) If so, we obviously don't need a function for it...
> Thanks again!
Yes, could just make midi_time global.. simply remove the "static"
before midi_time in midi.c, and add midi_time to include/allegro/midi.h.
I'll change this in the patch. Then midi_time / TIMERS_PER_SECOND will
be the time in seconds in the currently playing midi.
I think the function is still be useful though, since the seek_midi
trick is somewhat hackish. You would then do something like:
length = get_midi_length(midi);
pos = midi_time / TIMERS_PER_SECOND;
print("%d / %d", pos, length);