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
|
|
724
|
use strict; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
29
|
|
7
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
688
|
use MIDI::Simple (); |
|
1
|
|
|
|
|
21837
|
|
|
1
|
|
|
|
|
227
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.0802'; |
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 y, x, and o respectively. |
19
|
|
|
|
|
|
|
for my $duration ( qw( y x o ) ) { |
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
|
6
|
my ( $duration, $name, $factor ) = @_; |
45
|
2
|
|
|
|
|
11
|
$MIDI::Simple::Length{ $name . $duration } = $MIDI::Simple::Length{$duration} / $factor |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
2
|
1
|
7688
|
sub tuple { tuplet(@_) } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub add_duration { |
52
|
1
|
|
|
1
|
1
|
525
|
my ( $name, $duration ) = @_; |
53
|
1
|
|
|
|
|
4
|
$MIDI::Simple::Length{ $name } = $duration; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |