From 1fb1f7e2353c073900504289118f71bfa10b5b31 Mon Sep 17 00:00:00 2001 From: div0 Date: Tue, 9 Jun 2009 11:41:20 +0000 Subject: [PATCH] better display of stuck notes git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6940 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- misc/tools/midi2cfg.pl | 4 ++-- misc/tools/midichannels.pl | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/misc/tools/midi2cfg.pl b/misc/tools/midi2cfg.pl index 50d7a11cc..a9ea6458d 100644 --- a/misc/tools/midi2cfg.pl +++ b/misc/tools/midi2cfg.pl @@ -115,6 +115,8 @@ sub busybot_findfree($$$) && $time > $l->[$_]{busytime}; } + use Data::Dumper; + print STDERR Dumper $l; die "No free channel found ($notes notes active)\n"; } @@ -365,7 +367,5 @@ for(@busybots_percussion, @busybots_tuba) } if($n) { - use Data::Dumper; - print STDERR Dumper \%midinotes; die "$n channels blocked ($notes MIDI notes)"; } diff --git a/misc/tools/midichannels.pl b/misc/tools/midichannels.pl index 4a81774d5..f1ccc7747 100644 --- a/misc/tools/midichannels.pl +++ b/misc/tools/midichannels.pl @@ -61,8 +61,11 @@ while() 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 @@ while() ++$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"; } } -- 2.39.2