line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Music::ABC::Song; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
30713
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
27
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
456
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
our @EXPORT = () ; |
12
|
|
|
|
|
|
|
our @EXPORT_OK = (); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my %new_attributes = (archivename=>1, number => 1, meter=>1, type=>1, key=>1, filepos=>1) ; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my %header_full = ( |
20
|
|
|
|
|
|
|
A=>"AREA", |
21
|
|
|
|
|
|
|
B=>"BOOK", |
22
|
|
|
|
|
|
|
C=>"COMPOSER", |
23
|
|
|
|
|
|
|
D=>"DISCOGRAPHY", |
24
|
|
|
|
|
|
|
E=>"ELEMSKIP", |
25
|
|
|
|
|
|
|
F=>"FILENAME", |
26
|
|
|
|
|
|
|
G=>"GROUP", |
27
|
|
|
|
|
|
|
H=>"HISTORY", |
28
|
|
|
|
|
|
|
I=>"INFORMATION", |
29
|
|
|
|
|
|
|
K=>"KEY", |
30
|
|
|
|
|
|
|
L=>"NOTELENGTH", |
31
|
|
|
|
|
|
|
M=>"METER", |
32
|
|
|
|
|
|
|
N=>"NOTES", |
33
|
|
|
|
|
|
|
O=>"ORIGIN", |
34
|
|
|
|
|
|
|
P=>"PARTS", |
35
|
|
|
|
|
|
|
Q=>"TEMPO", |
36
|
|
|
|
|
|
|
R=>"RHYTHM", |
37
|
|
|
|
|
|
|
S=>"SOURCE", |
38
|
|
|
|
|
|
|
T=>"TITLES", |
39
|
|
|
|
|
|
|
X=>"NUMBER", |
40
|
|
|
|
|
|
|
Z=>"TRANSCRIPTION") ; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my %header_is_multiline = (DISCOGRAPHY=>1,HISTORY=>1,INFORMATION=>1,NOTES=>1,TITLES=>1,TRANSCRIPTION=>1) ; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my @header_print_order = qw(TITLES RHYTHM KEY METER NOTES HISTORY DISCOGRAPHY INFORMATION TRANSCRIPTION) ; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new |
47
|
|
|
|
|
|
|
{ |
48
|
1
|
|
|
1
|
1
|
18
|
my ($caller, %args) = @_ ; |
49
|
1
|
|
33
|
|
|
9
|
my $self = bless {}, ref($caller) || $caller ; |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
8
|
$self->{ARCHIVENAME} = "" ; |
52
|
1
|
|
|
|
|
4
|
$self->{DISPLAY_NAME} = "" ; |
53
|
1
|
|
|
|
|
3
|
$self->{NUMBER} = 0 ; |
54
|
1
|
|
|
|
|
4
|
$self->{FILEPOS} = 0 ; |
55
|
1
|
|
|
|
|
6
|
$self->{TEXT} = [] ; |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
4
|
$self->{AREA} = "" ; |
58
|
1
|
|
|
|
|
3
|
$self->{BOOK} = "" ; |
59
|
1
|
|
|
|
|
3
|
$self->{COMPOSER} = "" ; |
60
|
1
|
|
|
|
|
4
|
$self->{DISCOGRAPHY} = [] ; |
61
|
1
|
|
|
|
|
3
|
$self->{ELEMSKIP} = "" ; |
62
|
1
|
|
|
|
|
2
|
$self->{GROUP} = "" ; |
63
|
1
|
|
|
|
|
5
|
$self->{HISTORY} = [] ; |
64
|
1
|
|
|
|
|
3
|
$self->{INFORMATION} = [] ; |
65
|
1
|
|
|
|
|
3
|
$self->{KEY} = "" ; |
66
|
1
|
|
|
|
|
2
|
$self->{NOTELENGTH} = "" ; |
67
|
1
|
|
|
|
|
4
|
$self->{METER} = "" ; |
68
|
1
|
|
|
|
|
3
|
$self->{NOTES} = [] ; |
69
|
1
|
|
|
|
|
3
|
$self->{ORIGIN} = "" ; |
70
|
1
|
|
|
|
|
2
|
$self->{PARTS} = "" ; |
71
|
1
|
|
|
|
|
3
|
$self->{TEMPO} = "" ; |
72
|
1
|
|
|
|
|
2
|
$self->{RHYTHM} = "" ; |
73
|
1
|
|
|
|
|
2
|
$self->{SOURCE} = "" ; |
74
|
1
|
|
|
|
|
3
|
$self->{TITLES} = [] ; |
75
|
1
|
|
|
|
|
3
|
$self->{TRANSCRIPTION} = [] ; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
7
|
while (my ($arg, $value) = each %args) { |
79
|
2
|
50
|
|
|
|
7
|
croak "Invalid intializer for Music::ABC::Song object" unless $new_attributes{$arg} ; |
80
|
1
|
|
|
1
|
|
5
|
no strict 'refs' ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1632
|
|
81
|
2
|
|
|
|
|
9
|
$self->$arg($value) ; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
9
|
return $self ; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub quote_html |
88
|
|
|
|
|
|
|
{ |
89
|
0
|
|
|
0
|
0
|
0
|
my $text = shift ; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
0
|
$text =~ s/&/&/g ; |
92
|
0
|
|
|
|
|
0
|
$text =~ s/</g ; |
93
|
0
|
|
|
|
|
0
|
$text =~ s/>/>/g ; |
94
|
0
|
|
|
|
|
0
|
$text =~ s/"/&qout;/g ; |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
0
|
return $text ; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub output_scalar_desc |
100
|
|
|
|
|
|
|
{ |
101
|
0
|
|
|
0
|
0
|
0
|
my $header_str = shift ; |
102
|
0
|
|
|
|
|
0
|
my $text = shift ; |
103
|
0
|
|
0
|
|
|
0
|
my $html_tag = shift || 0 ; |
104
|
0
|
|
0
|
|
|
0
|
my $use_tags = shift || 0 ; |
105
|
0
|
|
|
|
|
0
|
my @data = () ; |
106
|
0
|
|
|
|
|
0
|
my $tmp ; |
107
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
0
|
$tmp .= "<$html_tag>" if ($use_tags) ; |
109
|
0
|
0
|
|
|
|
0
|
$tmp .= "$header_str" if $header_str ; |
110
|
0
|
0
|
|
|
|
0
|
$tmp .= "" if ($use_tags) ; |
111
|
0
|
0
|
|
|
|
0
|
$text = quote_html($text) if($use_tags) ; |
112
|
0
|
|
|
|
|
0
|
$tmp .= " $text" ; |
113
|
0
|
0
|
|
|
|
0
|
$tmp .= "" if ($use_tags) ; |
114
|
0
|
0
|
|
|
|
0
|
$tmp .= "$html_tag>" if($use_tags) ; |
115
|
0
|
|
|
|
|
0
|
push (@data, $tmp) ; |
116
|
0
|
|
|
|
|
0
|
return @data ; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub output_array_desc |
120
|
|
|
|
|
|
|
{ |
121
|
0
|
|
|
0
|
0
|
0
|
my $header_str = shift ; |
122
|
0
|
|
|
|
|
0
|
my $text_aref = shift ; |
123
|
0
|
|
0
|
|
|
0
|
my $html_tag = shift || 0 ; |
124
|
0
|
|
0
|
|
|
0
|
my $use_tags = shift || 0 ; |
125
|
0
|
|
|
|
|
0
|
my @data ; |
126
|
0
|
|
|
|
|
0
|
my $indent = " " x 8 ; |
127
|
|
|
|
|
|
|
|
128
|
0
|
0
|
|
|
|
0
|
push (@data, "<$html_tag>") if($use_tags) ; |
129
|
0
|
0
|
|
|
|
0
|
my $tmp .= "$header_str " if $header_str ; |
130
|
0
|
|
|
|
|
0
|
push (@data, $tmp) ; |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
0
|
foreach(@$text_aref) { |
133
|
0
|
0
|
|
|
|
0
|
$tmp = $use_tags ? "" : "" ; |
134
|
0
|
0
|
|
|
|
0
|
$tmp .= $use_tags ? quote_html($_) : $_ ; |
135
|
0
|
0
|
|
|
|
0
|
$tmp .= $use_tags ? "" : "" ; |
136
|
0
|
|
|
|
|
0
|
push (@data, $indent . $tmp) ; |
137
|
|
|
|
|
|
|
} |
138
|
0
|
0
|
|
|
|
0
|
push (@data, "$html_tag>") if($use_tags) ; |
139
|
0
|
|
|
|
|
0
|
return @data ; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub get_song_summary |
143
|
|
|
|
|
|
|
{ |
144
|
0
|
|
|
0
|
1
|
0
|
my $self = shift ; |
145
|
0
|
|
0
|
|
|
0
|
my $use_html_tags = shift || 0 ; |
146
|
0
|
|
|
|
|
0
|
my @data ; |
147
|
0
|
|
|
|
|
0
|
my $indent = " " x 8 ; |
148
|
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
0
|
my $tmp = "" if $use_html_tags ; |
150
|
0
|
|
|
|
|
0
|
$tmp .= "Song Number $self->{NUMBER} in " . $self->{ARCHIVENAME} ; |
151
|
0
|
0
|
|
|
|
0
|
$tmp .= "" if $use_html_tags ; |
152
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
0
|
push(@data, $tmp) ; |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
0
|
foreach(@header_print_order) { |
156
|
0
|
|
|
|
|
0
|
my $multiline = $header_is_multiline{$_} ; |
157
|
0
|
0
|
|
|
|
0
|
if($multiline) { |
158
|
0
|
|
|
|
|
0
|
push(@data, output_array_desc($_, \@{$self->{$_}}, "dl", $use_html_tags)) ; |
|
0
|
|
|
|
|
0
|
|
159
|
|
|
|
|
|
|
} else { |
160
|
0
|
|
|
|
|
0
|
push(@data, output_scalar_desc($_, $self->{$_}, "dl", $use_html_tags)) ; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
0
|
return @data ; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub archivename |
168
|
|
|
|
|
|
|
{ |
169
|
2
|
|
|
2
|
1
|
4
|
my $self = shift ; |
170
|
2
|
100
|
|
|
|
16
|
$self->{ARCHIVENAME} = shift if @_ ; |
171
|
2
|
|
|
|
|
13
|
return $self->{ARCHIVENAME} ; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub filepos |
175
|
|
|
|
|
|
|
{ |
176
|
0
|
|
|
0
|
1
|
0
|
my $self = shift ; |
177
|
0
|
0
|
|
|
|
0
|
$self->{FILEPOS} = shift if @_ ; |
178
|
0
|
|
|
|
|
0
|
return $self->{FILEPOS} ; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub number |
182
|
|
|
|
|
|
|
{ |
183
|
2
|
|
|
2
|
1
|
407
|
my $self = shift ; |
184
|
2
|
100
|
|
|
|
8
|
$self->{NUMBER} = shift if @_ ; |
185
|
2
|
|
|
|
|
10
|
return $self->{NUMBER} ; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub type |
189
|
|
|
|
|
|
|
{ |
190
|
0
|
|
|
0
|
1
|
0
|
my $self = shift ; |
191
|
0
|
0
|
|
|
|
0
|
$self->{TYPE} = shift if @_ ; |
192
|
0
|
|
|
|
|
0
|
return $self->{TYPE} ; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub key |
196
|
|
|
|
|
|
|
{ |
197
|
0
|
|
|
0
|
1
|
0
|
my $self = shift ; |
198
|
0
|
0
|
|
|
|
0
|
$self->{KEY} = shift if @_ ; |
199
|
0
|
|
|
|
|
0
|
return $self->{KEY} ; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub meter |
203
|
|
|
|
|
|
|
{ |
204
|
0
|
|
|
0
|
1
|
0
|
my $self = shift ; |
205
|
0
|
0
|
|
|
|
0
|
$self->{METER} = shift if @_ ; |
206
|
0
|
|
|
|
|
0
|
return $self->{METER} ; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub display_name |
210
|
|
|
|
|
|
|
{ |
211
|
0
|
|
|
0
|
0
|
0
|
my $self = shift ; |
212
|
0
|
0
|
|
|
|
0
|
$self->{DISPLAY_NAME} = shift if @_ ; |
213
|
0
|
|
|
|
|
0
|
return $self->{DISPLAY_NAME} ; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub titles { |
217
|
0
|
|
|
0
|
1
|
0
|
my $self = shift ; |
218
|
|
|
|
|
|
|
|
219
|
0
|
0
|
|
|
|
0
|
if(@_) { |
220
|
0
|
0
|
|
|
|
0
|
if (ref $_[0] eq 'ARRAY') { |
221
|
0
|
|
|
|
|
0
|
@{ $self->{TITLES} } = @{ $_[0] } ; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
222
|
|
|
|
|
|
|
} else { |
223
|
0
|
|
|
|
|
0
|
@{ $self->{TITLES} } = @_ ; |
|
0
|
|
|
|
|
0
|
|
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
0
|
return $self->{TITLES} ; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub add_title { |
231
|
0
|
|
|
0
|
1
|
0
|
my $self = shift ; |
232
|
0
|
0
|
|
|
|
0
|
push (@{ $self->{TITLES} }, shift) if @_ ; |
|
0
|
|
|
|
|
0
|
|
233
|
0
|
|
|
|
|
0
|
return $self->{TITLES} |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
sub notes { |
237
|
0
|
|
|
0
|
1
|
0
|
my $self = shift ; |
238
|
|
|
|
|
|
|
|
239
|
0
|
0
|
|
|
|
0
|
if(@_) { |
240
|
0
|
0
|
|
|
|
0
|
if (ref $_[0] eq 'ARRAY') { |
241
|
0
|
|
|
|
|
0
|
@{ $self->{NOTES} } = @{ $_[0] } ; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
242
|
|
|
|
|
|
|
} else { |
243
|
0
|
|
|
|
|
0
|
@{ $self->{NOTES} } = @_ ; |
|
0
|
|
|
|
|
0
|
|
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
0
|
return $self->{NOTES} ; |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
sub add_note { |
251
|
0
|
|
|
0
|
1
|
0
|
my $self = shift ; |
252
|
0
|
0
|
|
|
|
0
|
push (@{ $self->{NOTES} }, shift) if @_ ; |
|
0
|
|
|
|
|
0
|
|
253
|
0
|
|
|
|
|
0
|
return $self->{NOTES} ; |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub text { |
257
|
0
|
|
|
0
|
1
|
0
|
my $self = shift ; |
258
|
0
|
0
|
|
|
|
0
|
push (@{ $self->{TEXT} }, shift) if @_ ; |
|
0
|
|
|
|
|
0
|
|
259
|
0
|
|
|
|
|
0
|
return $self->{TEXT} ; |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
sub header { |
263
|
6
|
|
|
6
|
1
|
10
|
my $self = shift ; |
264
|
6
|
|
|
|
|
7
|
my $header_code = shift ; |
265
|
6
|
|
|
|
|
7
|
my $header_text = shift ; |
266
|
6
|
|
|
|
|
11
|
my $header_name = $header_full{$header_code} ; |
267
|
|
|
|
|
|
|
|
268
|
6
|
50
|
|
|
|
21
|
if($header_name) { |
269
|
6
|
|
100
|
|
|
19
|
my $multiline = $header_is_multiline{$header_name} || 0 ; |
270
|
6
|
100
|
|
|
|
12
|
if($multiline) { |
271
|
4
|
100
|
|
|
|
8
|
if($header_text) { |
272
|
2
|
50
|
|
|
|
4
|
push (@{ $self->{$header_name} }, $header_text) if $header_text ; |
|
2
|
|
|
|
|
5
|
|
273
|
|
|
|
|
|
|
} |
274
|
4
|
|
|
|
|
6
|
return \@{ $self->{$header_name} } ; |
|
4
|
|
|
|
|
17
|
|
275
|
|
|
|
|
|
|
} else { |
276
|
2
|
100
|
|
|
|
28
|
if($header_text) { |
277
|
1
|
|
|
|
|
3
|
$self->{$header_name} = $header_text ; |
278
|
|
|
|
|
|
|
} |
279
|
2
|
|
|
|
|
565
|
return $self->{$header_name} ; |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
1; |
285
|
|
|
|
|
|
|
__END__ |