Re: odd rhythms - how?

[email protected] ("Noel Lairson") Wed, 14 May 2003 21:13:41 -0700
Newsgroups perl.midi
Message-ID <003501c31a98$63fbbfa0$b6e5fea9@fido>
Jackie -
I don't know if this helps - this works for information written previously
by your program.  I don't know if it works for external MIDI files you're
opening.


    $score_r = Score_r;
#         $score_r is now an array of the events you've written (actually an
array of arrays, each of which represents the values of a single event)

    foreach $note_r (@$score_r) {
#        cycles through them one by one.  They cycle through in
channell/time order.  In other words, it runs through the events in channel
0, from time 0 through the end of the track; then the same for track 1; then
track 2, etc.
#        In any case, $$note_r[0] contains the type of event.
#         I was looking for notes in particular, so:

 if($$note_r[0] eq 'note') {
#        the note arrays, dereferenced, look like this:
#        'note' time duration channel notenumber velocity
#        (by the way, 'time' here is 'MIDI ticks since beginning of file)
#        So say I want to work with the notes in channel 0:

     if($$note_r[3] == '0') {
##            do stuff here
####        Important safety tip: if this function adds to channel 0, you've
created an infinite loop!
####        Not that I know that from excruciating, hair-tearing experience
or anything...

     }
 }
    }

#     once you assign Score_r to a variable, you do not need to assign it
again.  That variable will always contain an up-to-the-moment list of what
you have written so far.
Clear?
Hope this helps.  I don't know the answer to your IDE question, but I assure
you that there are no carats in the above code...
Noel