MIDI notes not playing unless...

[email protected] (Web Thumper) Wed, 25 Oct 2000 22:42:12 -0700
Newsgroups perl.midi
Organization Get Thumped Productions
Message-ID <[email protected]>
Below is sniplets of perl script (from a much larger project) to create a
click-track of four notes.  The problem is that unless I add another note to
the first measure I only hear 3 notes instead of 4 notes.

This script creates two files - test1.mid and test2.mid.  The test1.mid only
plays 3 notes.  The test2.mid will play all four notes, but then it has that
note of silence.

Has anyone ever run into this situation?  What I am trying to do is create
drum patterns that I will be able to loop...and not have this extra note
pause between loops.

I have checked out a similar drum pattern created from Cubase and it looks
almost identical to the test1.mid file (when dumped using the perl script at
the very bottom of this email).

Any help would be appreciated!

============================================================
#!\perl\bin\perl

 use MIDI ;
 $tempo = 100 ;
  $settempo = int(60000000/$tempo) ;

  $tracks[0] = MIDI::Track->new( { 'events' => [
    ['time_signature',0,4,2,24],
    ['set_tempo',0,$settempo],
    ['copyright_text_event',0,"Get Thumped Productions, Copyright 2000"],
    ['copyright_text_event',0,"----------------------------------------"],
    ['copyright_text_event',0,"Created by Web Thumper"],
    ['copyright_text_event',0,"http://www.webthumper.com/drums"],
    ['copyright_text_event',0,"thumper\@webthumper.com"],
    ['track_name',0,'WebThumper'],
    ['patch_change',0,9,0],
    ['control_change',0,9,6,100],
  ] } ) ;
  $tracks[1] = MIDI::Track->new ;

 $nindex = 0 ;
 $dbeat = 0 ;

 $drum{'ss'}  = [ 46, 'Side Stick' ] ;
 $note{'q'}    = [ 40,  20, 96,  384  ] ; # quarter

 $x = 4 ;
 while( $x ) {
  $notes[$nindex] =
['note_on',$dbeat,9,$MIDI::percussion2notenum{$drum{'ss'}[1]},100] ;
  $nindex++ ;
  $notes[$nindex] =
['note_off',0,9,$MIDI::percussion2notenum{$drum{'ss'}[1]},0] ;
  $nindex++ ;
    $dbeat = $note{'q'}[3] ;
  $x-- ;
 }

  $tracks[1]->events( @notes ) ;
  $midi1 = MIDI::Opus->new( { 'format'=>1, 'ticks'=>384, 'tracks'=> [
@tracks ] } ) ;
  $midi1->write_to_file("f:/test1.mid") ;

  $notes[$nindex] = ['note_on',384,9,0,0] ; $nindex++ ;
  $notes[$nindex] = ['note_off',0,9,0,0] ; $nindex++ ;
  $notes[$nindex] = ['note_on',0,9,0,0] ; $nindex++ ;
  $notes[$nindex] = ['note_off',0,9,0,0] ; $nindex++ ;
  $notes[$nindex] = ['note_on',0,9,0,0] ; $nindex++ ;
  $notes[$nindex] = ['note_off',0,9,0,0] ; $nindex++ ;
  $notes[$nindex] = ['note_on',0,9,0,0] ; $nindex++ ;
  $notes[$nindex] = ['note_off',0,9,0,0] ; $nindex++ ;
  $notes[$nindex] = ['text_event',48] ;

  $tracks[1]->events( @notes ) ;
  $midi2 = MIDI::Opus->new( { 'format'=>1, 'ticks'=>384, 'tracks'=> [
@tracks ] } ) ;
  $midi2->write_to_file("f:/test2.mid") ;

============================================================
dump.pl

MIDI::Opus->new( {
 "from_file" => $ARGV[0],
 "exclusive_event_callback" =>
  sub{
   print "$MIDI::notenum2percussion{$_[3]}\t" ;
   print "$_[0]  $_[1]  $_[2]  $_[3]  $_[4]\n" ;
  },
 "include" => \@MIDI::Event::All_events
} ) ;

--

Get Thumped Productions / Web Thumper - San Jose, CA USA
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 http://www.webthumper.com ([email protected])
 ICQ: 4133085    AOL: WebThumper
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
iPrint...do you print??    http://www.iPrint.com