Re: writing midi files from array

[email protected] ("Sean M. Burke") Mon, 17 Sep 2001 20:32:49 -0600
Newsgroups perl.midi
Message-ID <[email protected]>
At 06:02 PM 2001-09-17 -0700, Drew Krause wrote:
>[...]
>@atkpts = attack points in ticks from the beginning
>@pits = midi pitches (0-127)
>@durs = durations in ticks for each note
>
>So a three-event score might look like this:
>@atkpts = (0, 480, 960);
>@pits = (63, 35, 45);
>@durs (480, 480, 240);
>[...]

The @Notes / $Time / $Channel / $Duration / $Volume / etc. attributes of
MIDI::Simple can be directly manipulated.  Almost most of the time it's not
necessary, it'd be the most direct way for what you're doing.

Consider:

  while(@pits) {
    $Time  = shift @atkpts;  # start-time of the next note
    $Duration = shift @durs; # start-time of the next note
    n(shift @pits);
  }

Or you can just do what that n() call there does, and directly manipulate
@Score:

  push @Score, ['note',
   $start_time, $duration, $channel, $pitch, $volume ];

Altho I'm somehow happier with the n() way.  Both should work, tho.


--
Sean M. Burke  [email protected]  http://www.spinn.net/~sburke/