| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
13
|
|
|
13
|
|
173
|
use v5.26; |
|
|
13
|
|
|
|
|
45
|
|
|
2
|
13
|
|
|
13
|
|
65
|
use warnings; |
|
|
13
|
|
|
|
|
39
|
|
|
|
13
|
|
|
|
|
730
|
|
|
3
|
13
|
|
|
13
|
|
6575
|
use experimental qw/ signatures /; |
|
|
13
|
|
|
|
|
55941
|
|
|
|
13
|
|
|
|
|
127
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Instantiate events from MIDI messages |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package |
|
8
|
|
|
|
|
|
|
MIDI::Stream::EventFactory; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require MIDI::Stream::Event::Note; |
|
13
|
|
|
|
|
|
|
require MIDI::Stream::Event::PolyTouch; |
|
14
|
|
|
|
|
|
|
require MIDI::Stream::Event::ControlChange; |
|
15
|
|
|
|
|
|
|
require MIDI::Stream::Event::ProgramChange; |
|
16
|
|
|
|
|
|
|
require MIDI::Stream::Event::AfterTouch; |
|
17
|
|
|
|
|
|
|
require MIDI::Stream::Event::PitchBend; |
|
18
|
|
|
|
|
|
|
require MIDI::Stream::Event::SysEx; |
|
19
|
|
|
|
|
|
|
require MIDI::Stream::Event::TimeCode; |
|
20
|
|
|
|
|
|
|
require MIDI::Stream::Event::SongPosition; |
|
21
|
|
|
|
|
|
|
require MIDI::Stream::Event::SongSelect; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub event( $class, $dt, $message ) { |
|
24
|
|
|
|
|
|
|
my $status = $message->[0]; |
|
25
|
|
|
|
|
|
|
return if $status < 0x80; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my sub instance( $name = undef ) { |
|
28
|
|
|
|
|
|
|
my $class = 'MIDI::Stream::Event' . ( $name ? "::$name" : '' ); |
|
29
|
|
|
|
|
|
|
$class->new( dt => $dt, message => $message ); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Single byte status |
|
33
|
|
|
|
|
|
|
return instance() if $status > 0xf3; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Channel events |
|
36
|
|
|
|
|
|
|
return instance( 'Note' ) if $status < 0xa0; |
|
37
|
|
|
|
|
|
|
return instance( 'PolyTouch' ) if $status < 0xb0; |
|
38
|
|
|
|
|
|
|
return instance( 'ControlChange' ) if $status < 0xc0; |
|
39
|
|
|
|
|
|
|
return instance( 'ProgramChange' ) if $status < 0xd0; |
|
40
|
|
|
|
|
|
|
return instance( 'AfterTouch' ) if $status < 0xe0; |
|
41
|
|
|
|
|
|
|
return instance( 'PitchBend' ) if $status < 0xf0; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# System events |
|
44
|
|
|
|
|
|
|
return instance( 'SysEx' ) if $status == 0xf0; |
|
45
|
|
|
|
|
|
|
return instance( 'TimeCode' ) if $status == 0xf1; |
|
46
|
|
|
|
|
|
|
return instance( 'SongPosition' ) if $status == 0xf2; |
|
47
|
|
|
|
|
|
|
return instance( 'SongSelect' ) if $status == 0xf3; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |