Audio::File::AudioProperties - abstract an audio files audio properties.


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

Index


Code Index:

NAME

Top

Audio::File::AudioProperties - abstract an audio files audio properties.

DESCRIPTION

Top

Audio::File::AudioProperties is the base class for other file format independant audio property classes like Audio::File::Flac::AudioProperties or Audio::File::Ogg::AudioProperties. You should not use this class yourself exept you're writing an own file format dependant subclass.

METHODS

Top

new

Constructor. Creates new Audio::File::AudioProperties object. You shoud not use this method yourself. It's called by the filetype-dependant subclasses of Audio::File::Type automatically.

init

Initializes the object. It's called by the constructor and empty by default. It's ought to be overwritten by subclasses.

length

Returns the length of the audio file in seconds.

bitrate

Returns the bitrate of the file.

sample_rate

Returns the sample rate of the audio file.

channels

Returns the number of channels the audio file has.

all

Get all audio properties.

SEE ALSO

Top

Audio::File, Audio::File::Type, Audio::File::Tag

AUTHOR

Top

Florian Ragwitz <flora@cpan.org>

COPYRIGHT AND LICENSE

Top


Audio-File documentation Contained in the Audio-File distribution.
package Audio::File::AudioProperties;

use strict;
use warnings;

our $VERSION = '0.02';

sub new {
	my($class, $filename) = @_;
	$class = ref $class || $class;
	my $self = { filename => $filename };
	bless $self, $class;
	$self->init(@_) or return;
	return $self;
}

sub init {

}

sub length {
	my $self = shift;
	if( @_ ) {
		$self->{length} = shift;
		return 1;
	}

	return int $self->{length};
}

sub bitrate {
	my $self = shift;
	if( @_ ) {
		$self->{bitrate} = shift;
		return 1;
	}

	return int $self->{bitrate};
}

sub sample_rate {
	my $self = shift;
	if( @_ ) {
		$self->{sample_rate} = shift;
		return 1;
	}

	return $self->{sample_rate};
}

sub channels {
	my $self = shift;
	if( @_ ) {
		$self->{channels} = shift;
		return 1;
	}

	return $self->{channels};
}

sub all {
	my $self = shift;

	if (@_) {
		my $props = shift;
		$self->$_($props->{$_}) for keys %{$props};
		return 1;
	}

	return {
		length		=> $self->length(),
		bitrate		=> $self->bitrate(),
		sample_rate	=> $self->sample_rate(),
		channels	=> $self->channels()
	};
}

1;