| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Audio::File::AudioProperties; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
10
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
55
|
|
|
4
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1040
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Audio::File::AudioProperties - abstract an audio files audio properties. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Audio::File::AudioProperties is the base class for other file format independant |
|
15
|
|
|
|
|
|
|
audio property classes like Audio::File::Flac::AudioProperties or |
|
16
|
|
|
|
|
|
|
Audio::File::Ogg::AudioProperties. You should not use this class yourself exept |
|
17
|
|
|
|
|
|
|
you're writing an own file format dependant subclass. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 METHODS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 new |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Constructor. Creates new Audio::File::AudioProperties object. You shoud not use |
|
24
|
|
|
|
|
|
|
this method yourself. It's called by the filetype-dependant subclasses of |
|
25
|
|
|
|
|
|
|
Audio::File::Type automatically. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
|
30
|
3
|
|
|
3
|
1
|
8
|
my($class, $filename) = @_; |
|
31
|
3
|
|
33
|
|
|
18
|
$class = ref $class || $class; |
|
32
|
3
|
|
|
|
|
9
|
my $self = { filename => $filename }; |
|
33
|
3
|
|
|
|
|
11
|
bless $self, $class; |
|
34
|
3
|
50
|
|
|
|
16
|
$self->init(@_) or return; |
|
35
|
3
|
|
|
|
|
28
|
return $self; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 init |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Initializes the object. It's called by the constructor and empty by default. |
|
41
|
|
|
|
|
|
|
It's ought to be overwritten by subclasses. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
1
|
0
|
sub init { |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 length |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Returns the length of the audio file in seconds. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub length { |
|
56
|
6
|
|
|
6
|
1
|
12
|
my $self = shift; |
|
57
|
6
|
100
|
|
|
|
19
|
if( @_ ) { |
|
58
|
3
|
|
|
|
|
8
|
$self->{length} = shift; |
|
59
|
3
|
|
|
|
|
8
|
return 1; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
3
|
|
|
|
|
114
|
return int $self->{length}; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 bitrate |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns the bitrate of the file. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub bitrate { |
|
72
|
6
|
|
|
6
|
1
|
9
|
my $self = shift; |
|
73
|
6
|
100
|
|
|
|
19
|
if( @_ ) { |
|
74
|
3
|
|
|
|
|
7
|
$self->{bitrate} = shift; |
|
75
|
3
|
|
|
|
|
8
|
return 1; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
3
|
|
|
|
|
19
|
return int $self->{bitrate}; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 sample_rate |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Returns the sample rate of the audio file. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub sample_rate { |
|
88
|
6
|
|
|
6
|
1
|
12
|
my $self = shift; |
|
89
|
6
|
100
|
|
|
|
20
|
if( @_ ) { |
|
90
|
3
|
|
|
|
|
5
|
$self->{sample_rate} = shift; |
|
91
|
3
|
|
|
|
|
7
|
return 1; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
3
|
|
|
|
|
16
|
return $self->{sample_rate}; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 channels |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Returns the number of channels the audio file has. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub channels { |
|
104
|
6
|
|
|
6
|
1
|
16
|
my $self = shift; |
|
105
|
6
|
100
|
|
|
|
18
|
if( @_ ) { |
|
106
|
3
|
|
|
|
|
8
|
$self->{channels} = shift; |
|
107
|
3
|
|
|
|
|
8
|
return 1; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
3
|
|
|
|
|
19
|
return $self->{channels}; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 all |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Get all audio properties. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub all { |
|
120
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
if (@_) { |
|
123
|
0
|
|
|
|
|
|
my $props = shift; |
|
124
|
0
|
|
|
|
|
|
$self->$_($props->{$_}) for keys %{$props}; |
|
|
0
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
return 1; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
return { |
|
129
|
0
|
|
|
|
|
|
length => $self->length(), |
|
130
|
|
|
|
|
|
|
bitrate => $self->bitrate(), |
|
131
|
|
|
|
|
|
|
sample_rate => $self->sample_rate(), |
|
132
|
|
|
|
|
|
|
channels => $self->channels() |
|
133
|
|
|
|
|
|
|
}; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
L, L, L |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Florian Ragwitz |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Copyright (C) 2004 Florian Ragwitz |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
151
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
|
152
|
|
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or |
|
153
|
|
|
|
|
|
|
(at your option) any later version. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
|
156
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
157
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
158
|
|
|
|
|
|
|
GNU Library General Public License for more details. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
161
|
|
|
|
|
|
|
along with this program; if not, write to the Free Software |
|
162
|
|
|
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |