This file is indexed.

/usr/share/perl5/Audio/Wav.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
package Audio::Wav;

use strict;
eval { require warnings; }; #it's ok if we can't load warnings

use Audio::Wav::Tools;

use vars qw( $VERSION );
$VERSION = '0.12';

BEGIN {

    eval { require Inline::C };
    if($@) {
        $Audio::Wav::_has_inline = 0;
    } else {
        # Inline::C is confused with multiple import calls - it seems to 
        # result in errors about @INC. hack around this by launching a
        # seperate process instead of simply checking $@ after:
        #   eval { Inline->import(C => "int foo() { return 0; }\n"); };
        my $inline_c_ok = `$^X -e "require Inline::C; eval { Inline->import(C => q[int foo() { return 0; }]) }; print \\\$\@ ? 0 : 1"`;
        if($inline_c_ok) {
            $Audio::Wav::_has_inline = 1;
        } else {
            warn "Inline::C installed, but your C compiler doesn't seem to work with it\n";
            $Audio::Wav::_has_inline = 0;
        }
    }

}

=head1 NAME

Audio::Wav - Modules for reading & writing Microsoft WAV files.

=head1 SYNOPSIS

    # copying a file and adding some cue points to the output file
    use Audio::Wav;
    my $wav = new Audio::Wav;
    my $read = $wav -> read( 'input.wav' );
    my $write = $wav -> write( 'output.wav', $read -> details() );
    print "input is ", $read -> length_seconds(), " seconds long\n";

    $write -> set_info( 'software' => 'Audio::Wav' );
    my $data;
    #read 512 bytes
    while ( defined( $data = $read -> read_raw( 512 ) ) ) {
        $write -> write_raw( $data );
    }
    my $length = $read -> length_samples();
    my( $third, $half, $twothirds ) = map int( $length / $_ ), ( 3, 2, 1.5 );
    my %samp_loop = (
        'start' => $third,
        'end'   => $twothirds,
    );
    $write -> add_sampler_loop( %samp_loop );
    $write -> add_cue( $half, "cue label 1", "cue note 1" );
    $write -> finish();


    # splitting a multi-channel file to separate mono files (slowly!);
    use Audio::Wav;
    my $read = $wav -> read( '4ch.wav' );
    my $details = $read -> details();
    my %out_details = map { $_ => $details -> {$_} } 'bits_sample', 'sample_rate';
    $out_details{'channels'} = 1;
    my @out_files;
    my $in_channels = $details -> {'channels'};
    foreach my $channel ( 1 .. $in_channels ) {
        push @out_files, $wav -> write( 'multi_' . $channel . '.wav', \%out_details );
    }

    while ( 1 ) {
        my @channels = $read -> read();
        last unless @channels;
        foreach my $channel_id ( 0 .. $#channels ) {
            $out_files[$channel_id] -> write( $channels[$channel_id] );
        }
    }

    # not entirely necessary as finish is done in DESTROY now (if the file hasn't been finished already).
    foreach my $write ( @out_files ) {
        $write -> finish();
    }


=head1 NOTES

All sample positions are now in sample offsets (unless option '.01compatible' is true).

There is now *very* basic support for WAVEFORMATEXTENSIBLE (in fact it only recognises that the file is in this format).
The key 'wave-ex' is used in the detail hash to denote this format when reading or writing.
I'd like to do more with this, but don't have any hardware or software to test these files, also don't really have any spare time to do the implementation at present.

One day I plan to learn enough C to do the sample reading/ writing in XS, but for the time being it's done using pack/ unpack in Perl and is slow.
Working with the raw format doesn't suffer in this way.

It's likely that reading/ writing files with bit-depth greater than 16 won't work properly, I need to look at this at some point.

=head1 DESCRIPTION

These modules provide a method of reading & writing uncompressed Microsoft WAV files.

=head1 SEE ALSO

    L<Audio::Wav::Read>

    L<Audio::Wav::Write>

=head1 METHODS

=head2 new

Returns a blessed Audio::Wav object.
All the parameters are optional and default to 0

    my %options = (
        '.01compatible'   => 0,
        'oldcooledithack' => 0,
        'debug'           => 0,
    );
    my $wav = Audio::Wav -> new( %options );

=cut

sub new {
    my ($class, @args) = @_;
    my $tools = Audio::Wav::Tools -> new( @args );
    my $self = {
        'tools' => $tools,
    };
    bless $self, $class;
    return $self; 
}

=head2 write

Returns a blessed Audio::Wav::Write object.

    my $details = {
        'bits_sample'	=> 16,
        'sample_rate'	=> 44100,
        'channels'	=> 2,
    };

    my $write = $wav -> write( 'testout.wav', $details );
    my $write = Audio::Wav -> write( 'testout.wav', $details);
    my $write = Audio::Wav -> write( 'testout.wav', $details, %options );

where %options is in the form of arguments for L<Audio::Wav::Tools>.

See L<Audio::Wav::Write> for methods.

=cut

sub write {
    my ($self, $file, $details, @args) = @_;
    require Audio::Wav::Write;
    my $write;
    if(ref $self) {
        $write = Audio::Wav::Write -> new( $file, $details, $self -> {'tools'} );
    } else {
        $write = Audio::Wav::Write -> new( $file, Audio::Wav::Tools -> new( @args ) );
    }
    return $write; 
}

=head2 read

Returns a blessed Audio::Wav::Read object.

    my $read = $wav -> read( 'testin.wav' );
    my $read = Audio::Wav -> read( 'testin.wav' );
    my $read = Audio::Wav -> read( 'testin.wav', %options );

where %options is in the form of arguments for L<Audio::Wav::Tools>.

See L<Audio::Wav::Read> for methods.

=cut

sub read {
    my ($self, $file, @args) = @_;
    require Audio::Wav::Read;
    my $read;
    if(ref $self) {
        $read = Audio::Wav::Read -> new( $file, $self -> {'tools'} );
    } else {
        $read = Audio::Wav::Read -> new( $file, Audio::Wav::Tools -> new( @args ) );
    }
    return $read; 
}


=head2 set_error_handler

Specifies a subroutine for catching errors.
The subroutine should take a hash as input. The keys in the hash are 'filename', 'message' (error message), and 'warning'.
If no error handler is set, die and warn will be used.

    sub myErrorHandler {
        my( %parameters ) = @_;
        if ( $parameters{'warning'} ) {
            # This is a non-critical warning
            warn "Warning: $parameters{'filename'}: $parameters{'message'}\n";
        } else {
            # Critical error!
            die "ERROR: $parameters{'filename'}: $parameters{'message'}\n";
        }
    }
    $wav -> set_error_handler( \&myErrorHandler );


=cut

sub set_error_handler {
    my ($self, @args) = @_;
    $self -> {'tools'} -> set_error_handler( @args );
}

=head1 COPYRIGHT

    Copyright (c) 2007,2010 Brian Szymanski <brianski@cpan.org>
    Copyright (c) 1998-2006 Nick Peskett <npeskett@cpan.org> 
    Copyright (c) 2001 Kurt George Gjerde <KJERDE@cpan.org>

=head1 AUTHORS

    Nick Peskett (see http://www.peskett.co.uk/ for contact details).
    Brian Szymanski <ski-cpan@allafrica.com> (0.07-0.12)
    Wolfram humann (pureperl 24 and 32 bit read support in 0.09)
    Kurt George Gjerde <kurt.gjerde@media.uib.no>. (0.02-0.03)

=cut

1;
__END__