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.006';
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 179 ▶sub event( $class, $dt, $message ) {
Subroutine event: called CC=13 SCAR=26.0
Pod undocumented
24 179 my $status = $message->[0];
25 179 ▶ return if $status < 0x80;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 128 0 179 179
26  
27 179 ▶ my sub instance( $name = undef ) {
Subroutine instance: called CC=3 SCAR=11.0
28 179 ▶ my $class = 'MIDI::Stream::Event' . ( $name ? "::$name" : '' );
Branch: 1 branch
BranchTrueFalseTotal
$name ? : 141 38 179
29 179 $class->new( dt => $dt, message => $message );
30 }
31  
32 # Single byte status
33 179 ▶ return instance() if $status > 0xf3;
Branch: 1 branch
BranchTrueFalseTotal
if $status > 243 38 141 179
34  
35 # Channel events
36 141 ▶ return instance( 'Note' ) if $status < 0xa0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 160 47 94 141
37 94 ▶ return instance( 'PolyTouch' ) if $status < 0xb0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 176 8 86 94
38 86 ▶ return instance( 'ControlChange' ) if $status < 0xc0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 192 45 41 86
39 41 ▶ return instance( 'ProgramChange' ) if $status < 0xd0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 208 4 37 41
40 37 ▶ return instance( 'AfterTouch' ) if $status < 0xe0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 224 8 29 37
41 29 ▶ return instance( 'PitchBend' ) if $status < 0xf0;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 240 20 9 29
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 »