r21167 - in /branches/upstream/libaudio-file-perl: ./ current/ current/lib/ current/lib/Audio/ current/lib/Audio/File/ current/lib/Audio/File/Flac/ current/lib/Audio/File/Mp3/ current/lib/Audio/File/Ogg/ current/t/

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Sun Jun 15 13:13:28 UTC 2008


Author: gregoa
Date: Sun Jun 15 13:13:28 2008
New Revision: 21167

URL: http://svn.debian.org/wsvn/?sc=1&rev=21167
Log:
[svn-inject] Installing original source of libaudio-file-perl

Added:
    branches/upstream/libaudio-file-perl/
    branches/upstream/libaudio-file-perl/current/
    branches/upstream/libaudio-file-perl/current/Changes
    branches/upstream/libaudio-file-perl/current/MANIFEST
    branches/upstream/libaudio-file-perl/current/META.yml
    branches/upstream/libaudio-file-perl/current/Makefile.PL
    branches/upstream/libaudio-file-perl/current/README
    branches/upstream/libaudio-file-perl/current/lib/
    branches/upstream/libaudio-file-perl/current/lib/Audio/
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/
    branches/upstream/libaudio-file-perl/current/lib/Audio/File.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/AudioProperties.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac/
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac/AudioProperties.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac/Tag.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3/
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3/AudioProperties.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3/Tag.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg/
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg/AudioProperties.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg/Tag.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Tag.pm
    branches/upstream/libaudio-file-perl/current/lib/Audio/File/Type.pm
    branches/upstream/libaudio-file-perl/current/t/
    branches/upstream/libaudio-file-perl/current/t/Audio-File.t
    branches/upstream/libaudio-file-perl/current/t/test.flac   (with props)
    branches/upstream/libaudio-file-perl/current/t/test.mp3   (with props)
    branches/upstream/libaudio-file-perl/current/t/test.ogg   (with props)

Added: branches/upstream/libaudio-file-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/Changes?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/Changes (added)
+++ branches/upstream/libaudio-file-perl/current/Changes Sun Jun 15 13:13:28 2008
@@ -1,0 +1,42 @@
+Revision history for Perl extension Audio::File.
+
+0.11  Fri Aug 25 15:21:22 2006
+	- Fix a test failure in the mp3 tag tests.
+
+0.10  Mon Feb 28 16:03:12 2005
+	- Better test suite.
+	- Added Audio::File::Tag::all().
+	- Added Audio::File::AudioProperties::all().
+	- Audio::FLAC -> Audio::FLAC::Header.
+
+0.09  Fri Feb 18 00:20:08 2005
+	- Fixed README.
+	- Removed 'use 5.008004;' from Makefile.PL.
+	- Added test suite.
+	- Added Audio::File::Tag::total().
+
+0.08  Tue Sep 14 07:45:37 2004
+	- Fixed problems when loading type-secific plugins using eval in File.pm.
+
+0.06  Mon Aug 30 01:24:26 2004
+	- Added a better description.
+
+0.05  Sat Aug 21 01:31:12 2004
+	- yet another damn typo! I really should start testing *before* releasing a
+	  new version..
+
+0.04  Sat Aug 21 01:25:32 2004
+	- fixed typos of previous fix.
+
+0.03  Sat Aug 21 01:18:45 2004
+	- fixed Mp3 suppport.
+
+0.02  Thu Aug  5 19:02:21 2004
+	- fixed README.
+
+0.01  Wed Aug  4 15:58:39 2004
+	- original version; created by h2xs 1.23 with options
+		-AXO -n Audio::File
+	- implemented basic functionality of reading tags and audio properties for
+	  Flac, Ogg and MP3.
+

Added: branches/upstream/libaudio-file-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/MANIFEST?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/MANIFEST (added)
+++ branches/upstream/libaudio-file-perl/current/MANIFEST Sun Jun 15 13:13:28 2008
@@ -1,0 +1,22 @@
+Changes
+Makefile.PL
+MANIFEST
+META.yml
+README
+t/Audio-File.t
+t/test.flac
+t/test.mp3
+t/test.ogg
+lib/Audio/File.pm
+lib/Audio/File/AudioProperties.pm
+lib/Audio/File/Flac.pm
+lib/Audio/File/Flac/Tag.pm
+lib/Audio/File/Flac/AudioProperties.pm
+lib/Audio/File/Mp3.pm
+lib/Audio/File/Mp3/Tag.pm
+lib/Audio/File/Mp3/AudioProperties.pm
+lib/Audio/File/Ogg.pm
+lib/Audio/File/Ogg/Tag.pm
+lib/Audio/File/Ogg/AudioProperties.pm
+lib/Audio/File/Tag.pm
+lib/Audio/File/Type.pm

Added: branches/upstream/libaudio-file-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/META.yml?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/META.yml (added)
+++ branches/upstream/libaudio-file-perl/current/META.yml Sun Jun 15 13:13:28 2008
@@ -1,0 +1,14 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Audio-File
+version:      0.11
+version_from: lib/Audio/File.pm
+installdirs:  site
+requires:
+    Audio::FLAC::Header:           0
+    MP3::Info:                     0
+    MP3::Tag:                      0
+    Ogg::Vorbis::Header::PurePerl: 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30_01

Added: branches/upstream/libaudio-file-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/Makefile.PL?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/Makefile.PL (added)
+++ branches/upstream/libaudio-file-perl/current/Makefile.PL Sun Jun 15 13:13:28 2008
@@ -1,0 +1,16 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+    NAME              => 'Audio::File',
+    VERSION_FROM      => 'lib/Audio/File.pm', # finds $VERSION
+    PREREQ_PM         => {
+			'Audio::FLAC::Header'			=> 0,
+			'Ogg::Vorbis::Header::PurePerl'	=> 0,
+			'MP3::Info'						=> 0,
+			'MP3::Tag'						=> 0,
+	}, # e.g., Module::Name => 1.1
+    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
+      (ABSTRACT_FROM  => 'lib/Audio/File.pm', # retrieve abstract from module
+       AUTHOR         => 'Florian Ragwitz <flora at cpan.org>') : ()),
+);

Added: branches/upstream/libaudio-file-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/README?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/README (added)
+++ branches/upstream/libaudio-file-perl/current/README Sun Jun 15 13:13:28 2008
@@ -1,0 +1,39 @@
+Audio-File version 0.11
+=======================
+
+INSTALLATION
+
+To install this module type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+DEPENDENCIES
+
+This module requires these other modules and libraries:
+
+  Audio::FLAC
+  Ogg::Vorbis::Header::PurePerl
+  MP3::Tag
+  MP3::Info
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2004 by Florian Ragwitz
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Library General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,117 @@
+package Audio::File;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.11';
+
+=head1 NAME
+
+Audio::File - Audio file abstraction library
+
+=head1 SYNOPSIS
+
+  use Audio::File;
+  my $file = Audio::File->new( "foo.bar" );
+
+  print "The ". $file->type() ."-file ". $file->name
+  		." is ". int $file->length() ." seconds long.\n";
+
+  print "It's interpreted by ". $file->tag->artist()
+  		." and called ". $file->tag->title() ".\n";
+
+=head1 DESCRIPTION
+
+Audio::File abstracts a single audio file, independant of its format. Using this
+module you can access a files meta-info like title, album, etc. as well as the
+files audio-properties like its length and bitrate.
+
+Currently only the formats flac, ogg vorbis and mp3 are supported, but support
+for other formats may be easily added.
+
+=head1 METHODS
+
+=head2 new
+
+  $file = Audio::File->new( "foobar.flac" );
+
+Constructor. It takes the filename of the your audio file as its only argument
+and returns an instance of Audio::File::${Type} if the corresponding file type
+is supported. The file type will be determined using the file extension.
+Currently flac, ogg and mp3 are supported but new formats may be added easily by
+creating a Audio::File::${Type} that inherits from Audio::File::Type, which is
+the base class for all file type classes.
+
+The methods and behaviour of the returned are documented in
+L<Audio::File::Type>.
+
+=cut
+
+sub new {
+	my $class = shift;
+	$class = ref $class || $class;
+	my $self = {};
+	bless $self, $class;
+	return $self->_create(@_);
+}
+
+sub _create {
+	my($self, $filename) = @_;
+	
+	return unless length($filename) > 4;
+
+	(my $type = $filename) =~ s/.*\.//;
+	$type = ucfirst lc $type;
+	return unless $type;
+
+	my $loaded = 0;
+	eval "require Audio::File::$type; \$loaded = 1;";
+	return "Audio::File::$type"->new( $filename ) if $loaded;
+}
+
+1;
+
+=head1 TODO
+
+=over 4
+
+=item * Add possibility to change file and its tags.
+
+=item * better (easier) interface?
+
+=item * user shouldn't be forced to use Audio::File if he only want's the files
+tag or audio properties.
+
+=item * Add possibility to access raw audio data (Audio::File::Data)
+
+That could be done via Audio::Data or equivalent.
+
+=back
+
+=head1 SEE ALSO
+
+L<Audio::File::Type>, L<Audio::File::Tag>, L<Audio::File::AudioProperties>
+
+=head1 AUTHOR
+
+Florian Ragwitz <flora at cpan.org>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2004 Florian Ragwitz
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Library General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+=cut

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/AudioProperties.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/AudioProperties.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/AudioProperties.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/AudioProperties.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,164 @@
+package Audio::File::AudioProperties;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.02';
+
+=head1 NAME
+
+Audio::File::AudioProperties - abstract an audio files audio properties.
+
+=head1 DESCRIPTION
+
+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.
+
+=head1 METHODS
+
+=head2 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.
+
+=cut
+
+sub new {
+	my($class, $filename) = @_;
+	$class = ref $class || $class;
+	my $self = { filename => $filename };
+	bless $self, $class;
+	$self->init(@_) or return;
+	return $self;
+}
+
+=head2 init
+
+Initializes the object. It's called by the constructor and empty by default.
+It's ought to be overwritten by subclasses.
+
+=cut
+
+sub init {
+
+}
+
+=head2 length
+
+Returns the length of the audio file in seconds.
+
+=cut
+
+sub length {
+	my $self = shift;
+	if( @_ ) {
+		$self->{length} = shift;
+		return 1;
+	}
+
+	return int $self->{length};
+}
+
+=head2 bitrate
+
+Returns the bitrate of the file.
+
+=cut
+
+sub bitrate {
+	my $self = shift;
+	if( @_ ) {
+		$self->{bitrate} = shift;
+		return 1;
+	}
+
+	return int $self->{bitrate};
+}
+
+=head2 sample_rate
+
+Returns the sample rate of the audio file.
+
+=cut
+
+sub sample_rate {
+	my $self = shift;
+	if( @_ ) {
+		$self->{sample_rate} = shift;
+		return 1;
+	}
+
+	return $self->{sample_rate};
+}
+
+=head2 channels
+
+Returns the number of channels the audio file has.
+
+=cut
+
+sub channels {
+	my $self = shift;
+	if( @_ ) {
+		$self->{channels} = shift;
+		return 1;
+	}
+
+	return $self->{channels};
+}
+
+=head2 all
+
+Get all audio properties.
+
+=cut
+
+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;
+
+=head1 SEE ALSO
+
+L<Audio::File>, L<Audio::File::Type>, L<Audio::File::Tag>
+
+=head1 AUTHOR
+
+Florian Ragwitz <flora at cpan.org>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2004 Florian Ragwitz
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Library General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+=cut

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,27 @@
+package Audio::File::Flac;
+
+use strict;
+use warnings;
+use base qw( Audio::File::Type );
+use Audio::File::Flac::Tag;
+use Audio::File::Flac::AudioProperties;
+
+our $VERSION = '0.02';
+
+sub init {
+	return 1;
+}
+
+sub _create_tag {
+	my $self = shift;
+	$self->{tag} = Audio::File::Flac::Tag->new( $self->name() ) or return;
+	return 1;
+}
+
+sub _create_audio_properties {
+	my $self = shift;
+	$self->{audio_properties} = Audio::File::Flac::AudioProperties->new( $self->name() ) or return;
+	return 1;
+}
+
+1;

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac/AudioProperties.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac/AudioProperties.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac/AudioProperties.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac/AudioProperties.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,23 @@
+package Audio::File::Flac::AudioProperties;
+
+use strict;
+use warnings;
+use base qw( Audio::File::AudioProperties );
+use Audio::FLAC::Header
+
+our $VERSION = '0.02';
+
+sub init {
+	my $self = shift;
+	$self->{flac} = Audio::FLAC::Header->new( $self->{filename} ) or return;
+	my $flacinfo = $self->{flac}->info();
+
+	$self->length( $self->{flac}->{trackTotalLengthSeconds} );
+	$self->bitrate( $self->{flac}->{bitRate} );
+	$self->sample_rate( $flacinfo->{SAMPLERATE} );
+	$self->channels( $flacinfo->{NUMCHANNELS} );
+	
+	return 1;
+}
+
+1;

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac/Tag.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac/Tag.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac/Tag.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/Flac/Tag.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,27 @@
+package Audio::File::Flac::Tag;
+
+use strict;
+use warnings;
+use base qw( Audio::File::Tag );
+use Audio::FLAC::Header
+
+our $VERSION = '0.03';
+
+sub init {
+	my $self = shift;
+	$self->{flac} = Audio::FLAC::Header->new( $self->{filename} ) or return;
+	my $flactag = $self->{flac}->tags();
+
+	$self->title(	$flactag->{TITLE}		);
+	$self->artist(	$flactag->{ARTIST}		);
+	$self->album(	$flactag->{ALBUM}		);
+	$self->comment(	$flactag->{DESCRIPTION}	);
+	$self->genre(	$flactag->{GENRE}		);
+	$self->year(	$flactag->{DATE}		);
+	$self->track(	$flactag->{TRACKNUMBER}	);
+	$self->total(	$flactag->{TRACKTOTAL}	);
+
+	return 1;
+}
+
+1;

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,27 @@
+package Audio::File::Mp3;
+
+use strict;
+use warnings;
+use base qw( Audio::File::Type );
+use Audio::File::Mp3::Tag;
+use Audio::File::Mp3::AudioProperties;
+
+our $VERSION = '0.05';
+
+sub init {
+	return 1;
+}
+
+sub _create_tag {
+	my $self = shift;
+	$self->{tag} = Audio::File::Mp3::Tag->new( $self->name() ) or return;
+	return 1;
+}
+
+sub _create_audio_properties {
+	my $self = shift;
+	$self->{audio_properties} = Audio::File::Mp3::AudioProperties->new( $self->name() ) or return;
+	return 1;
+}
+
+1;

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3/AudioProperties.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3/AudioProperties.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3/AudioProperties.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3/AudioProperties.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,22 @@
+package Audio::File::Mp3::AudioProperties;
+
+use strict;
+use warnings;
+use base qw( Audio::File::AudioProperties );
+use MP3::Info;
+
+our $VERSION = '0.03';
+
+sub init {
+	my $self = shift;
+	my $info = get_mp3info( $self->{filename} ) or return;
+
+	$self->length( $info->{SECS} );
+	$self->bitrate( $info->{BITRATE} );
+	$self->sample_rate( $info->{FREQUENCY} * 1000 );
+	$self->channels( $info->{STEREO} ? 2 : 1 );
+
+	return 1;
+}
+
+1;

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3/Tag.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3/Tag.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3/Tag.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/Mp3/Tag.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,31 @@
+package Audio::File::Mp3::Tag;
+
+use strict;
+use warnings;
+use base qw( Audio::File::Tag );
+use MP3::Tag;
+
+our $VERSION = '0.05';
+
+sub init {
+	my $self = shift;
+	$self->{mp3} = MP3::Tag->new( $self->{filename} ) or return;
+	$self->{mp3}->get_tags();
+
+	my $info = $self->{mp3}->autoinfo;
+	my $track = $info->{track};
+	my $pos = index($track, '/');
+
+	$self->title  (	$info->{ title   } );
+	$self->artist (	$info->{ artist  } );
+	$self->album  (	$info->{ album   } );
+	$self->comment(	$info->{ comment } );
+	$self->genre  (	$info->{ genre   } );
+	$self->year   (	$info->{ year    } );
+	$self->track  (	substr($track, 0, $pos)  );
+	$self->total  (	substr($track, $pos + 1) );
+
+	return 1;
+}
+
+1;

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,27 @@
+package Audio::File::Ogg;
+
+use strict;
+use warnings;
+use base qw( Audio::File::Type );
+use Audio::File::Ogg::Tag;
+use Audio::File::Ogg::AudioProperties;
+
+our $VERSION = '0.02';
+
+sub init {
+	return 1;
+}
+
+sub _create_tag {
+	my $self = shift;
+	$self->{tag} = Audio::File::Ogg::Tag->new( $self->name() ) or return;
+	return 1;
+}
+
+sub _create_audio_properties {
+	my $self = shift;
+	$self->{audio_properties} = Audio::File::Ogg::AudioProperties->new( $self->name() ) or return;
+	return 1;
+}
+
+1;

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg/AudioProperties.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg/AudioProperties.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg/AudioProperties.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg/AudioProperties.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,23 @@
+package Audio::File::Ogg::AudioProperties;
+
+use strict;
+use warnings;
+use base qw( Audio::File::AudioProperties );
+use Ogg::Vorbis::Header::PurePerl;
+
+our $VERSION = '0.01';
+
+sub init {
+	my $self = shift;
+	$self->{ogg} = Ogg::Vorbis::Header::PurePerl->new( $self->{filename} ) or return;
+	my $ogginfo = $self->{ogg}->info();
+
+	$self->length( $ogginfo->{length} );
+	$self->bitrate( $ogginfo->{bitrate_nominal} );
+	$self->sample_rate( $ogginfo->{rate} );
+	$self->channels( $ogginfo->{channels} );
+
+	return 1;
+}
+
+1;

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg/Tag.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg/Tag.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg/Tag.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/Ogg/Tag.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,26 @@
+package Audio::File::Ogg::Tag;
+
+use strict;
+use warnings;
+use base qw( Audio::File::Tag );
+use Ogg::Vorbis::Header::PurePerl;
+
+our $VERSION = '0.02';
+
+sub init {
+	my $self = shift;
+	$self->{ogg} = Ogg::Vorbis::Header::PurePerl->new( $self->{filename} ) or return;
+
+	$self->title(	$self->{ogg}->comment('title')			);
+	$self->artist(	$self->{ogg}->comment('artist')			);
+	$self->album(	$self->{ogg}->comment('album')			);
+	$self->comment(	$self->{ogg}->comment('comment')		);
+	$self->genre(	$self->{ogg}->comment('genre')			);
+	$self->year(	$self->{ogg}->comment('date')			);
+	$self->track(	$self->{ogg}->comment('tracknumber')	);
+	$self->total(	$self->{ogg}->comment('tracktotal')		);
+
+	return 1;
+}
+
+1;

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/Tag.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/Tag.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/Tag.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/Tag.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,271 @@
+package Audio::File::Tag;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.03';
+
+=head1 NAME
+
+Audio::File::Tag - abstracts the tag of an audio file
+
+=head1 DESCRIPTION
+
+Audio::File::Tag is the base class for other file format independant tag classes
+like Audio::File::Flac::Tag or Audio::File::Ogg::Tag. You shouldn't use this
+class yourself exept you're writing an own file format dependant subclass.
+
+=head1 METHODS
+
+=head2 new
+
+Constructor. Creates a new Audio::File::Tag object. You shouldn't use this
+method yourself. It is called by the filetype-dependant subclasses of
+Audio::File::Type automatically.
+
+=cut
+
+sub new {
+	my($class, $filename) = @_;
+	$class = ref $class || $class;
+	my $self = { filename => $filename };
+	bless $self, $class;
+	$self->init(@_) or return;
+	return $self;
+}
+
+=head2 init
+
+Initializes the object. It's called by the constructor and empty by default.
+It's ought to be overwritten by subclasses.
+
+=cut
+
+sub init {
+
+}
+
+=head2 title
+
+Using title() you can get or set the tags title field. If called without any
+argument it'll return the current content of the title field. If you call
+title() with an scalar argument it will set the title field to what the argument
+contains. The methods artist(), album(), comment(), genre(), year(), track() and total()
+are called in the same way.
+
+=cut
+
+sub title {
+	my $self = shift;
+	if( @_ ) {
+		$self->{title} = shift;
+		return 1;
+	}
+
+	return $self->{title};
+}
+
+=head2 artist
+
+Set/get the artist field in the files tag.
+
+=cut
+
+sub artist {
+	my $self = shift;
+	if( @_ ) {
+		$self->{artist} = shift;
+		return 1;
+	}
+
+	return $self->{artist};
+}
+
+=head2 album
+
+Set/get the album field in the files tag.
+
+=cut
+
+sub album {
+	my $self = shift;
+	if( @_ ) {
+		$self->{album} = shift;
+		return 1;
+	}
+
+	return $self->{album};
+}
+
+=head2 comment
+
+Set/get the comment field in the files tag.
+
+=cut
+
+sub comment {
+	my $self = shift;
+	if( @_ ) {
+		$self->{comment} = shift;
+		return 1;
+	}
+
+	return $self->{comment};
+}
+
+=head2 genre
+
+Set/get the genre field in the files tag.
+
+=cut
+
+sub genre {
+	my $self = shift;
+	if( @_ ) {
+		$self->{genre} = shift;
+		return 1;
+	}
+
+	return $self->{genre};
+}
+
+=head2 year
+
+Set/get the year field in the files tag.
+
+=cut
+
+sub year {
+	my $self = shift;
+	if( @_ ) {
+		$self->{year} = shift;
+		return 1;
+	}
+
+	return $self->{year};
+
+}
+
+=head2 track
+
+Set/get the track field in the files tag.
+
+=cut
+
+sub track {
+	my $self = shift;
+	if( @_ ) {
+		$self->{track} = shift;
+		return 1;
+	}
+	
+	return $self->{track} + 0;
+
+}
+
+=head2 total
+
+Set/get the total number of tracks.
+
+=cut
+
+sub total {
+	my $self = shift;
+	if ( @_ ) {
+		$self->{total} = shift;
+		return 1;
+	}
+
+	return $self->{total} + 0;
+}
+
+=head2 all
+
+Set/get all tags. To set the tags pass a hash reference with the names of the
+tags as keys and the tag values as hash values. Returns a hash reference if no
+argument is specified.
+
+=cut
+
+sub all {
+	my $self = shift;
+
+	if (@_) {
+		my $tags = shift;
+		$self->$_($tags->{$_}) for keys %{$tags};
+		return 1;
+	}
+
+	return {
+		title	=> $self->title(),
+		artist	=> $self->artist(),
+		album	=> $self->album(),
+		comment	=> $self->comment(),
+		genre	=> $self->genre(),
+		year	=> $self->year(),
+		track	=> $self->track(),
+		total	=> $self->total()
+	};
+}
+
+=head2 is_empty
+
+Returns whether all tag fields are empty or not.
+
+=cut
+
+sub is_empty {
+	my $self = shift;
+	return ($self->title() &&
+			$self->artist() &&
+			$self->album() &&
+			$self->comment() &&
+			$self->genre() &&
+			$self->year() &&
+			$self->track() &&
+			$self->total());
+}
+
+=head2 save
+
+Saves the changed tag information. Not yet implemented.
+
+=cut
+
+sub save {
+
+}
+
+1;
+
+=head1 TODO
+
+=over 4
+
+=item Implement writing tags
+
+=back
+
+=head1 AUTHOR
+
+Florian Ragwitz <flora at cpan.org>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) Florian Ragwitz
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Library General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+=cut

Added: branches/upstream/libaudio-file-perl/current/lib/Audio/File/Type.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/lib/Audio/File/Type.pm?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/lib/Audio/File/Type.pm (added)
+++ branches/upstream/libaudio-file-perl/current/lib/Audio/File/Type.pm Sun Jun 15 13:13:28 2008
@@ -1,0 +1,179 @@
+package Audio::File::Type;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.02';
+
+=head1 NAME
+
+Audio::File::Type - represents an audio filetype
+
+=head1 DESCRIPTION
+
+An instance of an object inherited from Audio::File::Type is returned by the
+constructor of Audio::File. This object currently provides access to the audio
+files information like its audio properties (bitrate, sample rate, number of
+channels, ...) and the data stored in the files tag, but also providing access
+to the raw audio data and other information should be easy to be implemented.
+
+=head1 METHODS
+
+=head2 new
+
+Constructor. In fact you don't need to use it. Please use Audio::File which will
+call the appropriate constructor corresponding to the files type.
+
+=cut
+
+sub new {
+	my($class, $filename) = @_;
+	$class = ref $class || $class;
+	my $self = {
+		name		=> $filename,
+		readonly 	=> 1
+	};
+	bless $self, $class;
+	return unless $self->is_readable();
+	$self->init(@_) or return;
+	return $self;
+}
+
+=head2 init
+
+This method will be called by the constructor. It's empty by default and should
+be overwritten by inheriting subclasses to initialize themselfes.
+
+=cut
+
+sub init {
+
+}
+
+sub _create_tag { }
+
+sub _create_audio_properties { }
+
+=head2 name
+
+Returns the name of the audio file.
+
+=cut
+
+sub name {
+	return shift->{name};
+}
+
+=head2 is_readable
+
+Checks whether the file is readable or not. At the moment it's only used by the
+constructor, but it will be more usefull with later versions of Audio::File.
+
+=cut
+
+sub is_readable {
+	return -r shift->{name};
+}
+
+=head2 is_writeable
+
+Checks whether the file is writeable or not. At the moment you'll probably don't
+need to call this method, but it'll be more usefull as soon as changing the
+audio file is implemented.
+
+=cut
+
+sub is_writeable {
+	return -w shift->{name};
+}
+
+=head2 tag
+
+Returns a reference to the files tag object. See the documentation of
+L<Audio::File::Tag> to learn about what the tag object does.
+
+=cut
+
+sub tag {
+	my $self = shift;
+	unless( $self->{tag} ) {
+		$self->_create_tag() or return;
+	}
+
+	return $self->{tag};
+}
+
+=head2 audio_properties
+
+Returns a reference to the files audio properties object. See the documentation
+of L<Audio::File::AudioProperties> to get information about what the audio
+properties object does.
+
+=cut
+
+sub audio_properties {
+	my $self = shift;
+	unless( $self->{audio_properties} ) {
+		$self->_create_audio_properties() or return;
+	}
+	
+	return $self->{audio_properties};
+}
+
+=head2 save
+
+Saves the audio file. This is not yet implemented but it should remember me to
+do it at some time.. :-)
+
+=cut
+
+sub save {
+
+}
+
+=head2 type
+
+Returns the files type.
+
+=cut
+
+sub type {
+	(my $type = ref shift) =~ s/.*:://;
+	return lc $type;
+}
+
+=head1 TODO
+
+=over 4
+
+=item implement changing the file
+
+=back
+
+=head1 SEE ALSO
+
+L<Audio::File>, L<Audio::File::Tag>, L<Audio::File::AudioProperties>
+
+=head1 AUTHOR
+
+Florian Ragwitz <flora at cpan.org>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2004 Florian Ragwitz
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Library General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+=cut

Added: branches/upstream/libaudio-file-perl/current/t/Audio-File.t
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/t/Audio-File.t?rev=21167&op=file
==============================================================================
--- branches/upstream/libaudio-file-perl/current/t/Audio-File.t (added)
+++ branches/upstream/libaudio-file-perl/current/t/Audio-File.t Sun Jun 15 13:13:28 2008
@@ -1,0 +1,57 @@
+#!/usr/bin/perl
+
+use Test::More tests => 49;
+
+BEGIN { use_ok('Audio::File'); }
+
+my $tags = {
+	Flac	=> {
+		title	=> 'Title',
+		artist	=> 'Artist',
+		album	=> 'Album',
+		comment	=> 'Comment',
+		genre	=> 'Rock',
+		year	=> 2005,
+		track	=> 2,
+		total	=> 3
+	}
+};
+$tags->{Mp3} = $tags->{Ogg} = $tags->{Flac};
+
+my $audio_properties = {
+	Flac	=> {
+		length		=> 4,
+		bitrate		=> 94910,
+		sample_rate	=> 8000,
+		channels	=> 1
+	},
+	Ogg		=> {
+		length		=> 4,
+		bitrate		=> 28000,
+		sample_rate	=> 8000,
+		channels	=> 1
+	},
+	Mp3		=> {
+		length		=> 4,
+		bitrate		=> 8,
+		sample_rate	=> 8000,
+		channels	=> 1
+	}
+};
+
+for my $type (keys %{$tags}) {
+	my $file = Audio::File->new('t/test.'.lc($type));
+	is( ref $file, "Audio::File::${type}", 'Audio::File::new()' );
+	is( $file->type(), lc $type, 'Audio::File::Type::type()' );
+
+	is( ref $file->tag(), "Audio::File::${type}::Tag", "Audio::File::${type}::tag()" );
+	is( ref $file->audio_properties(), "Audio::File::${type}::AudioProperties", "Audio::File::${type}::audio_properties()" );
+
+	for my $test (keys %{$tags->{$type}}) {
+		is( $file->tag()->$test(), $tags->{$type}->{$test}, "Audio::File::${type}::Tag::${test}()" );
+	}
+
+	for my $test (keys %{$audio_properties->{$type}}) {
+		is( $file->audio_properties()->$test(), $audio_properties->{$type}->{$test}, "Audio::File::${type}::AudioProperties::${test}()" );
+	}
+}

Added: branches/upstream/libaudio-file-perl/current/t/test.flac
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/t/test.flac?rev=21167&op=file
==============================================================================
Binary file - no diff available.

Propchange: branches/upstream/libaudio-file-perl/current/t/test.flac
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: branches/upstream/libaudio-file-perl/current/t/test.mp3
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/t/test.mp3?rev=21167&op=file
==============================================================================
Binary file - no diff available.

Propchange: branches/upstream/libaudio-file-perl/current/t/test.mp3
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: branches/upstream/libaudio-file-perl/current/t/test.ogg
URL: http://svn.debian.org/wsvn/branches/upstream/libaudio-file-perl/current/t/test.ogg?rev=21167&op=file
==============================================================================
Binary file - no diff available.

Propchange: branches/upstream/libaudio-file-perl/current/t/test.ogg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream




More information about the Pkg-perl-cvs-commits mailing list