| 1 | package MIDI::RtController::Filter::Tonal; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:GENE'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Tonal RtController filters | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | our $VERSION = '0.0503'; | |||||||||||||||||||||||||||||||||||||||||
| 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 Array::Circular (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use List::SomeUtils qw(first_index); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use List::Util qw(shuffle uniq); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use Music::Scales qw(get_scale_MIDI get_scale_notes); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Music::Chord::Note (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Music::Note (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use Music::ToRoman (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Music::VoiceGen (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use Types::Common::Numeric qw(NegativeInt PositiveInt PositiveNum); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use Types::MIDI qw(Velocity); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use Types::Standard qw(ArrayRef InstanceOf Num Maybe Str); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use constant KNOWN_FILTERS => qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | pedal_tone chord_tone delay_tone offset_tone walk_tone arp_tone | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | extends 'MIDI::RtController::Filter'; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | has pedal => ( | ||||||||||||||||||||||||||||||||||||||||||
| 36 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | isa => Velocity, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | default => sub { 55 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | has delay => ( | ||||||||||||||||||||||||||||||||||||||||||
| 43 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | isa => Num, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | default => sub { 0.1 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | has factor => ( | ||||||||||||||||||||||||||||||||||||||||||
| 50 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | isa => Maybe[Num], | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | default => sub { undef }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | has velocity => ( | ||||||||||||||||||||||||||||||||||||||||||
| 57 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 58 | isa => Velocity, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | default => sub { 10 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | has feedback => ( | ||||||||||||||||||||||||||||||||||||||||||
| 64 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 65 | isa => PositiveInt, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | default => sub { 1 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | has offset => ( | ||||||||||||||||||||||||||||||||||||||||||
| 71 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 72 | isa => NegativeInt | PositiveInt, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | default => sub { -12 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | has key => ( | ||||||||||||||||||||||||||||||||||||||||||
| 78 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 79 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | default => sub { 'C' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | has scale => ( | ||||||||||||||||||||||||||||||||||||||||||
| 85 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 86 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | default => sub { 'major' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | has intervals => ( | ||||||||||||||||||||||||||||||||||||||||||
| 92 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 93 | isa => ArrayRef[NegativeInt | PositiveInt], | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | default => sub { [qw(-3 -2 -1 1 2 3)] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | has arp => ( | ||||||||||||||||||||||||||||||||||||||||||
| 99 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 100 | isa => ArrayRef[Velocity], | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | has arp_types => ( | ||||||||||||||||||||||||||||||||||||||||||
| 106 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 107 | isa => InstanceOf['Array::Circular'], | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | default => sub { Array::Circular->new(qw(up down updown random converge diverge)) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | has arp_type => ( | ||||||||||||||||||||||||||||||||||||||||||
| 113 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 114 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | default => sub { 'up' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub add_filters ($filters, $controllers) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_filters: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | for my $orig (@$filters) { | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my %params = %$orig; # work on a copy, don't mutate the caller's hashref | |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $port = delete $params{port}; | |||||||||||||||||||||||||||||||||||||||||
| 123 | # skip unnamed and unknown entries | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | next if !$port || !exists $controllers->{$port}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$port and exists $controllers->{$port}
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}
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | my $type = delete $params{type} || 'delay_tone'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $params{'type'} || 'delay_tone'
MC/DC0%0/1
delete $params{'type'} || 'delay_tone'
delete $params{'type'}
Truth table0%0/2
A
A= delete $params{'type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | croak qq{Unknown filter type "$type" (must be one of: } . join(', ', KNOWN_FILTERS) . ')' | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | unless grep { $_ eq $type } KNOWN_FILTERS; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | my $event = delete $params{event} || 'all'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $params{'event'} || 'all'
MC/DC0%0/1
delete $params{'event'} || 'all'
delete $params{'event'}
Truth table0%0/2
A
A= delete $params{'event'}
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | my $filter = __PACKAGE__->new( | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | rtc => $controllers->{$port} | |||||||||||||||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 132 | # assume all remaining key/values are module attributes | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | for my $param (keys %params) { | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $filter->$param($params{$param}); | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $method = "curry::$type"; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $controllers->{$port}->add_filter($type, $event => $filter->$method); | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub _pedal_notes ($self, $note) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pedal_notes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | return $self->pedal, $note, $note + 7; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub pedal_tone ($self, $device, $dt, $event) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pedal_tone: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my ($ev, $chan, $note, $val) = $event->@*; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | return 0 if defined $self->trigger && defined $note && $note != $self->trigger; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger and defined $note
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
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | return 0 if defined $self->value && defined $val && $val != $self->value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
defined $self->value and defined $val
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
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my @notes = $self->_pedal_notes($note); | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $delay_time = 0; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | for my $n (@notes) { | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $delay_time += $self->delay; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | $delay_time *= $self->factor if defined $self->factor; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $self->rtc->delay_send($delay_time, [ $ev, $self->channel, $n, $val ]); | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | return $self->continue; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub _chord_notes ($self, $note) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_chord_notes: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $mn = Music::Note->new($note, 'midinum'); | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $base = uc($mn->format('isobase')); | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my @scale = get_scale_notes($self->key, $self->scale); | |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | my $index = first_index { $_ eq $base } @scale; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | return $note if $index == -1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my $mtr = Music::ToRoman->new(scale_note => $base); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my @chords = $mtr->get_scale_chords; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $chord = $scale[$index] . $chords[$index]; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $cn = Music::Chord::Note->new; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my @notes = $cn->chord_with_octave($chord, $mn->octave); | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | @notes = map { Music::Note->new($_, 'ISO')->format('midinum') } @notes; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | return @notes; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub chord_tone ($self, $device, $dt, $event) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chord_tone: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my ($ev, $chan, $note, $val) = $event->@*; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | return 0 if defined $self->trigger && defined $note && $note != $self->trigger; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger and defined $note
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
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | return 0 if defined $self->value && defined $val && $val != $self->value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
defined $self->value and defined $val
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
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my @notes = $self->_chord_notes($note); | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $self->rtc->send_it([ $ev, $self->channel, $_, $val ]) for @notes; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | return $self->continue; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub _delay_notes ($self, $note) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_delay_notes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | return ($note) x $self->feedback; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub delay_tone ($self, $device, $dt, $event) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delay_tone: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my ($ev, $chan, $note, $val) = $event->@*; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | return 0 if defined $self->trigger && defined $note && $note != $self->trigger; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger and defined $note
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
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | return 0 if defined $self->value && defined $val && $val != $self->value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
defined $self->value and defined $val
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
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my @notes = $self->_delay_notes($note); | |||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $delay_time = 0; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | for my $n (@notes) { | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $delay_time += $self->delay; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $delay_time *= $self->factor if defined $self->factor; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $self->rtc->delay_send($delay_time, [ $ev, $self->channel, $n, $val ]); | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $val -= $self->velocity; | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | return $self->continue; | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub _offset_notes ($self, $note) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_offset_notes: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my @notes = ($note); | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | push @notes, $note + $self->offset if $self->offset; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | return @notes; | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub offset_tone ($self, $device, $dt, $event) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset_tone: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my ($ev, $chan, $note, $val) = $event->@*; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | return 0 if defined $self->trigger && defined $note && $note != $self->trigger; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger and defined $note
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
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | return 0 if defined $self->value && defined $val && $val != $self->value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
defined $self->value and defined $val
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
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my @notes = $self->_offset_notes($note); | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->rtc->send_it([ $ev, $self->channel, $_, $val ]) for @notes; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | return $self->continue; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | sub _walk_notes ($self, $note) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_walk_notes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my $mn = Music::Note->new($note, 'midinum'); | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my @pitches = ( | |||||||||||||||||||||||||||||||||||||||||
| 225 | get_scale_MIDI($self->key, $mn->octave, $self->scale), | ||||||||||||||||||||||||||||||||||||||||||
| 226 | get_scale_MIDI($self->key, $mn->octave + 1, $self->scale), | ||||||||||||||||||||||||||||||||||||||||||
| 227 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $voice = Music::VoiceGen->new( | |||||||||||||||||||||||||||||||||||||||||
| 229 | pitches => \@pitches, | ||||||||||||||||||||||||||||||||||||||||||
| 230 | intervals => $self->intervals, | ||||||||||||||||||||||||||||||||||||||||||
| 231 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my @notes = map { $voice->rand } 1 .. $self->feedback; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return @notes; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub walk_tone ($self, $device, $dt, $event) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
walk_tone: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my ($ev, $chan, $note, $val) = $event->@*; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | return 0 if defined $self->trigger && defined $note && $note != $self->trigger; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger and defined $note
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
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | return 0 if defined $self->value && defined $val && $val != $self->value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
defined $self->value and defined $val
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
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | # make sure the note_on and note_off notes are the same | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $notes = $self->arp; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if (@$notes) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $self->arp([]); | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | @$notes = $self->_walk_notes($note); | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $self->arp($notes); | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $delay_time = 0; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | for my $n (@$notes) { | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $delay_time += $self->delay; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | $delay_time *= $self->factor if defined $self->factor; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $self->rtc->delay_send($delay_time, [ $ev, $self->channel, $n, $val ]); | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | return $self->continue; | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | sub _arp_notes ($self, $note) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_arp_notes: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | $self->feedback(2) if $self->feedback < 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my @tmp = $self->arp->@*; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if (@tmp >= 2 * $self->feedback) { # double, on/off note event | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | shift @tmp; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | shift @tmp; | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | push @tmp, $note; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $self->arp(\@tmp); | |||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my @notes = uniq @tmp; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if ($self->arp_type eq 'up') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | @notes = sort { $a <=> $b } @notes; | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | elsif ($self->arp_type eq 'down') { | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | @notes = sort { $b <=> $a } @notes; | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | elsif ($self->arp_type eq 'random') { | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | @notes = shuffle @notes; | |||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | return @notes; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub arp_tone ($self, $device, $dt, $event) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arp_tone: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my ($ev, $chan, $note, $val) = $event->@*; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | return 0 if defined $self->trigger && defined $note && $note != $self->trigger; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->trigger and defined $note and $note != $self->trigger
defined $self->trigger and defined $note
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
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | return 0 if defined $self->value && defined $val && $val != $self->value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->value and defined $val and $val != $self->value
defined $self->value and defined $val
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
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my @notes = $self->_arp_notes($note); | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my $delay_time = 0; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | for my $n (@notes) { | |||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $self->rtc->delay_send($delay_time, [ $ev, $self->channel, $n, $val ]); | |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $delay_time += $self->delay; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | $delay_time *= $self->factor if defined $self->factor; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | return $self->continue; | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | __END__ | ||||||||||||||||||||||||||||||||||||||||||