/usr/share/perl5/Audio/Nama/Midi_subs.pm is in nama 1.078-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # ------------- MIDI routines -----------
package Audio::Nama;
use Modern::Perl;
use Carp;
{
my($error,$answer)=('','');
my ($pid, $sel);
sub start_midish {
my $executable = qx(which midish);
chomp $executable;
$executable or say("Midish not found!"), return;
$pid = open3(\*MIDISH_WRITE, \*MIDISH_READ,\*MIDISH_ERROR,"$executable -v")
or warn "Midish failed to start!";
$sel = new IO::Select();
$sel->add(\*MIDISH_READ);
$sel->add(\*MIDISH_ERROR);
midish_command( qq(print "Welcome to Nama/Midish!"\n) );
}
sub midish_command {
my $query = shift;
print "\n";
#$midish_enable or say( qq($query: cannot execute Midish command
#unless you set "midish_enable: 1" in .namarc)), return;
#$query eq 'exit' and say("Will exit Midish on closing Nama."), return;
#send query to midish
print MIDISH_WRITE "$query\n";
foreach my $h ($sel->can_read)
{
my $buf = '';
if ($h eq \*MIDISH_ERROR)
{
sysread(MIDISH_ERROR,$buf,4096);
if($buf){print "MIDISH ERR-> $buf\n"}
}
else
{
sysread(MIDISH_READ,$buf,4096);
if($buf){map{say "MIDISH-> $_"} grep{ !/\+ready/ } split "\n", $buf}
}
}
print "\n";
}
sub close_midish {
midish_command('exit');
sleeper(0.1);
kill 15,$pid;
sleeper(0.1);
kill 9,$pid;
sleeper(0.1);
waitpid($pid, 1);
# It is important to waitpid on your child process,
# otherwise zombies could be created.
}
}
1;
__END__
|