#!/usr/local/bin/perl # # postpmx.pl : a postprocessing filter for PMX-output MusiXTeX file # print "a postprocessing filter for PMX-output MusiXTeX file\n"; $file = $ARGV[0]; # filename to be processed if($file eq '') { print "usage: postpmx filename.tex\n"; exit(1); } if(not($file =~ m/.tex$/)){ $file = $file . '.tex'; } if (open (IN, "<$file") == 0) { print "file not open.\n"; exit(1); } print "file: ", $file, "\n"; @in = ; close IN; #foreach $line (@in) { # if($line =~ s/musixmad\n/musixmad\n\\input musixtmr\n\\input musixjfn\n\\input mxfeta\n\\input musixvbm\n/){ # last; # } #} if(@in[0] =~ m/filtered by postpmx/){ print "already filtered by postpmx. nothing to be done.\n"; exit(0); } if(not(@in[0] =~ m/^%%%%%%%%%%%%%%%%%$/)){ print "not a PMX-output MusiXTeX file.\n"; exit(0); } foreach $line (@in) { $line =~ s/(\\vsize.*pt)/$1\n\\voffset-7mm\n\\hoffset-15.4mm/; $line =~ s/\\tracingstats=2//; $line =~ s/\\readmod\{(.*)\}/\\readmod\{\\jobname\}/; $line =~ s/\\stafftopmarg0pt\\staffbotmarg5\\Interligne\\interstaff\{10\}\\relax/\\stafftopmarg3\\Interligne\\staffbotmarg3\\Interligne\\interstaff\{13\}\\relax/; $line =~ s/\\vskip.*eject%\n$//; $line =~ s/\\vfill\\eject%\n$//; $line =~ s/\\interstaff\{(\d*)\.\d\}\\contpiece/\\vskip0pt plus1fil minus2mm\\interstaff\{$1\}\\contpiece%/; $line =~ s/\\alaligne/\\stoppiece\\vskip0pt plus1fil minus2mm\\contpiece%/; $line =~ s/\\vskip\d*.\d*\\Interligne\\eject\\endmuflex/\\vfil\\eject\\endmuflex/; # base=2.1 rate=1.618 $line =~ s/pnotes{5.66}/pnotes{8.90}/g; # whole note $line =~ s/pnotes{4.90}/pnotes{6.99}/g; # dotted half note $line =~ s/pnotes{4.00}/pnotes{5.50}/g; # half note $line =~ s/pnotes{3.46}/pnotes{4.32}/g; # dotted fourth note $line =~ s/pnotes{3.27}/pnotes{ }/g; # half triplet $line =~ s/pnotes{2.83}/pnotes{3.40}/g; # fourth note $line =~ s/pnotes{2.53}/pnotes{ }/g; # fourth pentet $line =~ s/pnotes{2.45}/pnotes{2.67}/g; # dotted eighth note $line =~ s/pnotes{2.31}/pnotes{2.47}/g; # fourth triplet $line =~ s/pnotes{2.00}/pnotes{2.10}/g; # eighth note $line =~ s/pnotes{1.79}/pnotes{ }/g; # eighth pentet $line =~ s/pnotes{1.63}/pnotes{1.52}/g; # eighth triplet $line =~ s/pnotes{1.41}/pnotes{1.30}/g; # sixteenth note $line =~ s/pnotes{1.26}/pnotes{ }/g; # sixteenth pentet # $line =~ s/Setvolta1/setvoltabox1/; # $line =~ s/Setvolta2/setendvolta\\setvolta2/; } foreach $line (@in) {$line =~ s/\\stoppiece%\n$/\\stoppiece/;} # foreach $line (@in) {$line =~ s/\\stoppiece.*\\contpiece/\\alaligne/;} # foreach $line (@in) {$line =~ s/\\xbar/\\xbar%/;} # 2006.11.23 if (open (IN, ">$file") == 0) { print "file cannot be overwrited.\n"; exit(1); } print "overwriting...\n"; print IN "% filtered by postpmx\n"; print IN @in; print "done.\n"; end;