line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Note.pm,v 1.1.1.1 2004/11/22 17:52:11 root Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package POE::Framework::MIDI::Note; |
4
|
8
|
|
|
8
|
|
280683
|
use strict; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
413
|
|
5
|
8
|
|
|
8
|
|
43
|
use vars '$VERSION'; $VERSION = '0.02'; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
379
|
|
6
|
8
|
|
|
8
|
|
1842
|
use POE::Framework::MIDI::Utility; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
4302
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
570
|
|
|
570
|
0
|
3732
|
my ( $self, $class ) = ( {}, shift ); |
10
|
570
|
|
|
|
|
5604
|
bless $self,$class; |
11
|
570
|
|
|
|
|
1470
|
my %params = @_; |
12
|
570
|
|
|
|
|
1010
|
$self->{cfg} = \%params; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# validate note names. |
15
|
570
|
|
|
|
|
979
|
my $_name = $self->name; |
16
|
570
|
|
|
|
|
1357
|
my ($letter) = $_name =~ /^([a-gA-G])/; |
17
|
570
|
50
|
|
|
|
1085
|
die "$_name doesn't look like a valid note name. Examples: A, C3, G2, CS4 etc" |
18
|
|
|
|
|
|
|
unless $letter; |
19
|
|
|
|
|
|
|
|
20
|
570
|
50
|
|
|
|
1112
|
die "You forgot to set a duration for the note $_name" unless $self->{cfg}->{duration}; |
21
|
570
|
|
|
|
|
818
|
$self->{cfg}->{name} = $self->{cfg}->{name}; |
22
|
570
|
|
|
|
|
1179
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub duration { |
26
|
518
|
|
|
518
|
0
|
609
|
my ( $self, $new_duration ) = @_; |
27
|
518
|
50
|
|
|
|
1969
|
$new_duration ? $self->{cfg}->{duration} = $new_duration : return $self->{cfg}->{duration} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub name { |
31
|
1605
|
|
|
1605
|
0
|
1780
|
my ( $self, $new_name ) = @_; |
32
|
1605
|
50
|
|
|
|
3962
|
$new_name ? $self->{cfg}->{name} = $new_name : return $self->{cfg}->{name} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# an alias for name |
36
|
|
|
|
|
|
|
sub note { |
37
|
517
|
|
|
517
|
0
|
615
|
my ( $self, $new_note ) = @_; |
38
|
517
|
|
|
|
|
838
|
$self->name($new_note); |
39
|
517
|
|
|
|
|
824
|
return $self->name; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |