---
name: "Audio::Wav::Read"
section: "3pm"
platform: "linux"
package: "libaudio-wav-perl"
version: "0.14-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Audio::Wav::Read"
---

# Audio::Wav::Read(3pm)

Module for reading Microsoft WAV files.

## NAME

Audio::Wav::Read - Module for reading Microsoft WAV files.

## SYNOPSIS

```
    use Audio::Wav;
    my $wav = new Audio::Wav;
    my $read = $wav -> read( 'filename.wav' );
#OR
    my $read = Audio::Wav -> read( 'filename.wav' );
    my $details = $read -> details();
```

## DESCRIPTION

Reads Microsoft Wav files.

## SEE ALSO

Audio::Wav

Audio::Wav::Write

## NOTES

This module shouldn't be used directly, a blessed object can be returned from Audio::Wav.

## METHODS

### file\_name

Returns the file name.

```
    my $file = $read -> file_name();
```

### get\_info

Returns information contained within the wav file.

```
    my $info = $read -> get_info();
```

Returns a reference to a hash containing; (for example, a file marked up for use in Audio::Mix)

```
    {
        'keywords' => 'bpm:126 key:a',
        'name'     => 'Mission Venice',
        'artist'   => 'Nightmares on Wax'
    };
```

### get\_cues

Returns the cuepoints marked within the wav file.

```
    my $cues = $read -> get_cues();
```

Returns a reference to a hash containing; (for example, a file marked up for use in Audio::Mix) (position is sample position)

```
    {
        1 => {
            label    => 'sig',
            position => 764343,
            note     => 'first',
        },
        2 => {
            label    => 'fade_in',
            position => 1661774,
            note     => 'trig',
        },
        3 => {
            label    => 'sig',
            position => 18033735,
            note     => 'last',
        },
        4 => {
            label    => 'fade_out',
            position => 17145150,
            note     => 'trig',
        },
        5 => {
            label    => 'end',
            position => 18271676,
        }
    }
```

### read\_raw

Reads raw packed bytes from the current audio data position in the file.

```
    my $data = $self -> read_raw( $byte_length );
```

### read\_raw\_samples

Reads raw packed samples from the current audio data position in the file.

```
    my $data = $self -> read_raw_samples( $samples );
```

### read

Returns the current audio data position sample across all channels.

```
    my @channels = $self -> read();
```

Returns an array of unpacked samples. Each element is a channel i.e ( left, right ). The numbers will be in the range;

```
    where $samp_max = ( 2 ** bits_per_sample ) / 2
    -$samp_max to +$samp_max
```

### position

Returns the current audio data position (as byte offset).

```
    my $byte_offset = $read -> position();
```

### position\_samples

Returns the current audio data position (in samples).

```
    my $samples = $read -> position_samples();
```

### move\_to

Moves the current audio data position to byte offset.

```
    $read -> move_to( $byte_offset );
```

### move\_to\_sample

Moves the current audio data position to sample offset.

```
    $read -> move_to_sample( $sample_offset );
```

### length

Returns the number of bytes of audio data in the file.

```
    my $audio_bytes = $read -> length();
```

### length\_samples

Returns the number of samples of audio data in the file.

```
    my $audio_samples = $read -> length_samples();
```

### length\_seconds

Returns the number of seconds of audio data in the file.

```
    my $audio_seconds = $read -> length_seconds();
```

### details

Returns a reference to a hash of lots of details about the file. Too many to list here, try it with Data::Dumper.....

```
    use Data::Dumper;
    my $details = $read -> details();
    print Data::Dumper->Dump([ $details ]);
```

### reread\_length

Rereads the length of the file in case it is being written to as we are reading it.

```
    my $new_data_length = $read -> reread_length();
```

## AUTHORS

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