line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! perl |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
3308
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
279
|
|
4
|
5
|
|
|
5
|
|
31
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
447
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Music::ChordBot::Opus::Section; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Music::ChordBot::Opus::Section - ChordBot song section. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = 0.01; |
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
5
|
|
28
|
use parent 'Music::ChordBot::Opus::Base'; |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
39
|
|
17
|
|
|
|
|
|
|
|
18
|
5
|
|
|
5
|
|
3251
|
use Music::ChordBot::Opus::Section::Chord; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
137
|
|
19
|
5
|
|
|
5
|
|
2797
|
use Music::ChordBot::Opus::Section::Style; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
2038
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Music::ChordBot::Opus::Section; |
24
|
|
|
|
|
|
|
my $sect = Music::ChordBot::Opus::Section->new; |
25
|
|
|
|
|
|
|
$sect->name("First movement"); |
26
|
|
|
|
|
|
|
$sect->set_style("Kubiac"); |
27
|
|
|
|
|
|
|
$sect->add_chord(...); |
28
|
|
|
|
|
|
|
$sect->add_chord(...); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#### TODO: Repeat sections. |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
# A repeat section has a name, optionally a style, and no chords. The |
35
|
|
|
|
|
|
|
# field 'repeat' contains the index of the original section that is to |
36
|
|
|
|
|
|
|
# be repeated. This can be tricky when inserting/deleting sections. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 new [ args ] |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Creates a new Music::ChordBot::Opus::Section object. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Initial attributes may be passed as a hash. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Attributes: |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=over 4 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item name |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
The name of the section. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item chords |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
An arrayref containing Music::ChordBot::Opus::Section::Chord objects, |
57
|
|
|
|
|
|
|
more commonly known as 'chords', |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item style |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
A hashref representing the attributes of a style. See |
62
|
|
|
|
|
|
|
L. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub new { |
67
|
6
|
|
|
6
|
1
|
31
|
my $pkg = shift; |
68
|
6
|
|
|
|
|
69
|
my $data = { name => "Section 1", |
69
|
|
|
|
|
|
|
chords => [], |
70
|
|
|
|
|
|
|
style => { chorus => 4, reverb => 8, |
71
|
|
|
|
|
|
|
tracks => [ { volume => 7, id => 95 } ] }, |
72
|
|
|
|
|
|
|
@_ }; |
73
|
6
|
|
|
|
|
32
|
bless { data => $data }, $pkg; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 name [ I ] |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Sets or gets the name of the section. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
2
|
|
|
2
|
1
|
26
|
sub name { shift->_setget( "name", @_ ) } |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 add_chord I |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Adds a chord to the section. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
I must be a Music::ChordBot::Opus::Section::Chord object, or a |
89
|
|
|
|
|
|
|
string denoting a chord, e.g. "C Maj 4". For convenience, the three |
90
|
|
|
|
|
|
|
elements may also be passed separately, e.g., C
|
91
|
|
|
|
|
|
|
4)>. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
A bass note can be specified by adding the note to the key, separated |
94
|
|
|
|
|
|
|
by a slash, e.g., C<"C/B">. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub add_chord { |
99
|
52
|
|
|
52
|
1
|
73
|
my ( $self, $chord ) = @_; |
100
|
52
|
|
|
|
|
69
|
my $ok = 0; |
101
|
52
|
|
|
|
|
65
|
eval { push( @{$self->{data}->{chords}}, $chord->{data} ); $ok = 1 }; |
|
52
|
|
|
|
|
57
|
|
|
52
|
|
|
|
|
551
|
|
|
4
|
|
|
|
|
7
|
|
102
|
52
|
100
|
|
|
|
173
|
return if $ok; |
103
|
48
|
|
|
|
|
52
|
shift; |
104
|
48
|
|
|
|
|
50
|
push( @{$self->{data}->{chords}}, |
|
48
|
|
|
|
|
240
|
|
105
|
|
|
|
|
|
|
Music::ChordBot::Opus::Section::Chord->new(@_)->data ); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub chords { |
109
|
|
|
|
|
|
|
wantarray |
110
|
0
|
0
|
|
0
|
1
|
0
|
? @{ $_[0]->{data}->{chords} } |
|
0
|
|
|
|
|
0
|
|
111
|
|
|
|
|
|
|
: $_[0]->{data}->{chords}; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 no_style |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
A newly created Music::ChordBot::Opus::Section object has a default |
117
|
|
|
|
|
|
|
style associated. Calling this method removes the style from the |
118
|
|
|
|
|
|
|
section. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub no_style { |
123
|
0
|
|
|
0
|
1
|
0
|
delete $_[0]->{data}->{style}; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 set_style [ I |