]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
Allow remapping a channel to multiple channels (to duplicate notes).
authorRudolf Polzer <divverent@xonotic.org>
Mon, 12 Oct 2015 00:32:09 +0000 (02:32 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Mon, 12 Oct 2015 00:32:09 +0000 (02:32 +0200)
misc/tools/midichannels.pl

index f86eae4db5e8212a15aa8d2ae0773a7512af4642..5462bbb8ed97cdbe434d76a05e2911de207dc6ec 100755 (executable)
@@ -62,7 +62,11 @@ while(<STDIN>)
        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(<STDIN>)
                                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(<STDIN>)
                        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]);
                }