| 1 | package MIDI::RtController::Filter::Math; | ||||||||||||||||||||||||||||
| 2 | 1 | $MIDI::RtController::Filter::Math::VERSION = '0.0403'; | |||||||||||||||||||||||||||
| 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 | ▶ | 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
| |||||||||||||||||||||||||||||
| 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 | ▶ | sub stair_step ($self, $device, $dt, $event) { | |||||||||||||||||||||||||||
|
Subroutine
stair_step: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 65 | 0 | my ($ev, $chan, $note, $val) = $event->@*; | |||||||||||||||||||||||||||
| 66 | 0 | ▶ | return 0 if defined $self->trigger && $note != $self->trigger; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->trigger and $note != $self->trigger
MC/DC0%0/2
defined $self->trigger and $note != $self->trigger
defined $self->trigger
$note != $self->trigger
Truth table0%0/3
A and B
A= defined $self->triggerB= $note != $self->trigger
| |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | return 0 if defined $self->value && $val != $self->value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->value and $val != $self->value
MC/DC0%0/2
defined $self->value and $val != $self->value
defined $self->value
$val != $self->value
Truth table0%0/3
A and B
A= defined $self->valueB= $val != $self->value
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||