3 # converter from Type 1 MIDI files to CFG files that control bots with the Tuba and other weapons for percussion (requires g_weaponarena all)
11 # workaround for possible refire time problems
12 use constant SYS_TICRATE => 0.033333;
13 #use constant SYS_TICRATE => 0;
15 use constant MIDI_FIRST_NONCHANNEL => 17;
16 use constant MIDI_DRUMS_CHANNEL => 10;
18 die "Usage: $0 filename.conf midifile1 transpose1 midifile2 transpose2 ..."
19 unless @ARGV > 1 and @ARGV % 2;
21 my $timeoffset_preinit = 2;
22 my $timeoffset_postinit = 2;
23 my $timeoffset_predone = 2;
24 my $timeoffset_postdone = 2;
25 my $timeoffset_preintermission = 2;
26 my $timeoffset_postintermission = 2;
27 my $time_forgetfulness = 1.5;
31 my ($config, @midilist) = @ARGV;
35 return map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, rand] } @_;
41 my ($dest, $src) = @_;
42 if(ref $src eq 'HASH')
48 $dest->{$_} = override $dest->{$_}, $src->{$_};
51 elsif(ref $src eq 'ARRAY')
57 push @$dest, override undef, $_;
62 $dest = Storable::dclone $src;
74 my @busybots_allocated;
78 my $lowestnotestart = undef;
87 my $currentbot = undef;
88 my $appendref = undef;
97 my @cmd = split /\s+/, $_;
98 if($cmd[0] eq 'super')
100 push @$appendref, @$super
103 elsif($cmd[0] eq 'percussion') # simple import
105 push @$appendref, @{$currentbot->{percussion}->{$cmd[1]}};
109 push @$appendref, \@cmd;
116 my $base = $bots{$1};
117 $currentbot = override $currentbot, $base;
119 elsif(/^count (\d+)/)
121 $currentbot->{count} = $1;
123 elsif(/^transpose (\d+)/)
125 $currentbot->{transpose} ||= 0;
126 $currentbot->{transpose} += $1;
128 elsif(/^channels (.*)/)
130 $currentbot->{channels} = { map { $_ => 1 } split /\s+/, $1 };
132 elsif(/^programs (.*)/)
134 $currentbot->{programs} = { map { $_ => 1 } split /\s+/, $1 };
138 $super = $currentbot->{init};
139 $currentbot->{init} = $appendref = [];
141 elsif(/^intermission$/)
143 $super = $currentbot->{intermission};
144 $currentbot->{intermission} = $appendref = [];
148 $super = $currentbot->{done};
149 $currentbot->{done} = $appendref = [];
151 elsif(/^note on (-?\d+)/)
153 $super = $currentbot->{notes_on}->{$1};
154 $currentbot->{notes_on}->{$1} = $appendref = [];
156 elsif(/^note off (-?\d+)/)
158 $super = $currentbot->{notes_off}->{$1};
159 $currentbot->{notes_off}->{$1} = $appendref = [];
161 elsif(/^percussion (\d+)/)
163 $super = $currentbot->{percussion}->{$1};
164 $currentbot->{percussion}->{$1} = $appendref = [];
168 $super = $currentbot->{vocals};
169 $currentbot->{vocals} = $appendref = [];
173 print "unknown command: $_\n";
178 $currentbot = ($bots{$1} ||= {count => 0});
182 $precommands .= "$1\n";
184 elsif(/^timeoffset_preinit (.*)/)
186 $timeoffset_preinit = $1;
188 elsif(/^timeoffset_postinit (.*)/)
190 $timeoffset_postinit = $1;
192 elsif(/^timeoffset_predone (.*)/)
194 $timeoffset_predone = $1;
196 elsif(/^timeoffset_postdone (.*)/)
198 $timeoffset_postdone = $1;
200 elsif(/^timeoffset_preintermission (.*)/)
202 $timeoffset_preintermission = $1;
204 elsif(/^timeoffset_postintermission (.*)/)
206 $timeoffset_postintermission = $1;
208 elsif(/^time_forgetfulness (.*)/)
210 $time_forgetfulness = $1;
212 elsif(/^list (.*?) (.*)/)
214 $lists{$1} = [split / /, $2];
215 $listindexes{$1} = 0;
219 print "unknown command: $_\n";
225 for(values %{$_->{notes_on}}, values %{$_->{percussion}})
227 my $t = $_->[0]->[0] eq 'time' ? $_->[0]->[1] : 0;
228 $lowestnotestart = $t if not defined $lowestnotestart or $t < $lowestnotestart;
234 my $busybots_orig = botconfig_read $config;
237 # returns: ($mintime, $maxtime, $busytime)
238 sub busybot_cmd_bot_cmdinfo(@)
244 my $busytime = undef;
248 if($_->[0] eq 'time')
251 if not defined $mintime or $_->[1] < $mintime;
252 $maxtime = $_->[1] + SYS_TICRATE
253 if not defined $maxtime or $_->[1] + SYS_TICRATE > $maxtime;
255 elsif($_->[0] eq 'busy')
257 $busytime = $_->[1] + SYS_TICRATE;
261 return ($mintime, $maxtime, $busytime);
264 sub busybot_cmd_bot_matchtime($$$@)
266 my ($bot, $targettime, $targetbusytime, @commands) = @_;
268 # I want to execute @commands so that I am free on $targettime and $targetbusytime
269 # when do I execute it then?
271 my ($mintime, $maxtime, $busytime) = busybot_cmd_bot_cmdinfo @commands;
273 my $tstart_max = defined $maxtime ? $targettime - $maxtime : $targettime;
274 my $tstart_busy = defined $busytime ? $targetbusytime - $busytime : $targettime;
276 return $tstart_max < $tstart_busy ? $tstart_max : $tstart_busy;
279 # TODO function to find out whether, and when, to insert a command before another command to make it possible
280 # (note-off before note-on)
282 sub busybot_cmd_bot_test($$$@)
284 my ($bot, $time, $force, @commands) = @_;
286 my $bottime = defined $bot->{timer} ? $bot->{timer} : -1;
287 my $botbusytime = defined $bot->{busytimer} ? $bot->{busytimer} : -1;
289 my ($mintime, $maxtime, $busytime) = busybot_cmd_bot_cmdinfo @commands;
291 if($time < $botbusytime)
293 warn "FORCE: $time < $botbusytime"
298 if(defined $mintime and $time + $mintime < $bottime)
300 warn "FORCE: $time + $mintime < $bottime"
315 ? do { $lists{$1}[$listindexes{$1}++ % @{$lists{$1}}]; }
321 sub busybot_cmd_bot_execute($$@)
323 my ($bot, $time, @commands) = @_;
327 if($_->[0] eq 'time')
329 $commands .= sprintf "sv_cmd bot_cmd %d wait_until %f\n", $bot->{id}, $time + $_->[1];
330 if($bot->{timer} > $time + $_->[1] + SYS_TICRATE)
332 #use Carp; carp "Negative wait: $bot->{timer} <= @{[$time + $_->[1] + SYS_TICRATE]}";
334 $bot->{timer} = $time + $_->[1] + SYS_TICRATE;
336 elsif($_->[0] eq 'busy')
338 $bot->{busytimer} = $time + $_->[1] + SYS_TICRATE;
340 elsif($_->[0] eq 'buttons')
342 my %buttons_release = %{$bot->{buttons} ||= {}};
346 delete $buttons_release{$1};
348 for(keys %buttons_release)
350 $commands .= sprintf "sv_cmd bot_cmd %d releasekey %s\n", $bot->{id}, $_;
351 delete $bot->{buttons}->{$_};
357 $commands .= sprintf "sv_cmd bot_cmd %d presskey %s\n", $bot->{id}, $_;
358 $bot->{buttons}->{$_} = 1;
361 elsif($_->[0] eq 'cmd')
363 $commands .= sprintf "sv_cmd bot_cmd %d %s\n", $bot->{id}, buildstring @{$_}[1..@$_-1];
365 elsif($_->[0] eq 'aim_random')
367 $commands .= sprintf "sv_cmd bot_cmd %d aim \"%f 0 %f\"\n", $bot->{id}, $_->[1] + rand($_->[2] - $_->[1]), $_->[3];
369 elsif($_->[0] eq 'barrier')
371 $commands .= sprintf "sv_cmd bot_cmd %d barrier\n", $bot->{id};
372 $bot->{timer} = $bot->{busytimer} = 0;
373 undef $bot->{lastuse};
375 elsif($_->[0] eq 'raw')
377 $commands .= sprintf "%s\n", buildstring @{$_}[1..@$_-1];
384 my $intermissions = 0;
386 sub busybot_intermission_bot($)
389 busybot_cmd_bot_execute $bot, 0, ['cmd', 'wait', $timeoffset_preintermission];
390 busybot_cmd_bot_execute $bot, 0, ['barrier'];
391 if($bot->{intermission})
393 busybot_cmd_bot_execute $bot, 0, @{$bot->{intermission}};
395 busybot_cmd_bot_execute $bot, 0, ['barrier'];
396 $notetime = $timeoffset_postintermission - $lowestnotestart;
400 sub busybot_note_off_bot($$$$)
402 my ($bot, $time, $channel, $note) = @_;
403 #print STDERR "note off $bot:$time:$channel:$note\n";
404 my ($busychannel, $busynote, $cmds) = @{$bot->{busy}};
406 if not defined $cmds; # note off cannot fail
407 die "Wrong note-off?!?"
408 if $busychannel != $channel || $busynote ne $note;
409 $bot->{busy} = undef;
411 my $t = $time + $notetime;
412 my ($mintime, $maxtime, $busytime) = busybot_cmd_bot_cmdinfo @$cmds;
414 # perform note-off "as soon as we can"
415 $t = $bot->{busytimer}
416 if $t < $bot->{busytimer};
417 $t = $bot->{timer} - $mintime
418 if $t < $bot->{timer} - $mintime;
420 busybot_cmd_bot_execute $bot, $t, @$cmds;
424 sub busybot_get_cmds_bot($$$)
426 my ($bot, $channel, $note) = @_;
427 my ($k0, $k1, $cmds, $cmds_off) = (undef, undef, undef, undef);
431 $cmds = $bot->{vocals};
434 $cmds = [ map { [ map { $_ eq '%s' ? $note : $_ } @$_ ] } @$cmds ];
439 elsif($channel == 10)
442 $cmds = $bot->{percussion}->{$note};
449 $cmds = $bot->{notes_on}->{$note - ($bot->{transpose} || 0) - $transpose};
450 $cmds_off = $bot->{notes_off}->{$note - ($bot->{transpose} || 0) - $transpose};
452 $k1 = $note - ($bot->{transpose} || 0) - $transpose;
454 return ($cmds, $cmds_off, $k0, $k1);
457 sub busybot_note_on_bot($$$$$$$)
459 my ($bot, $time, $channel, $program, $note, $init, $force) = @_;
460 return -1 # I won't play on this channel
461 if defined $bot->{channels} and not $bot->{channels}->{$channel};
462 return -1 # I won't play this program
463 if defined $bot->{programs} and not $bot->{programs}->{$program};
465 my ($cmds, $cmds_off, $k0, $k1) = busybot_get_cmds_bot($bot, $channel, $note);
467 return -1 # I won't play this note
468 if not defined $cmds;
471 #print STDERR "note on $bot:$time:$channel:$note\n";
475 if not busybot_cmd_bot_test $bot, $time + $notetime, $force, @$cmds;
476 busybot_cmd_bot_execute $bot, 0, ['cmd', 'wait', $timeoffset_preinit];
477 busybot_cmd_bot_execute $bot, 0, ['barrier'];
478 busybot_cmd_bot_execute $bot, 0, @{$bot->{init}}
480 busybot_cmd_bot_execute $bot, 0, ['barrier'];
481 for(1..$intermissions)
483 busybot_intermission_bot $bot;
485 # we always did a barrier, so we know this works
486 busybot_cmd_bot_execute $bot, $time + $notetime, @$cmds;
491 if not busybot_cmd_bot_test $bot, $time + $notetime, $force, @$cmds;
492 busybot_cmd_bot_execute $bot, $time + $notetime, @$cmds;
494 if(defined $cmds and defined $cmds_off)
496 $bot->{busy} = [$channel, $note, $cmds_off];
498 ++$bot->{seen}{$k0}{$k1};
500 if(($bot->{lastuse} // -666) >= $time - $time_forgetfulness && $channel == $bot->{lastchannel})
502 $bot->{lastchannelsequence} += 1;
506 $bot->{lastchannelsequence} = 1;
508 $bot->{lastuse} = $time;
509 $bot->{lastchannel} = $channel;
511 # print STDERR "$time $bot->{id} $channel:$note\n"
519 $busybots = Storable::dclone $busybots_orig;
520 @busybots_allocated = ();
521 %notechannelbots = ();
523 $notetime = $timeoffset_postinit - $lowestnotestart;
526 sub busybot_note_off($$$)
528 my ($time, $channel, $note) = @_;
530 # print STDERR "note off $time:$channel:$note\n";
537 if(my $bot = $notechannelbots{$channel}{$note})
539 busybot_note_off_bot $bot, $time, $channel, $note;
540 delete $notechannelbots{$channel}{$note};
549 my ($time, $channel, $program, $note, @bots) = @_;
559 ($a->[0]->{lastuse} // -666) <=> ($b->[0]->{lastuse} // -666)
566 if($channel != 10) # percussion just should do round robin
568 if(($_->{lastuse} // -666) >= $time - $time_forgetfulness)
570 if($channel == $_->{lastchannel})
572 $q += $_->{lastchannelsequence};
576 # better leave this one alone
577 $q -= $_->{lastchannelsequence};
586 sub busybot_note_on($$$$)
588 my ($time, $channel, $program, $note) = @_;
590 if($notechannelbots{$channel}{$note})
592 busybot_note_off $time, $channel, $note;
595 # print STDERR "note on $time:$channel:$note\n";
599 my @epicfailbots = ();
601 for(botsort $time, $channel, $program, $note, @busybots_allocated)
603 my $canplay = busybot_note_on_bot $_, $time, $channel, $program, $note, 0, 0;
606 $notechannelbots{$channel}{$note} = $_;
609 push @epicfailbots, $_
616 for(unsort keys %$busybots)
618 next if $busybots->{$_}->{count} <= 0;
619 my $bot = Storable::dclone $busybots->{$_};
620 $bot->{id} = @busybots_allocated + 1;
621 $bot->{classname} = $_;
622 my $canplay = busybot_note_on_bot $bot, $time, $channel, $program, $note, 1, 0;
631 --$busybots->{$_}->{count};
632 $notechannelbots{$channel}{$note} = $bot;
633 push @busybots_allocated, $bot;
637 die "Fresh bot cannot play stuff"
643 # we cannot add a new bot to play this
644 # we could try finding a bot that could play this, and force him to stop the note!
646 my @candidates = (); # contains: [$bot, $score, $offtime]
648 # put in all currently busy bots that COULD play this, if they did a note-off first
649 for my $bot(@epicfailbots)
652 if $busybots->{$bot->{classname}}->{count} != 0;
655 my ($busy_chan, $busy_note, $busy_cmds_off) = @{$bot->{busy}};
657 unless $busy_cmds_off;
658 my ($cmds, $cmds_off, $k0, $k1) = busybot_get_cmds_bot $bot, $channel, $note;
661 my ($mintime, $maxtime, $busytime) = busybot_cmd_bot_cmdinfo @$cmds;
662 my ($mintime_off, $maxtime_off, $busytime_off) = busybot_cmd_bot_cmdinfo @$busy_cmds_off;
664 my $noteofftime = busybot_cmd_bot_matchtime $bot, $time + $notetime + $mintime, $time + $notetime, @$busy_cmds_off;
666 if $noteofftime < $bot->{busytimer};
668 if $noteofftime + $mintime_off < $bot->{timer};
671 # prefer turning off long notes
672 $score += 100 * ($noteofftime - $bot->{timer});
673 # prefer turning off low notes
674 $score += 1 * (-$note);
675 # prefer turning off notes that already play on another channel
676 $score += 1000 * (grep { $_ != $busy_chan && $notechannelbots{$_}{$busy_note} && $notechannelbots{$_}{$busy_note}{busy} } keys %notechannelbots);
678 push @candidates, [$bot, $score, $noteofftime];
685 @candidates = sort { $a->[1] <=> $b->[1] } @candidates;
686 my ($bot, $score, $offtime) = @{(pop @candidates)};
687 my $oldchan = $bot->{busy}->[0];
688 my $oldnote = $bot->{busy}->[1];
689 busybot_note_off $offtime - $notetime, $oldchan, $oldnote;
690 my $canplay = busybot_note_on_bot $bot, $time, $channel, $program, $note, 0, 1;
691 die "Canplay but not?"
693 warn "Made $channel:$note play by stopping $oldchan:$oldnote";
694 $notechannelbots{$channel}{$note} = $bot;
704 warn "Not enough bots to play this (when playing $channel:$note)";
707 # my $b = $_->{busy};
708 # warn "$_->{classname} -> @{[$b ? qq{$b->[0]:$b->[1]} : 'none']} @{[$_->{timer} - $notetime]} ($time)\n";
713 warn "Note $channel:$note cannot be played by any bot";
721 my (@preallocate) = @_;
725 die "Cannot preallocate any more $_ bots"
726 if $busybots->{$_}->{count} <= 0;
727 my $bot = Storable::dclone $busybots->{$_};
728 $bot->{id} = @busybots_allocated + 1;
729 $bot->{classname} = $_;
730 busybot_cmd_bot_execute $bot, 0, ['cmd', 'wait', $timeoffset_preinit];
731 busybot_cmd_bot_execute $bot, 0, ['barrier'];
732 busybot_cmd_bot_execute $bot, 0, @{$bot->{init}}
734 busybot_cmd_bot_execute $bot, 0, ['barrier'];
735 --$busybots->{$_}->{count};
736 push @busybots_allocated, $bot;
742 my ($filename, $trans) = @_;
745 my $opus = MIDI::Opus->new({from_file => $filename});
746 my $ticksperquarter = $opus->ticks();
747 my $tracks = $opus->tracks_r();
748 my @tempi = (); # list of start tick, time per tick pairs (calculated as seconds per quarter / ticks per quarter)
752 for($tracks->[0]->events())
755 if($_->[0] eq 'set_tempo')
757 push @tempi, [$tick, $_->[2] * 0.000001 / $ticksperquarter];
764 my $curtempo = [0, 0.5 / $ticksperquarter];
769 # this event is in the past
770 # we add the full time since the last one then
771 $sec += ($_->[0] - $curtempo->[0]) * $curtempo->[1];
775 # if this event is in the future, we break
780 $sec += ($tick - $curtempo->[0]) * $curtempo->[1];
784 # merge all to a single track
785 my @allmidievents = ();
787 for my $track(0..@$tracks-1)
790 for($tracks->[$track]->events())
792 my ($command, $delta, @data) = @$_;
793 $command = 'note_off' if $command eq 'note_on' and $data[2] == 0;
795 push @allmidievents, [$command, $tick, $sequence++, $track, @data];
799 if(open my $fh, "$filename.vocals")
806 my ($tick, $file) = split /\s+/, $_;
811 elsif($tick eq 'shift')
817 push @allmidievents, ['note_on', $tick * $scale + $shift, $sequence++, -1, -1, $file];
818 push @allmidievents, ['note_off', $tick * $scale + $shift, $sequence++, -1, -1, $file];
824 @allmidievents = sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } @allmidievents;
826 # find the first interesting event
827 my $shift = [grep { $_->[0] eq 'note_on' } @allmidievents]->[0][1];
829 unless defined $shift;
831 # shift times by first event, no boring waiting
832 $_->[0] = ($_->[0] < $shift ? 0 : $_->[0] - $shift) for @tempi;
833 $_->[1] = ($_->[1] < $shift ? 0 : $_->[1] - $shift) for @allmidievents;
847 my $chan = $ev->[4] + 1;
848 ++$notes_seen{$chan}{($programs{$chan} || 1)}{$ev->[5]};
849 if($midinotes{$chan}{$ev->[5]})
852 busybot_note_off($t - SYS_TICRATE - 0.001, $chan, $ev->[5]);
854 busybot_note_on($t, $chan, $programs{$chan} || 1, $ev->[5]);
856 $midinotes{$chan}{$ev->[5]} = 1;
862 my $chan = $ev->[4] + 1;
863 if(exists $sustain{$chan})
865 push @{$sustain{$chan}}, $ev;
868 if($midinotes{$chan}{$ev->[5]})
871 busybot_note_off($t - SYS_TICRATE - 0.001, $chan, $ev->[5]);
873 $midinotes{$chan}{$ev->[5]} = 0;
876 my $patch_change = sub
879 my $chan = $ev->[4] + 1;
880 my $program = $ev->[5] + 1;
881 $programs{$chan} = $program;
884 my $sustain_change = sub
887 my $chan = $ev->[4] + 1;
890 # release all currently not pressed notes
891 my $s = $sustain{$chan};
892 delete $sustain{$chan};
901 $sustain{$chan} = [];
907 $t = $tick2sec->($_->[1]);
908 # my $track = $_->[3];
909 if($_->[0] eq 'note_on')
913 elsif($_->[0] eq 'note_off')
917 elsif($_->[0] eq 'patch_change')
921 elsif($_->[0] eq 'control_change' && $_->[5] == 64) # sustain pedal
923 $sustain_change->($_);
927 # fake events for releasing pedal
930 $sustain_change->(['control_change', $t, undef, undef, $_ - 1, 64, 0]);
933 print STDERR "For file $filename:\n";
934 print STDERR " Stuck notes: $notes_stuck\n";
936 for my $testtranspose(-127..127)
941 for my $channel(sort keys %notes_seen)
943 next if $channel == 10 or $channel < 0;
944 for my $program(sort keys %{$notes_seen{$channel}})
946 for my $note(sort keys %{$notes_seen{$channel}{$program}})
948 my $cnt = $notes_seen{$channel}{$program}{$note};
952 for(@busybots_allocated, grep { $_->{count} > 0 } values %$busybots)
954 next # I won't play on this channel
955 if defined $_->{channels} and not $_->{channels}->{$channel};
956 next # I won't play this program
957 if defined $_->{programs} and not $_->{programs}->{$program};
958 my $transposed = $note - ($_->{transpose} || 0) - $testtranspose;
959 if(exists $_->{notes_on}{$transposed})
965 ++$votehigh if $transposed >= 0;
966 ++$votelow if $transposed < 0;
973 elsif($votelow >= $votehigh)
984 next if !$toohigh != !$toolow;
985 print STDERR " Transpose $testtranspose: $toohigh too high, $toolow too low, $good good\n";
988 for my $program(sort keys %{$notes_seen{10}})
990 for my $note(sort keys %{$notes_seen{10}{$program}})
992 my $cnt = $notes_seen{10}{$program}{$note};
994 for(@busybots_allocated)
996 next # I won't play on this channel
997 if defined $_->{channels} and not $_->{channels}->{10};
998 next # I won't play this program
999 if defined $_->{programs} and not $_->{programs}->{$program};
1000 if(exists $_->{percussion}{$note})
1007 print STDERR "Failed percussion $note ($cnt times)\n";
1012 while(my ($k1, $v1) = each %midinotes)
1014 while(my ($k2, $v2) = each %$v1)
1016 busybot_note_off($t, $k1, $k2);
1020 for(@busybots_allocated)
1022 busybot_intermission_bot $_;
1029 print STDERR "Bots allocated:\n";
1032 for(@busybots_allocated)
1034 print STDERR "$_->{id} is a $_->{classname}\n";
1035 ++$counthash{$_->{classname}};
1036 while(my ($type, $notehash) = each %{$_->{seen}})
1038 while(my ($k, $v) = each %$notehash)
1040 $notehash{$_->{classname}}{$type}{$k} += $v;
1044 for my $cn(sort keys %counthash)
1046 print STDERR "$counthash{$cn} bots of $cn have played:\n";
1047 for my $type(sort keys %{$notehash{$cn}})
1049 for my $note(sort { $a <=> $b } keys %{$notehash{$cn}{$type}})
1051 my $cnt = $notehash{$cn}{$type}{$note};
1052 print STDERR " $type $note ($cnt times)\n";
1056 for(@busybots_allocated)
1058 busybot_cmd_bot_execute $_, 0, ['cmd', 'wait', $timeoffset_predone];
1059 busybot_cmd_bot_execute $_, 0, ['barrier'];
1062 busybot_cmd_bot_execute $_, 0, @{$_->{done}};
1064 busybot_cmd_bot_execute $_, 0, ['cmd', 'wait', $timeoffset_postdone];
1065 busybot_cmd_bot_execute $_, 0, ['barrier'];
1069 my @preallocate = ();
1077 Preallocate(@preallocate);
1081 my $filename = shift @l;
1082 my $transpose = shift @l;
1083 ConvertMIDI($filename, $transpose);
1086 my @preallocate_new = map { $_->{classname} } @busybots_allocated;
1087 if(@preallocate_new == @preallocate)
1089 print "sv_cmd bot_cmd reset\n";
1090 print "sv_cmd bot_cmd setbots @{[scalar @preallocate_new]}\n";
1091 print "$precommands$commands";
1094 @preallocate = @preallocate_new;
1099 unless $@ eq "noalloc\n";