++ed by:
Author image Taisuke Yamada


 Audio::SoundFile::Header - Interface to handle sound format information


 use Audio::SoundFile::Header;

 $header = new Audio::SoundFile::Header(
    samplerate  => 44100,
    channels    => 1,
    format      => SF_FORMAT_WAV | SF_FORMAT_PCM,

 die "Invalid format information" unless $header;
 die "Invalid format information" unless $header->set(channels => 2);
 die "Invalid format information" unless $header->format_check;


This module provides abstract interface to handle sound format information. It manages format information defined by sndfile.h in libsndfile library.

Currently, following methods are provided:

$header = new Audio::SoundFile::Header(%format_info);


Returns a class instance which is initialized by given format information. This automatically does sanity check of the info, and returns undef if the format structure is invalid.

$value = $header->get($name);

Returns a value that corresponds with given parameter name.

$value = $header->set($name => $value, $name => $value, ...);

Sets a value for given parameter name.

If new format structure is invalid (contradicting parameters, etc), it discards all information passed, and returns an error. Original structure is retained in that case.

Returns true on success, otherwise false.

$bool = $header->format_check;

Runs sanity check on the format structure. Returns true if format is valid, otherwise false.


Taisuke Yamada <tai@imasy.or.jp>


Copyright (C) 2001. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.