| 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
| |||||||||||
| 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
| |||||||||||
| 29 | 179 | $class->new( dt => $dt, message => $message ); | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | # Single byte status | ||||||||||
| 33 | 179 | ▶ | return instance() if $status > 0xf3; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | # Channel events | ||||||||||
| 36 | 141 | ▶ | return instance( 'Note' ) if $status < 0xa0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 94 | ▶ | return instance( 'PolyTouch' ) if $status < 0xb0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 86 | ▶ | return instance( 'ControlChange' ) if $status < 0xc0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 41 | ▶ | return instance( 'ProgramChange' ) if $status < 0xd0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 37 | ▶ | return instance( 'AfterTouch' ) if $status < 0xe0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 29 | ▶ | return instance( 'PitchBend' ) if $status < 0xf0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | |||||||||||
| 43 | # System events | ||||||||||
| 44 | 9 | ▶ | return instance( 'SysEx' ) if $status == 0xf0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 5 | ▶ | return instance( 'TimeCode' ) if $status == 0xf1; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 5 | ▶ | return instance( 'SongPosition' ) if $status == 0xf2; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | ▶ | return instance( 'SongSelect' ) if $status == 0xf3; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | ; | ||||||||||
| 51 | |||||||||||
| 52 | __END__ | ||||||||||