/usr/share/perl5/Audio/Wav/Tools.pm is in libaudio-wav-perl 0.12-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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | package Audio::Wav::Tools;
use strict;
eval { require warnings; }; #it's ok if we can't load warnings
use vars qw( $VERSION );
$VERSION = '0.12';
sub new {
my ($class, %options) = @_;
my $self = {
'errorHandler' => undef,
};
foreach my $key ( qw( .01compatible oldcooledithack debug ) ) {
$self -> {$key} = exists( $options{$key} ) && $options{$key} ? 1 : 0;
}
bless $self, $class;
return $self;
}
sub is_debug {
my $self = shift;
return $self -> {'debug'};
}
sub is_01compatible {
my $self = shift;
return $self -> {'.01compatible'};
}
sub is_oldcooledithack {
my $self = shift;
return $self -> {'oldcooledithack'};
}
sub set_error_handler {
my $self = shift;
my $handler = shift;
unless ( ref( $handler ) eq 'CODE' ) {
die 'set_error_handler is expecting a reference to a sub routine';
}
$self -> {'errorHandler'} = $handler;
}
sub is_big_endian {
my $self = shift;
return $self -> {'is_big_endian'} if exists $self -> {'is_big_endian'};
my $VALUE = 1801677134;
my $nativeLong = pack 'L', $VALUE; # 'kciN' (big) or 'Nick' (little)
my $bigLong = pack 'N', $VALUE; # should return 'kciN'
$self -> {'is_big_endian'} = $nativeLong eq $bigLong ? 1 : 0;
return $self -> {'is_big_endian'};
}
sub get_info_fields {
return (
'IARL' => 'archivallocation',
'IART' => 'artist',
'ICMS' => 'commissioned',
'ICMT' => 'comments',
'ICOP' => 'copyright',
'ICRD' => 'creationdate',
'IENG' => 'engineers',
'IGNR' => 'genre',
'IKEY' => 'keywords',
'IMED' => 'medium',
'INAM' => 'name',
'IPRD' => 'product',
'ISBJ' => 'subject',
'ISFT' => 'software',
'ISRC' => 'supplier',
'ISRF' => 'source',
'ITCH' => 'digitizer',
);
}
sub get_rev_info_fields {
my $self = shift;
return %{ $self -> {'rev_info_fields'} } if exists $self -> {'rev_info_fields'};
my %info_fields = $self -> get_info_fields();
my %rev_info;
foreach my $key ( keys %info_fields ) {
$rev_info{ $info_fields{$key} } = $key;
}
$self -> {'rev_info_fields'} = \%rev_info;
return %rev_info;
}
sub get_sampler_fields {
# dwManufacturer dwProduct dwSamplePeriod dwMIDIUnityNote dwMIDIPitchFraction dwSMPTEFormat dwSMPTEOffset cSampleLoops cbSamplerData
# <sample-loop(s)> <sampler-specific-data> ) <sample-loop> struct dwIdentifier; dwType; dwStart; dwEnd; dwFraction; dwPlayCount;
return (
'fields' => [ qw( manufacturer product sample_period midi_unity_note midi_pitch_fraction smpte_format smpte_offset sample_loops sample_data ) ],
'loop' => [ qw( id type start end fraction play_count ) ],
'extra' => [],
# 'extra' => [ map 'unknown' . $_, 1 .. 3 ],
);
}
sub get_sampler_defaults {
return (
'midi_pitch_fraction' => 0,
'smpte_format' => 0,
'smpte_offset' => 0,
'product' => 0,
'sample_period' => 0, # 22675,
'manufacturer' => 0,
'sample_data' => 0,
'midi_unity_note' => 65
);
}
sub get_sampler_loop_defaults {
return (
'fraction' => 0,
'type' => 0
);
}
sub error {
my $self = shift;
my $filename = shift;
my $msg = shift;
my $type = shift;
my $handler = $self -> {'errorHandler'};
if ( $handler ) {
my %hash = (
'filename' => $filename,
'message' => $msg ? $msg : '',
);
$hash{'warning'} = 1 if $type eq 'warn';
&$handler( %hash );
} else {
my $txt = $filename ? "$filename: $msg\n" : "$msg\n";
if ( $type && $type eq 'warn' ) {
warn $txt;
} else {
die $txt;
}
}
return;
}
sub get_wav_pack {
my $self = shift;
return {
'order' => [ qw( format channels sample_rate bytes_sec block_align bits_sample ) ],
'types' => {
'format' => 'v',
'channels' => 'v',
'sample_rate' => 'V',
'bytes_sec' => 'V',
'block_align' => 'v',
'bits_sample' => 'v',
},
};
}
1;
|