Re: midi re-tempoizer

[email protected] (zentara) Thu, 09 Dec 2004 06:08:06 -0500
Newsgroups perl.midi
Message-ID <[email protected]>
On Wed, 8 Dec 2004 21:02:54 +0000, [email protected] (Jean-Pierre
Vidal) wrote:

>Le vendredi 3 Décembre 2004 10:18, zentara a écrit :
>> Cool. This is a much asked for utility.
>> 
>> I've been wracking my brain trying to figure out how to
>> get the total playlength of a midi using Perl.
>> 
>> Would anyone know how to do this?
>
>Here is a new one, which use MIDI::Score
>
>#!perl -w
>use strict;
>use diagnostics;
>use MIDI;
......

>It works for almost of my midifiles. 
>Unfortunately, it doesnt work for some midifiles, failing with a diagnostic 
>like this:
>
>
>I'll search what is wrong with these files and MIDI::Opus
>
>Jean-Pierre

Your script runs without error for me, and on some midi
files gives the correct time. 

But I often get
0 mn 0.0 s
as output.

From a quick check of differences between files that work, and
those that give  0 0, it seems the problem is with midi files that
have NO 'set_tempo' in them.
I put a print in to test various files
     for my $note (@$score_r) {
              if($$note[0] eq 'set_tempo'){print $$note[0],"\n"}

and if it had no set_tempo, I get  0 0 output.

So maybe set a default tempo?

I think you are on the right track, in detecting 'set_tempo' events
to adjust the note playlength.

It seems like you are sooooo close. :-)




-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html