line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Music::Duration; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GENE'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: Add 32nd, 64th, 128th and tuplet durations to MIDI-Perl |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
659
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
612
|
use MIDI::Simple (); |
|
1
|
|
|
|
|
21127
|
|
|
1
|
|
|
|
|
206
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.0901'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
# Set the initial duration to one below 32nd, |
16
|
|
|
|
|
|
|
my $last = 's'; # ..which is a sixteenth. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Add 32nd, 64th and 128th as x, y, and z respectively. |
19
|
|
|
|
|
|
|
for my $duration ( qw( x y z ) ) { |
20
|
|
|
|
|
|
|
# Create a MIDI::Simple format note identifier. |
21
|
|
|
|
|
|
|
my $n = $duration . 'n'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Compute the note duration, which is half of the previous. |
24
|
|
|
|
|
|
|
$MIDI::Simple::Length{$n} = $MIDI::Simple::Length{ $last . 'n' } / 2; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Compute the dotted duration. |
27
|
|
|
|
|
|
|
$MIDI::Simple::Length{ 'd' . $n } = $MIDI::Simple::Length{$n} |
28
|
|
|
|
|
|
|
+ $MIDI::Simple::Length{$n} / 2; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Compute the double-dotted duration. |
31
|
|
|
|
|
|
|
$MIDI::Simple::Length{ 'dd' . $n } = $MIDI::Simple::Length{ 'd' . $n } |
32
|
|
|
|
|
|
|
+ $MIDI::Simple::Length{$n} / 4; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Compute the triplet duration. |
35
|
|
|
|
|
|
|
$MIDI::Simple::Length{ 't' . $n } = $MIDI::Simple::Length{$n} / 3 * 2; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Increment the last duration seen. |
38
|
|
|
|
|
|
|
$last = $duration; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub tuplet { |
44
|
2
|
|
|
2
|
1
|
7
|
my ( $duration, $name, $factor ) = @_; |
45
|
2
|
|
|
|
|
10
|
$MIDI::Simple::Length{ $name . $duration } = $MIDI::Simple::Length{$duration} / $factor |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
2
|
1
|
7223
|
sub tuple { tuplet(@_) } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub add_duration { |
52
|
1
|
|
|
1
|
1
|
543
|
my ( $name, $duration ) = @_; |
53
|
1
|
|
|
|
|
3
|
$MIDI::Simple::Length{ $name } = $duration; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |