Negative [?] note duration? h-h-huh?

[email protected] ("David L. Nelson, CAE's version of Yet Another...") Wed, 10 Jan 2001 15:06:22 -0600 (CST)
Newsgroups perl.midi
Message-ID <[email protected]>
Downloaded Sean M. Burke's MIDI-Perl last week.

Never done oop before, though how I tried.

Never saw a hash I didn't eat, let alone an anonymous hash of references.

Never knew a module, nor a package.

However I did get one particularly useful example off the list (create 
a MIDI file; alter it in some way; save it back).

That second step there is 'me all over.' My most-recent long-time 
dream has been to open a MIDI file, alter it ~my~ way, and save it
back out.

It requires my code to recognize individual notes and send them one
place or other based on their characteristics.

I expected to fall flat on my face from square knocks from Perl, but
as it happens, I've got it 95% done(!). In a week! (ish) and I've used
all that junk up there at the beginning I never dreamed I would.
[Oblig. stmnt of obv. unTHINKable without MIDI-Perl to start from.]

Turns out the 2x4 blow to the back of the head may be coming from MIDI
(or from a calculation in MIDI::Simple?).

The first complex (overlapping notes) MIDI I tried it on resulted in
some notes (as inferred by MIDI-Perl routines) being of "negative" 
duration.

In fact, it so happened that the Very First Note was:
 ['note', 0, '-0', 1, 67, 80]  # quotes in orig.; if you guessed this was
			       #   taken from a zip of German folk tunes,
			       #   you ARE scary... 
The '' are present in the output (so duration is really a "negative string").

I first thought perhaps a calc. mistake, but the -duration is inevitably
followed by a "correct" pattern, AT the same time; e.g.,
 ['note', 0, '-0', 1, 67, 80]
 ['note', 0, 192, 1, 67, 80]
 ...
That is no notes are being lost.

Too, the pattern recurs: throughout the score are instances like:
 ['note',3840,-3840,1,67,80] # no more ''s now.
 ['note',3840,192,1,67,80]
 ...

| grep note |grep '-' yields (with MANY notes missing btwn):
 ['note', 0, '-0', 1, 67, 80],
 ['note', 3840, -3840, 1, 67, 80],
 ['note', 13440, -13440, 1, 67, 80],
 ['note', 15360, -15360, 1, 67, 80],
 ['note', 19200, -19200, 1, 67, 80],
 ['note', 23040, -23040, 1, 67, 80],
 ['note', 32640, -32640, 1, 67, 80],
 ['note', 34560, -34560, 1, 67, 80],
 ['note', 38400, -38400, 1, 67, 80],
 ['note', 42240, -42240, 1, 67, 80],
 ['note', 51840, -51840, 1, 67, 80],
 ['note', 53760, -53760, 1, 67, 80],
 ['note', 57600, -57600, 1, 67, 80],
 ['note', 61440, -61440, 1, 67, 80],
 ['note', 71040, -71040, 1, 67, 80],
 ['note', 72960, -72960, 1, 67, 80],
 ['note', 76800, -76800, 1, 67, 80],
 ['note', 80640, -80640, 1, 67, 80],
 ['note', 90240, -90240, 1, 67, 80],
 ['note', 92160, -92160, 1, 67, 80],

The only pattern I can divine is that the difference btwn "adjacent" negative
durations seems to be a multiple of 1920: e.g. -13440- -15360 = 1920? And
-15360- -19200 = 3840 (1920*2)?

On top of not being a Perlist, I'm not a MIDIte either.
(That's like saying, I may not be smart, but at least I'm ugly...)

BTW, I'm going to just go ahead and pretend these negative notes
are not important because I don't understand them. It's working
so far with the rest of my life. :o)

David Nelson