blib/lib/MIDI/RtController/Filter/CC.pm

filter: Statementstmt 22.2% 50 / 225 Branchbran 0.0% 0 / 84 Conditioncond 0.0% 0 / 115 MC/DCmcdc 0.0% 0 / 61 Subroutinesub 41.9% 13 / 31 Podpod 100% 11 / 11 totaltotal 14.0% 74 / 527 CC 84 SCAR 39.9
CC
84
Cov
12%
threshold
110.0
add_filters
72.0
breathe
72.0
CRAP 54.2
↑ Summary
1 package MIDI::RtController::Filter::CC;
2 2 our $AUTHORITY = 'cpan:GENE';
3  
4 # ABSTRACT: Control-change based RtController filters
5  
6 2 our $VERSION = '0.1407';
7  
8 2 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use curry;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use IO::Async::Timer::Countdown ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use IO::Async::Timer::Periodic ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Iterator::Breathe ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Types::MIDI qw(Velocity);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use Types::Common::Numeric qw(PositiveNum);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use Types::Standard qw(Maybe Int);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 2 ▶use constant KNOWN_FILTERS => qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
23 single clock_it breathe scatter stair_step ramp_up ramp_down flicker threshold program_change
24 2 );
25  
26 2 extends 'MIDI::RtController::Filter';
27  
28  
29 2 has control => (
30 is => 'rw',
31 isa => Velocity, # no CC# in Types::MIDI yet
32 default => 1,
33 );
34  
35  
36 2 has initial_point => (
37 is => 'rw',
38 isa => Velocity,
39 default => 0,
40 );
41  
42  
43 2 has range_bottom => (
44 is => 'rw',
45 isa => Velocity,
46 default => 0,
47 );
48  
49  
50 2 has range_top => (
51 is => 'rw',
52 isa => Velocity,
53 default => 127,
54 );
55  
56  
57 2 has range_step => (
58 is => 'rw',
59 isa => Velocity,
60 default => 1,
61 );
62  
63  
64 2 has time_step => (
65 is => 'rw',
66 isa => PositiveNum,
67 default => 0.25,
68 );
69  
70  
71 2 has step_up => (
72 is => 'rw',
73 isa => Velocity,
74 default => 2,
75 );
76  
77  
78 2 has step_down => (
79 is => 'rw',
80 isa => Velocity,
81 default => 1,
82 );
83  
84  
85 0 ▶sub add_filters ($filters, $controllers) {
Subroutine add_filters: not called CC=8 SCAR=42.8
Pod documented
86 0 for my $orig (@$filters) {
87 0 my %params = %$orig; # work on a copy
88 0 my $port = delete $params{port};
89 # skip unnamed and unknown entries
90 0 ▶ next if !$port || !exists $controllers->{$port};
Branch: 1 branch
BranchTrueFalseTotal
unless $port and exists $controllers->{$port} 0 0 0
Condition0%0/3
$port and exists $controllers->{$port}
!ll&&!rl&&r
000
MC/DC0%0/2
$port and exists $controllers->{$port}
$port exists $controllers->{$port}
Truth table0%0/3
A and B
A= $portB= exists $controllers->{$port}
ABresult
0X0
100
111
91 0 ▶ my $type = delete $params{type} || 'single';
Condition0%0/2
delete $params{'type'} || 'single'
l!l
00
MC/DC0%0/1
delete $params{'type'} || 'single'
delete $params{'type'}
Truth table0%0/2
A
A= delete $params{'type'}
Aresult
11
00
92 croak qq{Unknown filter type "$type" (must be one of: } . join(', ', KNOWN_FILTERS) . ')'
93 0 ▶ unless grep { $_ eq $type } KNOWN_FILTERS;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $type;} ("single", "clock_it", "breathe", "scatter", "stair_step", "ramp_up", "ramp_down", "flicker", "threshold", "program_change") 0 0 0
94 0 ▶ my $event = delete $params{event} || 'all';
Condition0%0/2
delete $params{'event'} || 'all'
l!l
00
MC/DC0%0/1
delete $params{'event'} || 'all'
delete $params{'event'}
Truth table0%0/2
A
A= delete $params{'event'}
Aresult
11
00
95 my $filter = __PACKAGE__->new(
96 0 rtc => $controllers->{$port}
97 );
98 # assume all remaining key/values are module attributes
99 0 for my $param (keys %params) {
100 0 $filter->$param( $params{$param} );
101 }
102 0 my $method = "curry::$type";
103 0 $controllers->{$port}->add_filter($type, $event => $filter->$method);
104 }
105 }
106  
107  
108 0 ▶sub single ($self, $device, $dt, $event) {
Subroutine single: not called CC=5 SCAR=34.0
Pod documented
109 0 my ($ev, $chan, $note, $val) = $event->@*;
110 0 ▶ return 0 if defined $self->trigger && defined $note && $note != $self->trigger;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->trigger and defined $note and $note != $self->trigger 0 0 0
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
!ll&&!rl&&r
000
defined $self->trigger and defined $note
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger defined $note $note != $self->trigger
Truth table0%0/4
A and B and C
A= defined $self->triggerB= defined $noteC= $note != $self->trigger
ABCresult
0XX0
10X0
1100
1111
111  
112 0 ▶ my $value = $self->value // $val;
Condition0%0/3
$self->value // $val
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->value // $val
$self->value $val
Truth table0%0/3
A // B
A= $self->valueB= $val
ABresult
1X1
011
000
113 0 my $cc = [ 'control_change', $self->channel, $self->control, $value ];
114 0 $self->rtc->send_it($cc);
115  
116 0 return $self->continue;
117 }
118  
119  
120 0 ▶sub clock_it ($self, $device, $dt, $event) {
Subroutine clock_it: not called CC=2 SCAR=17.9
Pod documented
121 0 ▶ return 0 if $self->running;
Branch: 1 branch
BranchTrueFalseTotal
if $self->running 0 0 0
122  
123 0 my ($ev, $chan) = $event->@*;
124  
125 0 $self->running(1);
126  
127 0 $self->rtc->send_it(['start']);
128  
129 $self->rtc->loop->add(
130 IO::Async::Timer::Periodic->new(
131 interval => $self->time_step,
132 0 ▶ on_tick => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
133 0 my ($c) = @_;
134 0 ▶ if ($self->halt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->halt) { } 0 0 0
135 0 $self->rtc->send_it(['stop']);
136 0 $c->stop;
137 0 $self->rtc->loop->remove($c);
138 0 $self->running(0);
139 0 $self->halt(0);
140 }
141 else {
142 0 $self->rtc->send_it(['clock']);
143 }
144 },
145 0 )->start
146 );
147  
148 0 return $self->continue;
149 }
150  
151  
152 0 ▶sub breathe ($self, $device, $dt, $event) {
Subroutine breathe: not called CC=8 SCAR=42.8
Pod documented
153 0 ▶ return 0 if $self->running;
Branch: 1 branch
BranchTrueFalseTotal
if $self->running 0 0 0
154  
155 0 my ($ev, $chan, $note, $val) = $event->@*;
156  
157 0 ▶ return 0 if defined $self->trigger && defined $note && $note != $self->trigger;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->trigger and defined $note and $note != $self->trigger 0 0 0
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
!ll&&!rl&&r
000
defined $self->trigger and defined $note
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger defined $note $note != $self->trigger
Truth table0%0/4
A and B and C
A= defined $self->triggerB= defined $noteC= $note != $self->trigger
ABCresult
0XX0
10X0
1100
1111
158 0 ▶ return 0 if defined $self->value && defined $val && $val != $self->value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->value and defined $val and $val != $self->value 0 0 0
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
!ll&&!rl&&r
000
defined $self->value and defined $val
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->value and defined $val and $val != $self->value
defined $self->value defined $val $val != $self->value
Truth table0%0/4
A and B and C
A= defined $self->valueB= defined $valC= $val != $self->value
ABCresult
0XX0
10X0
1100
1111
159  
160 0 $self->running(1);
161  
162 0 my $it = Iterator::Breathe->new(
163 bottom => $self->range_bottom,
164 top => $self->range_top,
165 step => $self->range_step,
166 );
167  
168 $self->rtc->loop->add(
169 IO::Async::Timer::Periodic->new(
170 interval => $self->time_step,
171 0 ▶ on_tick => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
172 0 my ($c) = @_;
173 0 ▶ if ($self->halt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->halt) { } 0 0 0
174 0 $c->stop;
175 0 $self->rtc->loop->remove($c);
176 0 $self->running(0);
177 0 $self->halt(0);
178 }
179 else {
180 0 $it->iterate;
181 0 my $cc = [ 'control_change', $self->channel, $self->control, $it->i ];
182 0 $self->rtc->send_it($cc);
183 }
184 },
185 0 )->start
186 );
187  
188 0 return $self->continue;
189 }
190  
191  
192 0 ▶sub scatter ($self, $device, $dt, $event) {
Subroutine scatter: not called CC=8 SCAR=42.8
Pod documented
193 0 ▶ return 0 if $self->running;
Branch: 1 branch
BranchTrueFalseTotal
if $self->running 0 0 0
194  
195 0 my ($ev, $chan, $note, $val) = $event->@*;
196  
197 0 ▶ return 0 if defined $self->trigger && defined $note && $note != $self->trigger;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->trigger and defined $note and $note != $self->trigger 0 0 0
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
!ll&&!rl&&r
000
defined $self->trigger and defined $note
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger defined $note $note != $self->trigger
Truth table0%0/4
A and B and C
A= defined $self->triggerB= defined $noteC= $note != $self->trigger
ABCresult
0XX0
10X0
1100
1111
198 0 ▶ return 0 if defined $self->value && defined $val && $val != $self->value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->value and defined $val and $val != $self->value 0 0 0
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
!ll&&!rl&&r
000
defined $self->value and defined $val
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->value and defined $val and $val != $self->value
defined $self->value defined $val $val != $self->value
Truth table0%0/4
A and B and C
A= defined $self->valueB= defined $valC= $val != $self->value
ABCresult
0XX0
10X0
1100
1111
199  
200 0 $self->running(1);
201  
202 0 my $value = $self->initial_point;
203 0 my @values = ($self->range_bottom .. $self->range_top);
204  
205 $self->rtc->loop->add(
206 IO::Async::Timer::Periodic->new(
207 interval => $self->time_step,
208 0 ▶ on_tick => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
209 0 my ($c) = @_;
210 0 ▶ if ($self->halt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->halt) { } 0 0 0
211 0 $c->stop;
212 0 $self->rtc->loop->remove($c);
213 0 $self->running(0);
214 0 $self->halt(0);
215 }
216 else {
217 0 my $cc = [ 'control_change', $self->channel, $self->control, $value ];
218 0 $self->rtc->send_it($cc);
219 0 $value = $values[ int rand @values ];
220 }
221 },
222 0 )->start
223 );
224  
225 0 return $self->continue;
226 }
227  
228  
229 0 ▶sub stair_step ($self, $device, $dt, $event) {
Subroutine stair_step: not called CC=8 SCAR=42.8
Pod documented
230 0 ▶ return 0 if $self->running;
Branch: 1 branch
BranchTrueFalseTotal
if $self->running 0 0 0
231  
232 0 my ($ev, $chan, $note, $val) = $event->@*;
233  
234 0 ▶ return 0 if defined $self->trigger && defined $note && $note != $self->trigger;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->trigger and defined $note and $note != $self->trigger 0 0 0
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
!ll&&!rl&&r
000
defined $self->trigger and defined $note
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger defined $note $note != $self->trigger
Truth table0%0/4
A and B and C
A= defined $self->triggerB= defined $noteC= $note != $self->trigger
ABCresult
0XX0
10X0
1100
1111
235 0 ▶ return 0 if defined $self->value && defined $val && $val != $self->value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->value and defined $val and $val != $self->value 0 0 0
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
!ll&&!rl&&r
000
defined $self->value and defined $val
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->value and defined $val and $val != $self->value
defined $self->value defined $val $val != $self->value
Truth table0%0/4
A and B and C
A= defined $self->valueB= defined $valC= $val != $self->value
ABCresult
0XX0
10X0
1100
1111
236  
237 0 $self->running(1);
238  
239 0 my $it = Iterator::Breathe->new(
240 bottom => $self->range_bottom,
241 top => $self->range_top,
242 );
243  
244 0 my $value = $self->initial_point;
245 0 my $direction = 1; # up
246  
247 $self->rtc->loop->add(
248 IO::Async::Timer::Periodic->new(
249 interval => $self->time_step,
250 0 ▶ on_tick => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
251 0 my ($c) = @_;
252 0 ▶ if ($self->halt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->halt) { } 0 0 0
253 0 $c->stop;
254 0 $self->rtc->loop->remove($c);
255 0 $self->running(0);
256 0 $self->halt(0);
257 }
258 else {
259 0 my $cc = [ 'control_change', $self->channel, $self->control, $value ];
260 0 $self->rtc->send_it($cc);
261  
262 # compute the stair-stepping
263 0 ▶ if ($direction) {
Branch: 1 branch
BranchTrueFalseTotal
if ($direction) { } 0 0 0
264 0 $it->step($self->step_up);
265 }
266 else {
267 0 $it->step(- $self->step_down);
268 }
269  
270 # toggle the stair-step direction
271 0 $direction = !$direction;
272  
273 # iterate the breathing
274 0 $it->iterate;
275 0 $value = $it->i;
276 0 ▶ $value = $self->range_top if $value >= $self->range_top;
Branch: 1 branch
BranchTrueFalseTotal
if $value >= $self->range_top 0 0 0
277 0 ▶ $value = $self->range_bottom if $value <= $self->range_bottom;
Branch: 1 branch
BranchTrueFalseTotal
if $value <= $self->range_bottom 0 0 0
278 }
279 },
280 0 )->start
281 );
282 0 return $self->continue;
283 }
284  
285  
286 0 ▶sub ramp_up ($self, $device, $dt, $event) {
Subroutine ramp_up: not called CC=8 SCAR=42.8
Pod documented
287 0 ▶ return 0 if $self->running;
Branch: 1 branch
BranchTrueFalseTotal
if $self->running 0 0 0
288  
289 0 my ($ev, $chan, $note, $val) = $event->@*;
290  
291 0 ▶ return 0 if defined $self->trigger && defined $note && $note != $self->trigger;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->trigger and defined $note and $note != $self->trigger 0 0 0
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
!ll&&!rl&&r
000
defined $self->trigger and defined $note
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger defined $note $note != $self->trigger
Truth table0%0/4
A and B and C
A= defined $self->triggerB= defined $noteC= $note != $self->trigger
ABCresult
0XX0
10X0
1100
1111
292 0 ▶ return 0 if defined $self->value && defined $val && $val != $self->value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->value and defined $val and $val != $self->value 0 0 0
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
!ll&&!rl&&r
000
defined $self->value and defined $val
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->value and defined $val and $val != $self->value
defined $self->value defined $val $val != $self->value
Truth table0%0/4
A and B and C
A= defined $self->valueB= defined $valC= $val != $self->value
ABCresult
0XX0
10X0
1100
1111
293  
294 0 $self->running(1);
295  
296 0 my $value = $self->initial_point;
297  
298 $self->rtc->loop->add(
299 IO::Async::Timer::Countdown->new(
300 delay => $self->time_step,
301 0 ▶ on_expire => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
302 0 my ($c) = @_;
303 0 ▶ if ($self->halt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->halt) { } 0 0 0
304 0 $c->stop;
305 0 $self->rtc->loop->remove($c);
306 0 $self->running(0);
307 0 $self->halt(0);
308 }
309 else {
310 0 my $cc = [ 'control_change', $self->channel, $self->control, $value ];
311 0 $self->rtc->send_it($cc);
312  
313 0 $value += $self->range_step;
314  
315 0 ▶ if ($value > $self->range_top) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value > $self->range_top) { } 0 0 0
316 0 $c->stop;
317 0 $self->rtc->loop->remove($c);
318 0 $self->running(0);
319 }
320 else {
321 0 $c->start;
322 }
323 }
324 },
325 0 )->start
326 );
327  
328 0 return $self->continue;
329 }
330  
331  
332 0 ▶sub ramp_down ($self, $device, $dt, $event) {
Subroutine ramp_down: not called CC=8 SCAR=42.8
Pod documented
333 0 ▶ return 0 if $self->running;
Branch: 1 branch
BranchTrueFalseTotal
if $self->running 0 0 0
334  
335 0 my ($ev, $chan, $note, $val) = $event->@*;
336  
337 0 ▶ return 0 if defined $self->trigger && defined $note && $note != $self->trigger;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->trigger and defined $note and $note != $self->trigger 0 0 0
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
!ll&&!rl&&r
000
defined $self->trigger and defined $note
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger defined $note $note != $self->trigger
Truth table0%0/4
A and B and C
A= defined $self->triggerB= defined $noteC= $note != $self->trigger
ABCresult
0XX0
10X0
1100
1111
338 0 ▶ return 0 if defined $self->value && defined $val && $val != $self->value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->value and defined $val and $val != $self->value 0 0 0
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
!ll&&!rl&&r
000
defined $self->value and defined $val
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->value and defined $val and $val != $self->value
defined $self->value defined $val $val != $self->value
Truth table0%0/4
A and B and C
A= defined $self->valueB= defined $valC= $val != $self->value
ABCresult
0XX0
10X0
1100
1111
339  
340 0 $self->running(1);
341  
342 0 my $value = $self->initial_point;
343  
344 $self->rtc->loop->add(
345 IO::Async::Timer::Countdown->new(
346 delay => $self->time_step,
347 0 ▶ on_expire => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
348 0 my ($c) = @_;
349 0 ▶ if ($self->halt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->halt) { } 0 0 0
350 0 $c->stop;
351 0 $self->rtc->loop->remove($c);
352 0 $self->running(0);
353 0 $self->halt(0);
354 }
355 else {
356 0 my $cc = [ 'control_change', $self->channel, $self->control, $value ];
357 0 $self->rtc->send_it($cc);
358  
359 0 $value -= $self->range_step;
360  
361 0 ▶ if ($value < $self->range_bottom) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value < $self->range_bottom) { } 0 0 0
362 0 $c->stop;
363 0 $self->rtc->loop->remove($c);
364 0 $self->running(0);
365 }
366 else {
367 0 $c->start;
368 }
369 }
370 },
371 0 )->start
372 );
373  
374 0 return $self->continue;
375 }
376  
377  
378 0 ▶sub flicker ($self, $device, $dt, $event) {
Subroutine flicker: not called CC=8 SCAR=42.8
Pod documented
379 0 ▶ return 0 if $self->running;
Branch: 1 branch
BranchTrueFalseTotal
if $self->running 0 0 0
380  
381 0 my ($ev, $chan, $note, $val) = $event->@*;
382  
383 0 ▶ return 0 if defined $self->trigger && defined $note && $note != $self->trigger;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->trigger and defined $note and $note != $self->trigger 0 0 0
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
!ll&&!rl&&r
000
defined $self->trigger and defined $note
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger defined $note $note != $self->trigger
Truth table0%0/4
A and B and C
A= defined $self->triggerB= defined $noteC= $note != $self->trigger
ABCresult
0XX0
10X0
1100
1111
384 0 ▶ return 0 if defined $self->value && defined $val && $val != $self->value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->value and defined $val and $val != $self->value 0 0 0
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
!ll&&!rl&&r
000
defined $self->value and defined $val
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->value and defined $val and $val != $self->value
defined $self->value defined $val $val != $self->value
Truth table0%0/4
A and B and C
A= defined $self->valueB= defined $valC= $val != $self->value
ABCresult
0XX0
10X0
1100
1111
385  
386 0 $self->running(1);
387  
388 0 my $value = $self->range_bottom;
389  
390 $self->rtc->loop->add(
391 IO::Async::Timer::Countdown->new(
392 delay => $self->time_step,
393 0 ▶ on_expire => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
394 0 my ($c) = @_;
395 0 ▶ if ($self->halt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->halt) { } 0 0 0
396 0 $c->stop;
397 0 $self->rtc->loop->remove($c);
398 0 $self->running(0);
399 0 $self->halt(0);
400 }
401 else {
402 0 my $cc = [ 'control_change', $self->channel, $self->control, $value ];
403 0 $self->rtc->send_it($cc);
404 0 ▶ $value = $value == $self->range_top ? $self->range_bottom : $self->range_top;
Branch: 1 branch
BranchTrueFalseTotal
$value == $self->range_top ? : 0 0 0
405 0 $c->start;
406 }
407 },
408 0 )->start
409 );
410  
411 0 return $self->continue;
412 }
413  
414  
415 0 ▶sub threshold ($self, $device, $dt, $event) {
Subroutine threshold: not called CC=10 SCAR=47.0
Pod documented
416 0 my ($ev, $chan, $note, $val) = $event->@*;
417  
418 0 ▶ return 0 unless defined $self->trigger && defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->trigger and defined $val 0 0 0
Condition0%0/3
defined $self->trigger and defined $val
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->trigger and defined $val
defined $self->trigger defined $val
Truth table0%0/3
A and B
A= defined $self->triggerB= defined $val
ABresult
0X0
100
111
419  
420 0 ▶ my $above_only = $self->step_up && !$self->step_down;
Condition0%0/3
$self->step_up && !$self->step_down
!ll&&!rl&&r
000
MC/DC0%0/2
$self->step_up && !$self->step_down
$self->step_up !$self->step_down
Truth table0%0/3
A && not(B)
A= $self->step_upB= !$self->step_down
ABresult
0X0
100
111
421 0 ▶ my $below_only = $self->step_down && !$self->step_up;
Condition0%0/3
$self->step_down && !$self->step_up
!ll&&!rl&&r
000
MC/DC0%0/2
$self->step_down && !$self->step_up
$self->step_down !$self->step_up
Truth table0%0/3
A && not(B)
A= $self->step_downB= !$self->step_up
ABresult
0X0
100
111
422  
423 0 ▶ if ($above_only && $val <= $self->trigger) {
Branch: 1 branch
BranchTrueFalseTotal
if ($above_only and $val <= $self->trigger) 0 0 0
Condition0%0/3
$above_only and $val <= $self->trigger
!ll&&!rl&&r
000
MC/DC0%0/2
$above_only and $val <= $self->trigger
$above_only $val <= $self->trigger
Truth table0%0/3
A and B
A= $above_onlyB= $val <= $self->trigger
ABresult
0X0
100
111
424 0 return 1; # block: only notes above the trigger are allowed
425 }
426 0 ▶ if ($below_only && $val >= $self->trigger) {
Branch: 1 branch
BranchTrueFalseTotal
if ($below_only and $val >= $self->trigger) 0 0 0
Condition0%0/3
$below_only and $val >= $self->trigger
!ll&&!rl&&r
000
MC/DC0%0/2
$below_only and $val >= $self->trigger
$below_only $val >= $self->trigger
Truth table0%0/3
A and B
A= $below_onlyB= $val >= $self->trigger
ABresult
0X0
100
111
427 0 return 1; # block: only notes below the trigger are allowed
428 }
429  
430 0 ▶ say "Sending $note" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 0 0
431 0 my $msg = [ $ev, $self->channel, $note, $val ];
432 0 $self->rtc->send_it($msg);
433  
434 0 return $self->continue;
435 }
436  
437  
438 0 ▶sub program_change ($self, $device, $dt, $event) {
Subroutine program_change: not called CC=8 SCAR=42.8
Pod documented
439 0 my ($ev, $chan, $note, $val) = $event->@*;
440  
441 0 ▶ return 0 if defined $self->trigger && defined $note && $note != $self->trigger;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->trigger and defined $note and $note != $self->trigger 0 0 0
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
!ll&&!rl&&r
000
defined $self->trigger and defined $note
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger defined $note $note != $self->trigger
Truth table0%0/4
A and B and C
A= defined $self->triggerB= defined $noteC= $note != $self->trigger
ABCresult
0XX0
10X0
1100
1111
442 0 ▶ return 0 if defined $self->value && defined $val && $val != $self->value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->value and defined $val and $val != $self->value 0 0 0
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
!ll&&!rl&&r
000
defined $self->value and defined $val
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->value and defined $val and $val != $self->value
defined $self->value defined $val $val != $self->value
Truth table0%0/4
A and B and C
A= defined $self->valueB= defined $valC= $val != $self->value
ABCresult
0XX0
10X0
1100
1111
443  
444 0 my $program = $self->value;
445  
446 0 ▶ say "Program change: $program" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 0 0
447 0 $self->rtc->send_it([ 'patch_change', $self->channel, $program ]);
448  
449 0 return $self->continue;
450 }
451  
452 2 1;
453  
454 __END__
↑ Summary