+ for my $testtranspose(-127..127)
+ {
+ my $toohigh = 0;
+ my $toolow = 0;
+ my $good = 0;
+ for my $channel(sort keys %notes_seen)
+ {
+ next if $channel == 10;
+ for my $program(sort keys %{$notes_seen{$channel}})
+ {
+ for my $note(sort keys %{$notes_seen{$channel}{$program}})
+ {
+ my $cnt = $notes_seen{$channel}{$program}{$note};
+ my $votehigh = 0;
+ my $votelow = 0;
+ my $votegood = 0;
+ for(@busybots_allocated, grep { $_->{count} > 0 } values %$busybots)
+ {
+ next # I won't play on this channel
+ if defined $_->{channels} and not $_->{channels}->{$channel};
+ next # I won't play this program
+ if defined $_->{programs} and not $_->{programs}->{$program};
+ my $transposed = $note - ($_->{transpose} || 0) - $testtranspose;
+ if(exists $_->{notes_on}{$transposed})
+ {
+ ++$votegood;
+ }
+ else
+ {
+ ++$votehigh if $transposed >= 0;
+ ++$votelow if $transposed < 0;
+ }
+ }
+ if($votegood)
+ {
+ $good += $cnt;
+ }
+ elsif($votelow >= $votehigh)
+ {
+ $toolow += $cnt;
+ }
+ else
+ {
+ $toohigh += $cnt;
+ }
+ }
+ }
+ }
+ next if !$toohigh != !$toolow;
+ print STDERR " Transpose $testtranspose: $toohigh too high, $toolow too low, $good good\n";
+ }
+
+ for my $program(sort keys %{$notes_seen{10}})
+ {
+ for my $note(sort keys %{$notes_seen{10}{$program}})
+ {
+ my $cnt = $notes_seen{10}{$program}{$note};
+ my $votegood = 0;
+ for(@busybots_allocated)
+ {
+ next # I won't play on this channel
+ if defined $_->{channels} and not $_->{channels}->{10};
+ next # I won't play this program
+ if defined $_->{programs} and not $_->{programs}->{$program};
+ if(exists $_->{percussion}{$note})
+ {
+ ++$votegood;
+ }
+ }
+ if(!$votegood)
+ {
+ print STDERR "Failed percussion $note ($cnt times)\n";
+ }
+ }
+ }
+