get_midi_length(3)
π get_midi_length β Allegro manual, bestie edition π
okay so you're in the get_midi_length(3) page of the Allegro manual, and honestly? this one is a little bop. it's about finding out how long a MIDI is gonna play for. let's get into it π
β¨ NAME β¨
get_midi_length β figures out the total playing time of a midi, in seconds. it's giving Allegro game programming library realness π΅
β¨ SYNOPSIS β¨
#include <allegro.h>
int get_midi_length(MIDI *midi);
β¨ DESCRIPTION β¨
so basically this function simulates playing the given MIDI from start to finish just to work out how long it takes to play. no cap, it really does sit there and mentally run through the whole thing for you. π§
once you've called it, two things happen and they're lowkey important:
midi_poswill hold the negative number of beats π«Άmidi_timewill hold the length of the midi, in seconds β±οΈ
β οΈ heads up bestie: any midi that's currently playing gets stopped the moment you call this. so don't be out here calling it mid-vibe and then wondering why the music died π
the usual move is to call it before play_midi, so you already know the length of the thing you're about to play. like this:
length = get_midi_length(my_midi);
play_midi(my_midi);
do {
pos = midi_time;
textprintf_ex(screen, font, 0, 0, c, -1, "%d:%02d / %d:%02d\n",
pos / 60, pos % 60, length / 60, length % 60);
rest(100);
} while(pos <= length);
that's the whole "current time / total time" display situation. iconic honestly π
β¨ RETURN VALUE β¨
it returns the value of midi_time β aka the length of the midi. that's it, that's the tea π
β¨ SEE ALSO β¨
and that's the page!! go forth and time your midis, queen π this was get_midi_length(3) from the Allegro manual, version 4.4.3 β mwah, catch you in the next one π¦π
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms