[nexuiz-commits] r6940 - trunk/misc/tools

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Jun 9 07:41:20 EDT 2009


Author: div0
Date: 2009-06-09 07:41:20 -0400 (Tue, 09 Jun 2009)
New Revision: 6940

Modified:
   trunk/misc/tools/midi2cfg.pl
   trunk/misc/tools/midichannels.pl
Log:
better display of stuck notes


Modified: trunk/misc/tools/midi2cfg.pl
===================================================================
--- trunk/misc/tools/midi2cfg.pl	2009-06-09 11:19:58 UTC (rev 6939)
+++ trunk/misc/tools/midi2cfg.pl	2009-06-09 11:41:20 UTC (rev 6940)
@@ -115,6 +115,8 @@
 			&&
 			$time > $l->[$_]{busytime};
 	}
+	use Data::Dumper;
+	print STDERR Dumper $l;
 	die "No free channel found ($notes notes active)\n";
 }
 
@@ -365,7 +367,5 @@
 }
 if($n)
 {
-	use Data::Dumper;
-	print STDERR Dumper \%midinotes;
 	die "$n channels blocked ($notes MIDI notes)";
 }

Modified: trunk/misc/tools/midichannels.pl
===================================================================
--- trunk/misc/tools/midichannels.pl	2009-06-09 11:19:58 UTC (rev 6939)
+++ trunk/misc/tools/midichannels.pl	2009-06-09 11:41:20 UTC (rev 6940)
@@ -61,8 +61,11 @@
 				my $name = undef;
 				my %channels = ();
 				my $notes = 0;
+				my %notehash = ();
+				my $t = 0;
 				for($tracks->[$_]->events())
 				{
+					$t += $_->[1];
 					my $p = $chanpos{$_->[0]};
 					if(defined $p)
 					{
@@ -70,12 +73,24 @@
 						++$channels{$c};
 					}
 					++$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 @stuck = ();
+				while(my ($k1, $v1) = each %notehash)
+				{
+					while(my ($k2, $v2) = each %$v1)
+					{
+						push @stuck, sprintf "%d:%d@%.1f%%", $k1+1, $k2, $v2 * 100.0 / $t
+							if defined $v2;
+					}
+				}
 				print " $name" if defined $name;
 				print " (channel $channels)" if $channels ne "";
 				print " ($notes notes)" if $notes;
+				print " (notes @stuck stuck)" if @stuck;
 				print "\n";
 			}
 		}



More information about the nexuiz-commits mailing list