From: Rudolf Polzer Date: Mon, 12 Oct 2015 00:32:09 +0000 (+0200) Subject: Allow remapping a channel to multiple channels (to duplicate notes). X-Git-Tag: xonotic-v0.8.2~31 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=76f7de9fe0f9aea6a3087df42f3f1cdfffd2a1bb;p=xonotic%2Fxonotic.git Allow remapping a channel to multiple channels (to duplicate notes). --- diff --git a/misc/tools/midichannels.pl b/misc/tools/midichannels.pl index f86eae4d..5462bbb8 100755 --- a/misc/tools/midichannels.pl +++ b/misc/tools/midichannels.pl @@ -62,7 +62,11 @@ while() my @arg = split /\s+/, $_; my $cmd = shift @arg; print "Executing: $cmd @arg\n"; - if($cmd eq 'clean') + if($cmd eq '#') + { + # Just a comment. + } + elsif($cmd eq 'clean') { my $tracks = $opus->tracks_r(); $tracks->[$_]->events_r([clean($tracks->[$_]->events())]) @@ -152,7 +156,7 @@ while() if(defined $p) { my $c = $_->[$p] + 1; - if($channel eq '*' || $c == $channel) + if($channel eq '*' ? $c != 10 : $c == $channel) { if($_->[0] eq 'note_on' || $_->[0] eq 'note_off') { @@ -173,15 +177,20 @@ while() for(abstime $tracks->[$_]->events()) { my $p = $chanpos{$_->[0]}; - if(defined $p) + if(!defined $p) { - my $c = $_->[$p] + 1; - $c = $chanmap{$c} // $chanmap{'*'} // $c; + push @events, $_; + next; + } + my $c = $_->[$p] + 1; + my @c = split /,/, ($chanmap{$c} // $chanmap{'*'} // $c); + for my $c(@c) { next if $c == 0; # kill by setting channel to 0 - $_->[$p] = $c - 1; + my @copy = @$_; + $copy[$p] = $c - 1; + push @events, \@copy; } - push @events, $_; } $tracks->[$_]->events_r([reltime @events]); }