delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/08/05:45:41

Message-ID: <D1FB30BBA491D1118E6D006097BCAE39238826@Probe-nt-2a.Probe.co.uk>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: A couple of questions about MIDI's and Allegro
Date: Wed, 8 Apr 1998 10:42:57 +0100
MIME-Version: 1.0

D. Huizenga writes:
>    1. Is it possible to tell how long a midi is, without
>       seeking through the whole thing until you get to the
>       end?

Not easily: I think that repeated seeks will be the best way to do 
this (very ugly, but easy to code).

The other possibility would be to scan through the MIDI data to
measure exactly how long it is. You could use the load_patches()
function (from midi.c) as a starting point for something like
this, but it will be awkward to get the results in any usable
format. It isn't enough just to measure the length in the
raw format used by the MIDI file, because you will need to look
at the playback speed (which may be changed at any point using
the tempo meta-event), and check the number of beat divisions 
from the file header before you can get the length in a useful
format. By the time you've done all that, you might as well
just have scanned through the entire file with a seek operation...

	Shawn Hargreaves.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019