/usr/share/perl5/Audio/Nama/Wavinfo.pm is in nama 1.208-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 73 74 75 76 77 78 79 80 81 | # ------- WAV file info routines ---------
package Audio::Nama;
use Modern::Perl;
### WAV file length/format/modify_time are cached in $setup->{wav_info}
### Cached methods
sub wav_length {
my $path = shift;
_update_wav_cache($path);
$setup->{wav_info}->{$path}{length}
}
sub wav_format {
my $path = shift;
_update_wav_cache($path);
$setup->{wav_info}->{$path}{format}
}
### Implementation
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";
$setup->{wav_info}->{$path}{length} = _get_length($path);
$setup->{wav_info}->{$path}{format} = _get_format($path);
$setup->{wav_info}->{$path}{modify_time} = _get_modify_time($path);
}
sub _get_length {
my $path = shift;
my $length = ecasound_get_info($path, 'ai-get-length');
$length ? sprintf("%.4f", $length) : undef
}
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 _update_wav_cache {
my $path = shift;
{ no warnings 'uninitialized';
return unless _get_modify_time($path) != $setup->{wav_info}->{$path}{modify_time};
}
throw("WAV file $path has changed! Updating cache.");
_get_wav_info($path)
}
sub ecasound_get_info {
# get information about an audio object
my ($path, $command) = @_;
local $config->{category} = 'ECI_WAVINFO';
$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;
}
1;
__END__
|