get_midi_length(3alleg4)
β¨ get_midi_length β¨
ok so this is from the Allegro manual bestie, it's get_midi_length(3alleg4) and it's literally about figuring out how long a midi is gonna play for. Allegro game programming library energy π
πΈ NAME πΈ
get_midi_length β Determines the total playing time of a midi, in seconds. Allegro game programming library. π
π¦ SYNOPSIS π¦
#include <allegro.h>
int get_midi_length(MIDI *midi);
π DESCRIPTION π
okok so what this function does is it simulates playing the MIDI you hand it, start to finish, just to figure out how long it takes to play. like it's doing a full run-through in its head bestie, no cap π§ β¨
Once you've called it, two things get updated:
midi_poswill contain the negative number of beatsmidi_timewill contain the length of the midi, in seconds
π¨ heads up bestie: any currently playing midi is stopped when you call this function. it does not care. it will end it. periodt π
So the move is usually to call it before play_midi, so you already know how long the thing you're about to play is gonna be. like this, fr fr:
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);
look at that progress bar-adjacent glow up π it's giving main character energy fr π«Ά
β RETURN VALUE β
Returns the value of midi_time, which is the length of the midi. so like, the answer. the whole point. slay π
π SEE ALSO π
and that's the whole vibe bestie, go make some music timing magic πβ¨πΈ
Allegro β version 4.4.3 β get_midi_length(3alleg4) π byeee π¦
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms