]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
better orchestra helper scripts ;)
authorRudolf Polzer <divverent@xonotic.org>
Wed, 24 Oct 2012 10:32:30 +0000 (12:32 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Wed, 24 Oct 2012 10:32:30 +0000 (12:32 +0200)
misc/tools/midi2cfg-ng.conf.cpp
misc/tools/midichannels.pl [changed mode: 0644->0755]

index 05497e63a5560df100c681ef44dd1d3f8658af45..c4c90c433f1706658fe770417d92285d77d34f09 100644 (file)
@@ -1,7 +1,7 @@
 #define USE_CHEATS
 #undef FAST
 #define BOW
-#undef INDICATORS
+#define INDICATORS
 
 #ifdef FAST
 timeoffset_preinit 0
@@ -1549,7 +1549,7 @@ bot vocals
 #ifdef INDICATORS
                cmd cc usetarget indicator_vocals
 #endif
-               cmd sound 10 %s
+               cmd sound -10 %s
                buttons crouch
                time 0.05
                buttons 
old mode 100644 (file)
new mode 100755 (executable)
index bcfe626..4df6978
@@ -87,6 +87,115 @@ while(<STDIN>)
        {
                print "haha, very funny\n";
        }
+       elsif($cmd eq 'retrack')
+       {
+               my $tracks = $opus->tracks_r();
+               my @newtracks = ();
+               for(0..@$tracks-1)
+               {
+                       for(abstime $tracks->[$_]->events())
+                       {
+                               my $p = $chanpos{$_->[0]};
+                               if(defined $p)
+                               {
+                                       my $c = $_->[$p] + 1;
+                                       push @{$newtracks[$c]}, $_;
+                               }
+                               else
+                               {
+                                       push @{$newtracks[0]}, $_;
+                               }
+                       }
+               }
+               $opus->tracks_r([map { ($_ && @$_) ? MIDI::Track->new({ events => [reltime @$_] }) : () } @newtracks]);
+       }
+       elsif($cmd eq 'program')
+       {
+               my $tracks = $opus->tracks_r();
+               my ($channel, $program) = @arg;
+               for(0..@$tracks-1)
+               {
+                       my @events = ();
+                       my $added = 0;
+                       for(abstime $tracks->[$_]->events())
+                       {
+                               my $p = $chanpos{$_->[0]};
+                               if(defined $p)
+                               {
+                                       my $c = $_->[$p] + 1;
+                                       if($c == $channel)
+                                       {
+                                               next
+                                                       if $_->[0] eq 'patch_change';
+                                               if(!$added)
+                                               {
+                                                       push @events, ['patch_change', $_->[1], $c-1, $program-1]
+                                                               if $program;
+                                                       $added = 1;
+                                               }
+                                       }
+                               }
+                               push @events, $_;
+                       }
+                       $tracks->[$_]->events_r([reltime @events]);
+               }
+       }
+       elsif($cmd eq 'transpose')
+       {
+               my $tracks = $opus->tracks_r();
+               my ($track, $channel, $delta) = @arg;
+               for(($track eq '*') ? (0..@$tracks-1) : $track)
+               {
+                       for($tracks->[$_]->events())
+                       {
+                               my $p = $chanpos{$_->[0]};
+                               if(defined $p)
+                               {
+                                       my $c = $_->[$p] + 1;
+                                       if($channel eq '*' || $c == $channel)
+                                       {
+                                               if($_->[0] eq 'note_on' || $_->[0] eq 'note_off')
+                                               {
+                                                       $_->[3] += $delta;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       elsif($cmd eq 'percussion')
+       {
+               my $tracks = $opus->tracks_r();
+               my %map = @arg;
+               for(0..@$tracks-1)
+               {
+                       my @events = ();
+                       for(abstime $tracks->[$_]->events())
+                       {
+                               my $p = $chanpos{$_->[0]};
+                               if(defined $p)
+                               {
+                                       my $c = $_->[$p] + 1;
+                                       if($c == 10)
+                                       {
+                                               if($_->[0] eq 'note_on' || $_->[0] eq 'note_off')
+                                               {
+                                                       if(length $map{$_->[3]})
+                                                       {
+                                                               $_->[3] = $map{$_->[3]};
+                                                       }
+                                                       elsif(exists $map{$_->[3]})
+                                                       {
+                                                               next;
+                                                       }
+                                               }
+                                       }
+                               }
+                               push @events, $_;
+                       }
+                       $tracks->[$_]->events_r([reltime @events]);
+               }
+       }
        elsif($cmd eq 'tracks')
        {
                my $tracks = $opus->tracks_r();
@@ -127,14 +236,18 @@ while(<STDIN>)
                                        if(defined $p)
                                        {
                                                my $c = $_->[$p] + 1;
-                                               ++$channels{$c};
+                                               $channels{$c} //= {};
+                                               if($_->[0] eq 'patch_change')
+                                               {
+                                                       ++$channels{$c}{$_->[3]};
+                                               }
                                        }
                                        ++$notes if $_->[0] eq 'note_on';
                                        $notehash{$_->[2]}{$_->[3]} = $t if $_->[0] eq 'note_on';
                                        $notehash{$_->[2]}{$_->[3]} = undef if $_->[0] eq 'note_off';
                                        $name = $_->[2] if $_->[0] eq 'track_name';
                                }
-                               my $channels = join " ", sort keys %channels;
+                               my $channels = join " ", map { sprintf "%s(%s)", $_, join ",", sort { $a <=> $b } keys %{$channels{$_}} } sort { $a <=> $b } keys %channels;
                                my @stuck = ();
                                while(my ($k1, $v1) = each %notehash)
                                {
@@ -159,7 +272,15 @@ while(<STDIN>)
        }
        else
        {
-               print "Unknown command, allowed commands: ticks, tracks, clean, save\n";
+               print "Unknown command, allowed commands:\n";
+               print "  clean\n";
+               print "  dump\n";
+               print "  ticks [value]\n";
+               print "  retrack\n";
+               print "  program <channel> <program (1-based)>\n";
+               print "  transpose <track|*> <channel|*> <delta>\n";
+               print "  percussion <from> <to> [<from> <to> ...]\n";
+               print "  tracks [trackno] [trackno] ...\n";
        }
        print "Done with: $cmd @arg\n";
 }