Audio::SoundFile::Reader - Reader class for various sound formats


Audio-SoundFile documentation Contained in the Audio-SoundFile distribution.

Index


Code Index:

NAME

Top

 Audio::SoundFile::Reader - Reader class for various sound formats

SYNOPSIS

Top

 use IO::Seekable;
 use Audio::SoundFile;

 $reader = new Audio::SoundFile::Reader($source, \$header);

 $length = $reader->bread_raw(\$buffer, $wanted);
 $length = $reader->bread_pdl(\$buffer, $wanted);

 $reader->fseek(1024, SEEK_SET);
 $reader->fseek(1024, SEEK_CUR);
 $reader->fseek(1024, SEEK_END);

 $reader->close;

DESCRIPTION

Top

This module provides an interface to read various sound formats supported by libsndfile.

In addition to usual I/O interface, it provides direct interface to create PDL object without making a copy of data in pure-Perl space. This is an advantage on both speed and memory, and is a recommended way to manipulate sound data.

Currently supported methods are:

$reader = new Audio::SoundFile::Reader($source, \$header);

Constructor. Returns input stream object that reads from given source.

Also assigns header information read from the source to passed scalar reference.

$reader->close;

Closes input stream. This object will be unusable after this method is called.

$offset = $reader->fseek($offset, $whence);

Moves next reading position to a point where specified by $offset and $whence. Note $offset is not a length in bytes, but a number of frames to skip (frame is a block of data containing data of all channels at given moment).

Return value (which should be a new position in number of frames) is currently unreliable.

$offset = $reader->bseek($offset, $whence);

Moves next reading position to a point where specified by $offset and $whence. Note $offset is not a length in bytes, but a number of blocks to skip (block is a bulk of data containing data of single channel at given moment).

Return value (which should be a new position in number of blocks) is currently unreliable.

$length = $reader->bread_raw(\$buffer, $wanted);

Reads $wanted blocks of data, and stores it to $buffer as a Perl scalar. Content of $buffer is not guranteed on error.

Returns length of the data actually stored, or 0 (or lesser value) on error.

$length = $reader->bread_pdl(\$buffer, $wanted);

Reads $wanted blocks of data, and stores it to $buffer as a PDL object. Content of $buffer is not guranteed on error.

Returns length of the data actually stored, or 0 (or lesser value) on error.

NOTES

Top

If you mix bseek/bread and fseek/fread, things might get confusing due to shift in internal offset - please do it with your responsibility.

AUTHORS / CONTRIBUTORS

Top

Taisuke Yamada <tai@imasy.or.jp>

COPYRIGHT

Top


Audio-SoundFile documentation Contained in the Audio-SoundFile distribution.
# -*- mode: perl -*-
#
# $Id: Reader.pm,v 1.4 2002/08/21 14:48:27 tai Exp $
#

package Audio::SoundFile::Reader;

use DynaLoader;

use strict;
use vars qw($VERSION @ISA);

$VERSION = (split(/\s+/, q$Revision 1.1$))[1] / 10;
@ISA     = qw(DynaLoader);

use PDL::Core;

bootstrap Audio::SoundFile::Reader $VERSION;

1;