get_midi_length(3alleg)

get_midi_length3alleg

Determines the total playing time of a midi, in seconds. allegro game programming library.

Usage

#include <allegro.h>

int get_midi_length(MIDI *midi);

Overview

This function will simulate playing the given MIDI, from start to end, to determine how long it takes to play. After calling this function, midi_pos will contain the negative number of beats, and midi_time the length of the midi, in seconds.

Note that any currently playing midi is stopped when you call this function. Usually you would call it before play_midi, to get the length of the midi to be played, like in this example:

   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);

Return value

Returns the value of midi_time, the length of the midi.

Releases

3 releases since Debian 4.0 (Etch); the text changed 1 time.

  1. 4.0
  2. 5.0–6.0

From liballegro-doc 2:4.2.2-2.2 in Debian 6.0 (Squeeze). Parsed by carta from the page's man source.