MIDI Simple Help, Read @Notes?
[email protected] ("Sigmund Rothschild") Wed, 30 Nov 2005 14:46:33 -0700
| Newsgroups | perl.midi |
|---|---|
| Message-ID | <00a501c5f5f7$87f16a80$6500a8c0@sigef502ced399> |
------=_NextPart_000_00A2_01C5F5BC.DB62F700 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I'm hoping to write a Perl program with MIDI::Simple that would: 1. Read a pre-existing MIDI file.=20 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. =20 I completed another project with the MIDI module and have found it to = be really great. I read Sean Burke's paper "Perl and MIDI: Simple = Languages, Easy Music" online, went through the archive at = http://www.nntp.perl.org/group/perl.midi, and looked at the the PODs on = the Cpan, and I'm stumped. There are critical pieces of information = that I am missing, as I am new to Perl and OOP. I have tried three = different approaches and have not been able to make any of them work. = Mainly, I don't understand how to write the new values to the array or = hash that is holding the MIDI note events, @Notes, as I can't access = them. =20 Any help to get the snippet below to work would be greatly appreciated. -Sig #!/System/Library/Perl #try_MIDI_simple_write-1.plx use warnings; use strict; use MIDI::Simple; new_score; my $obj =3D read_score($ARGV[0]); #How do I access the note values from read_score and assign them the new = note numbers? my $notes_r; my @old_notes; $notes_r =3D $obj->Notes_r; ##From Cpan MIDI::Simple POD # to read: @old_notes =3D @$notes_r; # to write: @$notes_r =3D (13,17,22); $notes_r =3D $obj->Notes_r; ##To Set? @$notes_r =3D (); write_score 'Changed_Notes.mid'; ------=_NextPart_000_00A2_01C5F5BC.DB62F700 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2900.2769" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>I'm hoping to write a Perl program with = MIDI::Simple that would:</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>1. Read a pre-existing MIDI file. = <BR>2. =20 Insert new MIDI note number values (pitch, 0-127) from an array into the = pre-existing MIDI file's note on and off events.<BR>3. Write the = result to=20 a new MIDI file. </FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>I completed another project with the = MIDI module=20 and have found it to be really great. I read Sean Burke's = paper=20 "Perl and MIDI: Simple Languages, Easy Music" online, went through the = archive=20 at <A=20 href=3D"http://www.nntp.perl.org/group/perl.midi">http://www.nntp.perl.or= g/group/perl.midi</A>,=20 and looked at the the PODs on the Cpan, and I'm stumped. There are = critical pieces of information that I am missing, as I am new to Perl = and=20 OOP. I have tried three different approaches and have not been = able to=20 make any of them work. Mainly, I don't understand how to write the = new=20 values to the array or hash that is holding the MIDI note events, = @Notes, as I=20 can't access them. </FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Any help to get the snippet below to = work would be=20 greatly appreciated.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>-Sig</FONT></DIV> <DIV> </DIV><FONT face=3DArial size=3D2> <DIV><BR>#!/System/Library/Perl<BR>#try_MIDI_simple_write-1.plx<BR>use=20 warnings;<BR>use strict;<BR>use MIDI::Simple;</DIV> <DIV> </DIV> <DIV><BR>new_score;<BR>my $obj =3D read_score($ARGV[0]);</DIV> <DIV> </DIV> <DIV>#How do I access the note values from read_score and assign them = the new=20 note numbers?</DIV> <DIV> </DIV> <DIV>my $notes_r;<BR>my @old_notes;</DIV> <DIV> </DIV> <DIV>$notes_r =3D $obj->Notes_r; ##From Cpan MIDI::Simple = POD<BR># to=20 read:<BR>@old_notes =3D @$notes_r;<BR># to write:<BR>@$notes_r =3D = (13,17,22);</DIV> <DIV> </DIV> <DIV>$notes_r =3D $obj->Notes_r; ##To Set?<BR>@$notes_r =3D = ();</DIV> <DIV> </DIV> <DIV>write_score 'Changed_Notes.mid';</FONT></DIV></BODY></HTML> ------=_NextPart_000_00A2_01C5F5BC.DB62F700--