/usr/share/perl5/Audio/Nama/Wavinfo_subs.pm is in nama 1.078-2.
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 67 68 69 70 71 72 | # ------- WAV file info routines ---------
package Audio::Nama;
use Modern::Perl;
our (%wav_info);
### WAV file length/format/modify_time are cached in %wav_info
sub ecasound_get_info {
# get information about an audio object
my ($path, $command) = @_;
$path = qq("$path");
teardown_engine();
eval_iam('cs-add gl');
eval_iam('c-add g');
eval_iam('ai-add ' . $path);
eval_iam('ao-add null');
eval_iam('cs-connect');
eval_iam('ai-select '. $path);
my $result = eval_iam($command);
teardown_engine();
$result;
}
sub cache_wav_info {
my @files = File::Find::Rule
->file()
->name( '*.wav' )
->in( this_wav_dir() );
map{ get_wav_info($_) } @files;
}
sub get_wav_info {
my $path = shift;
#say "path: $path";
$wav_info{$path}{length} = get_length($path);
$wav_info{$path}{format} = get_format($path);
$wav_info{$path}{modify_time} = get_modify_time($path);
}
sub get_length {
my $path = shift;
my $length = ecasound_get_info($path, 'ai-get-length');
sprintf("%.4f", $length);
}
sub get_format {
my $path = shift;
ecasound_get_info($path, 'ai-get-format');
}
sub get_modify_time {
my $path = shift;
my @stat = stat $path;
$stat[9]
}
sub wav_length {
my $path = shift;
update_wav_cache($path);
$wav_info{$path}{length}
}
sub wav_format {
my $path = shift;
update_wav_cache($path);
$wav_info{$path}{format}
}
sub update_wav_cache {
my $path = shift;
return unless get_modify_time($path) != $wav_info{$path}{modify_time};
say qq(WAV file $path has changed! Updating cache.);
get_wav_info($path)
}
1;
__END__
|