#!/usr/bin/perl -s our($o,$br,$font,$m,$v,$aout); use strict; my $a=shift; my ($pl,$br); $br="-RS" unless $br; ## by default it uses MIDI ratio 3 1 if($aout) { $aout="--aout=$aout" } elsif(not system("pulseaudio --check")) { $aout="--aout=alsa" } else { $aout="--aout=jack" } my @sf2dir=qw( . /usr/share/soundfonts/sf2 /usr/share/soundfonts /usr/share/sounds/sf2 /share/soundfonts ); my $basesf2= 'FluidR3_GM.sf2'; for(@sf2dir){ next unless -d $_; if(-f "$_/$basesf2"){ $font ||= "$_/$basesf2"; print "Debug: $font\n" } } die("Cant find basefont (try to install $basesf2...where is it?)\n") unless $font; my @n=(@ARGV); if(@n){ if($n[0] eq "all"){ @n=(); open(F,"<",$a); while(){ if(/^X:\s*(\d+)/){ push(@n,$1)} }; close F; } for(@n){ system("abc2midi '$a' $_ $br -NFER -o /tmp/_$_.mid"); $pl .= " /tmp/_$_.mid";} } elsif($a=~ /\.abc$/) { system("abc2midi '$a' $br -NFER -o /tmp/_1.mid"); $pl .= " /tmp/_1.mid"; } elsif($a=~ /\.mid$/) { system("cp $a /tmp/_1.mid"); $pl .= " /tmp/_1.mid"; } if($o){ system("fluidsynth $font $pl -F $o" ); } elsif($m) { system("mplayer -really-quiet $pl" ); } elsif($v) { system("vlc $aout -q --play-and-exit $pl" ); } else { system("cvlc $aout -q --play-and-exit $pl"); } # testar:("fluidsynth -ni /usr/share/soundfonts/FluidR3_GM.sf2 $pl -F $o"); # timidity -ig /tmp/_1.mid & __END__ =encoding utf8 =head1 NAME abcm - play abc music =head1 SYNOPSIS abcm file.abc -- first tune abcm file.abc tuneid* -- midi with provided ids abcm file.abc all -- midi with all tunes =head1 DESCRIPTION play abc music (abc -> midi -> cvcv) =head2 Options by default it uses MIDI ratio 3 1 (abc2mid -RS). -br to use MIDI ratio 2 1 (abc2midi default) -o=out.wav (using fluidsynth) -font=/place/of/my/font.sf2 (define soundfont; def:FluidR3_GM.sf2) =head2 EXPORT =head2 Dependencies abc2midi fluidsynth vlc cvlv =head1 AUTHOR J.Joao Almeida, jj@di.uminho.pt =head1 SEE ALSO perl(1). =head2 Configuration... in fedora: ln -s /usr/share/soundfonts /usr/share/sounds/sf2 =cut __END__