From: Rudolf Polzer Date: Thu, 25 Oct 2012 12:52:55 +0000 (+0200) Subject: midichannels script: more commands X-Git-Tag: xonotic-v0.7.0~34^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ad3995c957915b2b4c4c5febfa2c3c9767adb00f;p=xonotic%2Fxonotic.git midichannels script: more commands --- diff --git a/misc/tools/midichannels.pl b/misc/tools/midichannels.pl index 4df6978b..cebf7ec9 100755 --- a/misc/tools/midichannels.pl +++ b/misc/tools/midichannels.pl @@ -112,8 +112,8 @@ while() elsif($cmd eq 'program') { my $tracks = $opus->tracks_r(); - my ($channel, $program) = @arg; - for(0..@$tracks-1) + my ($track, $channel, $program) = @arg; + for(($track eq '*') ? (0..@$tracks-1) : $track) { my @events = (); my $added = 0; @@ -123,7 +123,7 @@ while() if(defined $p) { my $c = $_->[$p] + 1; - if($c == $channel) + if($channel eq '*' || $c == $channel) { next if $_->[0] eq 'patch_change'; @@ -163,11 +163,34 @@ while() } } } + elsif($cmd eq 'channel') + { + my $tracks = $opus->tracks_r(); + my ($track, %chanmap) = @arg; + for(($track eq '*') ? (0..@$tracks-1) : $track) + { + my @events = (); + for(abstime $tracks->[$_]->events()) + { + my $p = $chanpos{$_->[0]}; + if(defined $p) + { + my $c = $_->[$p] + 1; + $c = $chanmap{$c} // $chanmap{'*'} // $c; + next + if $c == 0; # kill by setting channel to 0 + $_->[$p] = $c - 1; + } + push @events, $_; + } + $tracks->[$_]->events_r([reltime @events]); + } + } elsif($cmd eq 'percussion') { my $tracks = $opus->tracks_r(); - my %map = @arg; - for(0..@$tracks-1) + my ($track, $channel, %map) = @arg; + for(($track eq '*') ? (0..@$tracks-1) : $track) { my @events = (); for(abstime $tracks->[$_]->events()) @@ -176,7 +199,7 @@ while() if(defined $p) { my $c = $_->[$p] + 1; - if($c == 10) + if($channel eq '*' || $c == $channel) { if($_->[0] eq 'note_on' || $_->[0] eq 'note_off') { @@ -277,9 +300,10 @@ while() print " dump\n"; print " ticks [value]\n"; print " retrack\n"; - print " program \n"; + print " program \n"; print " transpose \n"; - print " percussion [ ...]\n"; + print " channel [ ...]\n"; + print " percussion [ ...]\n"; print " tracks [trackno] [trackno] ...\n"; } print "Done with: $cmd @arg\n";