Stream/EventFactory.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 80.7% 21 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 89.5% 60 / 67 CC 15 SCAR 22.9
CC
15
Cov
90%
event
13.5
instance
3.0
BEGIN
1.0
CRAP 9.9
« Stream/Encoder.pm ↑ Summary Stream/Decoder.pm »
1 13 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 13 ▶use experimental qw/ signatures /;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: Instantiate events from MIDI messages
6  
7 package
8 MIDI::Stream::EventFactory;
9  
10 13 our $VERSION = '0.005';
11  
12 13 require MIDI::Stream::Event::Note;
13 13 require MIDI::Stream::Event::PolyTouch;
14 13 require MIDI::Stream::Event::ControlChange;
15 13 require MIDI::Stream::Event::ProgramChange;
16 13 require MIDI::Stream::Event::AfterTouch;
17 13 require MIDI::Stream::Event::PitchBend;
18 13 require MIDI::Stream::Event::SysEx;
19 13 require MIDI::Stream::Event::TimeCode;
20 13 require MIDI::Stream::Event::SongPosition;
21 13 require MIDI::Stream::Event::SongSelect;
22  
23 ▶sub event( $class, $dt, $message ) {
Subroutine event: called CC=13 SCAR=26.0
Pod undocumented
24 165 my $status = $message->[0];
25 165 ▶ return if $status < 0x80;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 128 0 165 165
26  
27 165 ▶ my sub instance( $name = undef ) {
Subroutine instance: called CC=3 SCAR=11.0
28 165 ▶ my $class = 'MIDI::Stream::Event' . ( $name ? "::$name" : '' );
Branch: 1 branch
BranchTrueFalseTotal
$name ? : 131 34 165
29 165 $class->new( dt => $dt, message => $message );
30 }
31  
32 # Single byte status
33 165 ▶ return instance() if $status > 0xf3;
Branch: 1 branch
BranchTrueFalseTotal
if $status > 243 34 131 165
34  
35 # Channel events
36 131 ▶ return instance( 'Note' ) if $status < 0xa0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 160 43 88 131
37 88 ▶ return instance( 'PolyTouch' ) if $status < 0xb0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 176 8 80 88
38 80 ▶ return instance( 'ControlChange' ) if $status < 0xc0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 192 41 39 80
39 39 ▶ return instance( 'ProgramChange' ) if $status < 0xd0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 208 4 35 39
40 35 ▶ return instance( 'AfterTouch' ) if $status < 0xe0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 224 8 27 35
41 27 ▶ return instance( 'PitchBend' ) if $status < 0xf0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 240 18 9 27
42  
43 # System events
44 9 ▶ return instance( 'SysEx' ) if $status == 0xf0;
Branch: 1 branch
BranchTrueFalseTotal
if $status == 240 4 5 9
45 5 ▶ return instance( 'TimeCode' ) if $status == 0xf1;
Branch: 1 branch
BranchTrueFalseTotal
if $status == 241 0 5 5
46 5 ▶ return instance( 'SongPosition' ) if $status == 0xf2;
Branch: 1 branch
BranchTrueFalseTotal
if $status == 242 5 0 5
47 0 ▶ return instance( 'SongSelect' ) if $status == 0xf3;
Branch: 1 branch
BranchTrueFalseTotal
if $status == 243 0 0 0
48 }
49  
50 ;
51  
52 __END__
« Stream/Encoder.pm ↑ Summary Stream/Decoder.pm »