GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Wav::Write(3) User Contributed Perl Documentation Wav::Write(3)

Audio::Wav::Write - Module for writing Microsoft WAV files.

    use Audio::Wav;

    my $wav = new Audio::Wav;

    my $sample_rate = 44100;
    my $bits_sample = 16;

    my $details = {
        'bits_sample'   => $bits_sample,
        'sample_rate'   => $sample_rate,
        'channels'      => 1,
        # if you'd like this module not to use a write cache, uncomment the next line
        #'no_cache'     => 1,

    };

    my $write = $wav -> write( 'testout.wav', $details );

    &add_sine( 200, 1 );

    sub add_sine {
        my $hz = shift;
        my $length = shift;
        my $pi = ( 22 / 7 ) * 2;
        $length *= $sample_rate;
        my $max_no =  ( 2 ** $bits_sample ) / 2 - 1;
        for my $pos ( 0 .. $length ) {
            $time = $pos / $sample_rate;
            $time *= $hz;
            my $val = sin $pi * $time;
            my $samp = $val * $max_no;
            $write -> write( $samp );
        }
    }

    $write -> finish();

Currently only writes to a file.

Audio::Wav

Audio::Wav::Read

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

Finishes off & closes the current wav file.

    $write -> finish();

Adds a cue point to the wav file. If $sample is undefined then the position will be the current position (end of all data written so far).

    # $byte_offset for 01 compatibility mode
    $write -> add_cue( $sample, "label", "note"  );

All parameters are optional.

    my %info = (
        'midi_pitch_fraction' => 0,
        'smpte_format'        => 0,
        'smpte_offset'        => 0,
        'product'             => 0,
        'sample_period'       => 0,
        'manufacturer'        => 0,
        'sample_data'         => 0,
        'midi_unity_note'     => 65,
    );
    $write -> set_sampler_info( %info );

All parameters are optional except start & end.

    my $length = $read -> length_samples();
    my( $third, $twothirds ) = map int( $length / $_ ), ( 3, 1.5 );
    my %loop = (
        'start'                 => $third,
        'end'                   => $twothirds,
        'fraction'              => 0,
        'type'                  => 0,
    );
    $write -> add_sampler_loop( %loop );

Sets information to be contained in the wav file.

    $write -> set_info( 'artist' => 'Nightmares on Wax', 'name' => 'Mission Venice' );

Returns the current filename.

    my $file = $write -> file_name();

Adds a sample to the current file.

    $write -> write( @sample_channels );

Each element in @sample_channels should be in the range of;

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

Adds some pre-packed data to the current file.

    $write -> write_raw( $data, $data_length );

Where;

    $data is the packed data
    $data_length (optional) is the length in bytes of the data

Adds some pre-packed data to the current file, returns number of samples written.

    $write -> write_raw_samples( $data, $data_length );

Where;

    $data is the packed data
    $data_length (optional) is the length in bytes of the data

    Nick Peskett (see http://www.peskett.co.uk/ for contact details).
    Kurt George Gjerde <kurt.gjerde@media.uib.no>. (0.02-0.03)
2014-04-27 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.