Re: MIDI Simple Help, Read @Notes?

[email protected] (zentara) Sat, 14 Jan 2006 08:30:36 -0500
Newsgroups perl.midi
Message-ID <[email protected]>
On Wed, 30 Nov 2005 14:46:33 -0700, [email protected] (Sigmund Rothschild)
wrote:

>I'm hoping to write a Perl program with MIDI::Simple that would:
>
>1. Read a pre-existing MIDI file. 
>2.  Insert new MIDI note number values (pitch, 0-127) from an array into the pre-existing MIDI file's note on and off events.
>3.  Write the result to a new MIDI file.  

>#How do I access the note values from read_score and assign them the new note numbers?

Hi, I've been using this script to modify lyrics in midi-karaoke
files, maybe it can be applied to notes?
It dumps each track, and if you figure out the meaning of the various
midi control characters, you might be able to change the note played
at any one point.
It writes a file that is in the form of a regenerator script, to
reproduce the new midi file.

For text events, each text fragment is prefixed by a hex value of it's
length, so when you change text, you must change that preceding number
too.  I'm not familiar enough with the midi specs to say what is needed
to change individual note events, but if you find out, please post it.
:-)
#######################################################
#!/usr/bin/perl -w
#Mr. Muskrat of perlmonks.org
use strict;
use MIDI;
for my $midi (@ARGV) {
open(*STDOUT, ">", "$midi.pl");
print <<'EOP';
#!/usr/bin/perl -w
use MIDI;
my $opus =
EOP
my $opus = MIDI::Opus->new({ 'from_file' => $midi, 'no_parse' => 1 });
$opus->dump( { dump_tracks => 1 } );
print "\$opus->write_to_file('$midi');\n";
}
__END__






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