Math.pm

filter: Statementstmt 53.1% 25 / 47 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 50.0% 6 / 12 Podpod 100% 1 / 1 totaltotal 38.1% 32 / 84 CC 10 SCAR 33.9
CC
10
Cov
38%
stair_step
72.0
_stair_step_notes
12.0
__ANON__
2.0
CRAP 29.8
« Tonal.pm ↑ Summary
1 package MIDI::RtController::Filter::Math;
2 1 $MIDI::RtController::Filter::Math::VERSION = '0.0503';
3 1 our $AUTHORITY = 'cpan:GENE';
4  
5 # ABSTRACT: Math based RtController filters
6  
7 1 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Types::Standard qw(Num);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Types::Common::Numeric qw(PositiveInt PositiveNum);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 extends 'MIDI::RtController::Filter';
16  
17  
18  
19 has delay => (
20 is => 'rw',
21 isa => PositiveNum,
22 0 ▶ default => sub { 0.1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 1 );
24  
25  
26 has feedback => (
27 is => 'rw',
28 isa => PositiveInt,
29 0 ▶ default => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 1 );
31  
32  
33 has up => (
34 is => 'rw',
35 isa => Num,
36 0 ▶ default => sub { 2 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
37 1 );
38  
39  
40 has down => (
41 is => 'rw',
42 isa => Num,
43 0 ▶ default => sub { -1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 1 );
45  
46  
47 0 ▶sub _stair_step_notes ($self, $note) {
Subroutine _stair_step_notes: not called CC=3 SCAR=24.8
48 0 my @notes;
49 my $factor;
50 0 my $current = $note;
51 0 for my $i (1 .. $self->feedback) {
52 0 ▶ if ($i % 2 == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i % 2 == 0) { } 0 0 0
53 0 $factor = ($i - 1) * $self->down;
54 }
55 else {
56 0 $factor = $i * $self->up;
57 }
58 0 $current += $factor;
59 0 push @notes, $current;
60 }
61 0 return @notes;
62 }
63  
64 0 ▶sub stair_step ($self, $device, $dt, $event) {
Subroutine stair_step: not called CC=8 SCAR=42.8
Pod documented
65 0 my ($ev, $chan, $note, $val) = $event->@*;
66 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
67 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
68  
69 0 my @notes = $self->_stair_step_notes($note);
70 0 my $delay_time = 0;
71 0 for my $n (@notes) {
72 0 $delay_time += $self->delay;
73 0 $self->rtc->delay_send($delay_time, [ $ev, $self->channel, $n, $val ]);
74 }
75 0 return $self->continue;
76 }
77  
78 1 1;
79  
80 __END__
« Tonal.pm ↑ Summary