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;
17 use constant TEXT_EVENT_CHANNEL => -1;
19 die "Usage: $0 filename.conf midifile1 transpose1 midifile2 transpose2 ..."
20 unless @ARGV > 1 and @ARGV % 2;
22 my $timeoffset_preinit = 2;
23 my $timeoffset_postinit = 2;
24 my $timeoffset_predone = 2;
25 my $timeoffset_postdone = 2;
26 my $timeoffset_preintermission = 2;
27 my $timeoffset_postintermission = 2;
28 my $time_forgetfulness = 1.5;
32 my ($config, @midilist) = @ARGV;
36 return map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, rand] } @_;
42 my ($dest, $src) = @_;
43 if(ref $src eq 'HASH')
49 $dest->{$_} = override $dest->{$_}, $src->{$_};
52 elsif(ref $src eq 'ARRAY')
58 push @$dest, override undef, $_;
63 $dest = Storable::dclone $src;
75 my @busybots_allocated;
79 my $lowestnotestart = undef;
88 my $currentbot = undef;
89 my $appendref = undef;
98 my @cmd = split /\s+/, $_;
99 if($cmd[0] eq 'super')
101 push @$appendref, @$super
104 elsif($cmd[0] eq 'percussion') # simple import
106 push @$appendref, @{$currentbot->{percussion}->{$cmd[1]}};
110 push @$appendref, \@cmd;
117 my $base = $bots{$1};
118 $currentbot = override $currentbot, $base;
120 elsif(/^count (\d+)/)
122 $currentbot->{count} = $1;
124 elsif(/^transpose (\d+)/)
126 $currentbot->{transpose} ||= 0;
127 $currentbot->{transpose} += $1;
129 elsif(/^channels (.*)/)
131 $currentbot->{channels} = { map { $_ => 1 } split /\s+/, $1 };
133 elsif(/^programs (.*)/)
135 $currentbot->{programs} = { map { $_ => 1 } split /\s+/, $1 };
139 $super = $currentbot->{init};
140 $currentbot->{init} = $appendref = [];
142 elsif(/^intermission$/)
144 $super = $currentbot->{intermission};
145 $currentbot->{intermission} = $appendref = [];
149 $super = $currentbot->{done};
150 $currentbot->{done} = $appendref = [];
152 elsif(/^note on (-?\d+)/)
154 $super = $currentbot->{notes_on}->{$1};
155 $currentbot->{notes_on}->{$1} = $appendref = [];
157 elsif(/^note off (-?\d+)/)
159 $super = $currentbot->{notes_off}->{$1};
160 $currentbot->{notes_off}->{$1} = $appendref = [];
162 elsif(/^percussion (\d+)/)
164 $super = $currentbot->{percussion}->{$1};
165 $currentbot->{percussion}->{$1} = $appendref = [];
169 $super = $currentbot->{text}->{$1};
170 $currentbot->{text}->{$1} = $appendref = [];
174 print STDERR "unknown command: $_\n";
179 $currentbot = ($bots{$1} ||= {count => 0});
183 $precommands .= "$1\n";
185 elsif(/^timeoffset_preinit (.*)/)
187 $timeoffset_preinit = $1;
189 elsif(/^timeoffset_postinit (.*)/)
191 $timeoffset_postinit = $1;
193 elsif(/^timeoffset_predone (.*)/)
195 $timeoffset_predone = $1;
197 elsif(/^timeoffset_postdone (.*)/)
199 $timeoffset_postdone = $1;
201 elsif(/^timeoffset_preintermission (.*)/)
203 $timeoffset_preintermission = $1;
205 elsif(/^timeoffset_postintermission (.*)/)
207 $timeoffset_postintermission = $1;
209 elsif(/^time_forgetfulness (.*)/)
211 $time_forgetfulness = $1;
213 elsif(/^list (.*?) (.*)/)
215 $lists{$1} = [split / /, $2];
216 $listindexes{$1} = 0;
220 print STDERR "unknown command: $_\n";
226 for(values %{$_->{notes_on}}, values %{$_->{percussion}})
228 my $t = $_->[0]->[0] eq 'time' ? $_->[0]->[1] : 0;
229 $lowestnotestart = $t if not defined $lowestnotestart or $t < $lowestnotestart;
235 my $busybots_orig = botconfig_read $config;
238 # returns: ($mintime, $maxtime, $busytime)
239 sub busybot_cmd_bot_cmdinfo(@)
245 my $busytime = undef;
249 if($_->[0] eq 'time')
252 if not defined $mintime or $_->[1] < $mintime;
253 $maxtime = $_->[1] + SYS_TICRATE
254 if not defined $maxtime or $_->[1] + SYS_TICRATE > $maxtime;
256 elsif($_->[0] eq 'busy')
258 $busytime = $_->[1] + SYS_TICRATE;
262 return ($mintime, $maxtime, $busytime);
265 sub busybot_cmd_bot_matchtime($$$@)
267 my ($bot, $targettime, $targetbusytime, @commands) = @_;
269 # I want to execute @commands so that I am free on $targettime and $targetbusytime
270 # when do I execute it then?
272 my ($mintime, $maxtime, $busytime) = busybot_cmd_bot_cmdinfo @commands;
274 my $tstart_max = defined $maxtime ? $targettime - $maxtime : $targettime;
275 my $tstart_busy = defined $busytime ? $targetbusytime - $busytime : $targettime;
277 return $tstart_max < $tstart_busy ? $tstart_max : $tstart_busy;
280 # TODO function to find out whether, and when, to insert a command before another command to make it possible
281 # (note-off before note-on)
283 sub busybot_cmd_bot_test($$$@)
285 my ($bot, $time, $force, @commands) = @_;
287 my $bottime = defined $bot->{timer} ? $bot->{timer} : -1;
288 my $botbusytime = defined $bot->{busytimer} ? $bot->{busytimer} : -1;
290 my ($mintime, $maxtime, $busytime) = busybot_cmd_bot_cmdinfo @commands;
292 if($time < $botbusytime)
294 warn "FORCE: $time < $botbusytime"
299 if(defined $mintime and $time + $mintime < $bottime)
301 warn "FORCE: $time + $mintime < $bottime"
316 ? do { $lists{$1}[$listindexes{$1}++ % @{$lists{$1}}]; }
322 sub busybot_cmd_bot_execute($$@)
324 my ($bot, $time, @commands) = @_;
328 if($_->[0] eq 'time')
330 $commands .= sprintf "sv_cmd bot_cmd %d wait_until %f\n", $bot->{id}, $time + $_->[1];
331 if($bot->{timer} > $time + $_->[1] + SYS_TICRATE)
333 #use Carp; carp "Negative wait: $bot->{timer} <= @{[$time + $_->[1] + SYS_TICRATE]}";
335 $bot->{timer} = $time + $_->[1] + SYS_TICRATE;
337 elsif($_->[0] eq 'busy')
339 $bot->{busytimer} = $time + $_->[1] + SYS_TICRATE;
341 elsif($_->[0] eq 'buttons')
343 my %buttons_release = %{$bot->{buttons} ||= {}};
347 delete $buttons_release{$1};
349 for(keys %buttons_release)
351 $commands .= sprintf "sv_cmd bot_cmd %d releasekey %s\n", $bot->{id}, $_;
352 delete $bot->{buttons}->{$_};
358 $commands .= sprintf "sv_cmd bot_cmd %d presskey %s\n", $bot->{id}, $_;
359 $bot->{buttons}->{$_} = 1;
362 elsif($_->[0] eq 'cmd')
364 $commands .= sprintf "sv_cmd bot_cmd %d %s\n", $bot->{id}, buildstring @{$_}[1..@$_-1];
366 elsif($_->[0] eq 'aim_random')
368 $commands .= sprintf "sv_cmd bot_cmd %d aim \"%f 0 %f\"\n", $bot->{id}, $_->[1] + rand($_->[2] - $_->[1]), $_->[3];
370 elsif($_->[0] eq 'barrier')
372 $commands .= sprintf "sv_cmd bot_cmd %d barrier\n", $bot->{id};
373 $bot->{timer} = $bot->{busytimer} = 0;
374 undef $bot->{lastuse};
376 elsif($_->[0] eq 'raw')
378 $commands .= sprintf "%s\n", buildstring @{$_}[1..@$_-1];
385 my $intermissions = 0;
387 sub busybot_intermission_bot($)
390 busybot_cmd_bot_execute $bot, 0, ['cmd', 'wait', $timeoffset_preintermission];
391 busybot_cmd_bot_execute $bot, 0, ['barrier'];
392 if($bot->{intermission})
394 busybot_cmd_bot_execute $bot, 0, @{$bot->{intermission}};
396 busybot_cmd_bot_execute $bot, 0, ['barrier'];
397 $notetime = $timeoffset_postintermission - $lowestnotestart;
401 sub busybot_note_off_bot($$$$)
403 my ($bot, $time, $channel, $note) = @_;
404 #print STDERR "note off $bot:$time:$channel:$note\n";
407 my ($busychannel, $busynote, $cmds) = @{$bot->{busy}};
409 if not defined $cmds; # note off cannot fail
410 die "Wrong note-off?!?"
411 if $busychannel != $channel || $busynote ne $note;
412 $bot->{busy} = undef;
414 my $t = $time + $notetime;
415 my ($mintime, $maxtime, $busytime) = busybot_cmd_bot_cmdinfo @$cmds;
417 # perform note-off "as soon as we can"
418 $t = $bot->{busytimer}
419 if $t < $bot->{busytimer};
420 $t = $bot->{timer} - $mintime
421 if $t < $bot->{timer} - $mintime;
423 busybot_cmd_bot_execute $bot, $t, @$cmds;
427 sub busybot_get_cmds_bot($$$)
429 my ($bot, $channel, $note) = @_;
430 my ($k0, $k1, $cmds, $cmds_off) = (undef, undef, undef, undef);
431 if($channel == TEXT_EVENT_CHANNEL)
434 $note =~ /^([^:]*):(.*)$/;
437 $cmds = $bot->{text}->{$name};
440 $cmds = [ map { [ map { $_ eq '%s' ? $data : $_ } @$_ ] } @$cmds ];
445 elsif($channel == 10)
448 $cmds = $bot->{percussion}->{$note};
455 $cmds = $bot->{notes_on}->{$note - ($bot->{transpose} || 0) - $transpose};
456 $cmds_off = $bot->{notes_off}->{$note - ($bot->{transpose} || 0) - $transpose};
458 $k1 = $note - ($bot->{transpose} || 0) - $transpose;
460 return ($cmds, $cmds_off, $k0, $k1);
463 sub busybot_note_on_bot($$$$$$$)
465 my ($bot, $time, $channel, $program, $note, $init, $force) = @_;
467 return -1 # I won't play on this channel
468 if defined $bot->{channels} and not $bot->{channels}->{$channel};
469 return -1 # I won't play this program
470 if defined $bot->{programs} and not $bot->{programs}->{$program};
472 my ($cmds, $cmds_off, $k0, $k1) = busybot_get_cmds_bot($bot, $channel, $note);
474 return -1 # I won't play this note
475 if not defined $cmds;
478 #print STDERR "note on $bot:$time:$channel:$note\n";
482 if not busybot_cmd_bot_test $bot, $time + $notetime, $force, @$cmds;
483 busybot_cmd_bot_execute $bot, 0, ['cmd', 'wait', $timeoffset_preinit];
484 busybot_cmd_bot_execute $bot, 0, ['barrier'];
485 busybot_cmd_bot_execute $bot, 0, @{$bot->{init}}
487 busybot_cmd_bot_execute $bot, 0, ['barrier'];
488 for(1..$intermissions)
490 busybot_intermission_bot $bot;
492 # we always did a barrier, so we know this works
493 busybot_cmd_bot_execute $bot, $time + $notetime, @$cmds;
498 if not busybot_cmd_bot_test $bot, $time + $notetime, $force, @$cmds;
499 busybot_cmd_bot_execute $bot, $time + $notetime, @$cmds;
501 if(defined $cmds_off)
503 $bot->{busy} = [$channel, $note, $cmds_off];
505 ++$bot->{seen}{$k0}{$k1};
507 if(($bot->{lastuse} // -666) >= $time - $time_forgetfulness && $channel == $bot->{lastchannel})
509 $bot->{lastchannelsequence} += 1;
513 $bot->{lastchannelsequence} = 1;
515 $bot->{lastuse} = $time;
516 $bot->{lastchannel} = $channel;
518 # print STDERR "$time $bot->{id} $channel:$note\n"
526 $busybots = Storable::dclone $busybots_orig;
527 @busybots_allocated = ();
528 %notechannelbots = ();
530 $notetime = $timeoffset_postinit - $lowestnotestart;
533 sub busybot_note_off($$$)
535 my ($time, $channel, $note) = @_;
537 # print STDERR "note off $time:$channel:$note\n";
539 if(my $bot = $notechannelbots{$channel}{$note})
541 busybot_note_off_bot $bot, $time, $channel, $note;
542 delete $notechannelbots{$channel}{$note};
551 my ($time, $channel, $program, $note, @bots) = @_;
561 ($a->[0]->{lastuse} // -666) <=> ($b->[0]->{lastuse} // -666)
568 if($channel != 10) # percussion just should do round robin
570 if(($_->{lastuse} // -666) >= $time - $time_forgetfulness)
572 if($channel == $_->{lastchannel})
574 $q += $_->{lastchannelsequence};
578 # better leave this one alone
579 $q -= $_->{lastchannelsequence};
588 sub busybot_note_on($$$$)
590 my ($time, $channel, $program, $note) = @_;
592 if($notechannelbots{$channel}{$note})
594 print STDERR "THIS SHOULD NEVER HAPPEN\n";
595 busybot_note_off $time, $channel, $note;
598 # print STDERR "note on $time:$channel:$note\n";
602 my @epicfailbots = ();
604 for(botsort $time, $channel, $program, $note, @busybots_allocated)
606 my $canplay = busybot_note_on_bot $_, $time, $channel, $program, $note, 0, 0;
609 $notechannelbots{$channel}{$note} = $_;
612 push @epicfailbots, $_
619 for(unsort keys %$busybots)
621 next if $busybots->{$_}->{count} <= 0;
622 my $bot = Storable::dclone $busybots->{$_};
623 $bot->{id} = @busybots_allocated + 1;
624 $bot->{classname} = $_;
625 my $canplay = busybot_note_on_bot $bot, $time, $channel, $program, $note, 1, 0;
634 --$busybots->{$_}->{count};
635 $notechannelbots{$channel}{$note} = $bot;
636 push @busybots_allocated, $bot;
640 die "Fresh bot cannot play stuff"
646 # we cannot add a new bot to play this
647 # we could try finding a bot that could play this, and force him to stop the note!
649 my @candidates = (); # contains: [$bot, $score, $offtime]
651 # put in all currently busy bots that COULD play this, if they did a note-off first
652 for my $bot(@epicfailbots)
655 if $busybots->{$bot->{classname}}->{count} != 0;
658 my ($busy_chan, $busy_note, $busy_cmds_off) = @{$bot->{busy}};
660 unless $busy_cmds_off;
661 my ($cmds, $cmds_off, $k0, $k1) = busybot_get_cmds_bot $bot, $channel, $note;
664 my ($mintime, $maxtime, $busytime) = busybot_cmd_bot_cmdinfo @$cmds;
665 my ($mintime_off, $maxtime_off, $busytime_off) = busybot_cmd_bot_cmdinfo @$busy_cmds_off;
667 my $noteofftime = busybot_cmd_bot_matchtime $bot, $time + $notetime + $mintime, $time + $notetime, @$busy_cmds_off;
669 if $noteofftime < $bot->{busytimer};
671 if $noteofftime + $mintime_off < $bot->{timer};
674 # prefer turning off long notes
675 $score += 100 * ($noteofftime - $bot->{timer});
676 # prefer turning off low notes
677 $score += 1 * (-$note);
678 # prefer turning off notes that already play on another channel
679 $score += 1000 * (grep { $_ != $busy_chan && $notechannelbots{$_}{$busy_note} && $notechannelbots{$_}{$busy_note}{busy} } keys %notechannelbots);
681 push @candidates, [$bot, $score, $noteofftime];
688 @candidates = sort { $a->[1] <=> $b->[1] } @candidates;
689 my ($bot, $score, $offtime) = @{(pop @candidates)};
690 my $oldchan = $bot->{busy}->[0];
691 my $oldnote = $bot->{busy}->[1];
692 busybot_note_off $offtime - $notetime, $oldchan, $oldnote;
693 my $canplay = busybot_note_on_bot $bot, $time, $channel, $program, $note, 0, 1;
694 die "Canplay but not?"
696 warn "Made $channel:$note play by stopping $oldchan:$oldnote";
697 $notechannelbots{$channel}{$note} = $bot;
707 warn "Not enough bots to play this (when playing $channel:$note)";
710 # my $b = $_->{busy};
711 # warn "$_->{classname} -> @{[$b ? qq{$b->[0]:$b->[1]} : 'none']} @{[$_->{timer} - $notetime]} ($time)\n";
716 warn "Note $channel:$note cannot be played by any bot";
724 my (@preallocate) = @_;
728 die "Cannot preallocate any more $_ bots"
729 if $busybots->{$_}->{count} <= 0;
730 my $bot = Storable::dclone $busybots->{$_};
731 $bot->{id} = @busybots_allocated + 1;
732 $bot->{classname} = $_;
733 busybot_cmd_bot_execute $bot, 0, ['cmd', 'wait', $timeoffset_preinit];
734 busybot_cmd_bot_execute $bot, 0, ['barrier'];
735 busybot_cmd_bot_execute $bot, 0, @{$bot->{init}}
737 busybot_cmd_bot_execute $bot, 0, ['barrier'];
738 --$busybots->{$_}->{count};
739 push @busybots_allocated, $bot;
745 my ($filename, $trans) = @_;
748 my $opus = MIDI::Opus->new({from_file => $filename});
749 my $ticksperquarter = $opus->ticks();
750 my $tracks = $opus->tracks_r();
751 my @tempi = (); # list of start tick, time per tick pairs (calculated as seconds per quarter / ticks per quarter)
755 for($tracks->[0]->events())
758 if($_->[0] eq 'set_tempo')
760 push @tempi, [$tick, $_->[2] * 0.000001 / $ticksperquarter];
767 my $curtempo = [0, 0.5 / $ticksperquarter];
772 # this event is in the past
773 # we add the full time since the last one then
774 $sec += ($_->[0] - $curtempo->[0]) * $curtempo->[1];
778 # if this event is in the future, we break
783 $sec += ($tick - $curtempo->[0]) * $curtempo->[1];
787 # merge all to a single track
788 my @allmidievents = ();
790 for my $track(0..@$tracks-1)
793 for($tracks->[$track]->events())
795 my ($command, $delta, @data) = @$_;
796 $command = 'note_off' if $command eq 'note_on' and $data[2] == 0;
799 if $command eq 'text_event' && $data[0] !~ /:/;
800 push @allmidievents, [$command, $tick, $sequence++, $track, @data];
804 if(open my $fh, "$filename.vocals")
811 my ($tick, $file) = split /\s+/, $_;
816 elsif($tick eq 'shift')
822 push @allmidievents, ['text_event', $tick * $scale + $shift, $sequence++, -1, "vocals:$file"];
827 # HACK for broken rosegarden export: put patch changes first by clearing their sequence number
830 if($_->[0] eq 'patch_change')
837 @allmidievents = sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } @allmidievents;
839 # find the first interesting event
840 my $shift = [grep { $_->[0] eq 'note_on' || $_->[0] eq 'text_event' } @allmidievents]->[0][1];
842 unless defined $shift;
844 # shift times by first event, no boring waiting
845 $_->[0] = ($_->[0] < $shift ? 0 : $_->[0] - $shift) for @tempi;
846 $_->[1] = ($_->[1] < $shift ? 0 : $_->[1] - $shift) for @allmidievents;
860 my $chan = $ev->[4] + 1;
861 ++$notes_seen{$chan}{($programs{$chan} || 1)}{$ev->[5]};
862 if($midinotes{$chan}{$ev->[5]})
865 busybot_note_off($t - SYS_TICRATE - 0.001, $chan, $ev->[5]);
867 busybot_note_on($t, $chan, $programs{$chan} || 1, $ev->[5]);
869 $midinotes{$chan}{$ev->[5]} = 1;
875 my $chan = $ev->[4] + 1;
876 if(exists $sustain{$chan})
878 push @{$sustain{$chan}}, $ev;
881 if($midinotes{$chan}{$ev->[5]})
884 busybot_note_off($t - SYS_TICRATE - 0.001, $chan, $ev->[5]);
886 $midinotes{$chan}{$ev->[5]} = 0;
893 my $chan = TEXT_EVENT_CHANNEL;
895 busybot_note_on($t, TEXT_EVENT_CHANNEL, -1, $ev->[4]);
896 busybot_note_off($t, TEXT_EVENT_CHANNEL, $ev->[4]);
899 my $patch_change = sub
902 my $chan = $ev->[4] + 1;
903 my $program = $ev->[5] + 1;
904 $programs{$chan} = $program;
907 my $sustain_change = sub
910 my $chan = $ev->[4] + 1;
913 # release all currently not pressed notes
914 my $s = $sustain{$chan};
915 delete $sustain{$chan};
924 $sustain{$chan} = [];
930 $t = $tick2sec->($_->[1]);
931 # my $track = $_->[3];
932 if($_->[0] eq 'note_on')
936 elsif($_->[0] eq 'note_off')
940 elsif($_->[0] eq 'text_event')
944 elsif($_->[0] eq 'patch_change')
948 elsif($_->[0] eq 'control_change' && $_->[5] == 64) # sustain pedal
950 $sustain_change->($_);
954 # fake events for releasing pedal
957 $sustain_change->(['control_change', $t, undef, undef, $_ - 1, 64, 0]);
960 print STDERR "For file $filename:\n";
961 print STDERR " Stuck notes: $notes_stuck\n";
963 for my $testtranspose(-127..127)
968 for my $channel(sort keys %notes_seen)
970 next if $channel == 10;
971 for my $program(sort keys %{$notes_seen{$channel}})
973 for my $note(sort keys %{$notes_seen{$channel}{$program}})
975 my $cnt = $notes_seen{$channel}{$program}{$note};
979 for(@busybots_allocated, grep { $_->{count} > 0 } values %$busybots)
981 next # I won't play on this channel
982 if defined $_->{channels} and not $_->{channels}->{$channel};
983 next # I won't play this program
984 if defined $_->{programs} and not $_->{programs}->{$program};
985 my $transposed = $note - ($_->{transpose} || 0) - $testtranspose;
986 if(exists $_->{notes_on}{$transposed})
992 ++$votehigh if $transposed >= 0;
993 ++$votelow if $transposed < 0;
1000 elsif($votelow >= $votehigh)
1011 next if !$toohigh != !$toolow;
1012 print STDERR " Transpose $testtranspose: $toohigh too high, $toolow too low, $good good\n";
1015 for my $program(sort keys %{$notes_seen{10}})
1017 for my $note(sort keys %{$notes_seen{10}{$program}})
1019 my $cnt = $notes_seen{10}{$program}{$note};
1021 for(@busybots_allocated)
1023 next # I won't play on this channel
1024 if defined $_->{channels} and not $_->{channels}->{10};
1025 next # I won't play this program
1026 if defined $_->{programs} and not $_->{programs}->{$program};
1027 if(exists $_->{percussion}{$note})
1034 print STDERR "Failed percussion $note ($cnt times)\n";
1039 while(my ($k1, $v1) = each %midinotes)
1041 while(my ($k2, $v2) = each %$v1)
1043 busybot_note_off($t, $k1, $k2);
1047 for(@busybots_allocated)
1049 busybot_intermission_bot $_;
1056 print STDERR "Bots allocated:\n";
1059 for(@busybots_allocated)
1061 print STDERR "$_->{id} is a $_->{classname}\n";
1062 ++$counthash{$_->{classname}};
1063 while(my ($type, $notehash) = each %{$_->{seen}})
1065 while(my ($k, $v) = each %$notehash)
1067 $notehash{$_->{classname}}{$type}{$k} += $v;
1071 for my $cn(sort keys %counthash)
1073 print STDERR "$counthash{$cn} bots of $cn have played:\n";
1074 for my $type(sort keys %{$notehash{$cn}})
1076 for my $note(sort keys %{$notehash{$cn}{$type}})
1078 my $cnt = $notehash{$cn}{$type}{$note};
1079 print STDERR " $type $note ($cnt times)\n";
1083 for(@busybots_allocated)
1085 busybot_cmd_bot_execute $_, 0, ['cmd', 'wait', $timeoffset_predone];
1086 busybot_cmd_bot_execute $_, 0, ['barrier'];
1089 busybot_cmd_bot_execute $_, 0, @{$_->{done}};
1091 busybot_cmd_bot_execute $_, 0, ['cmd', 'wait', $timeoffset_postdone];
1092 busybot_cmd_bot_execute $_, 0, ['barrier'];
1096 my @preallocate = ();
1104 Preallocate(@preallocate);
1108 my $filename = shift @l;
1109 my $transpose = shift @l;
1110 ConvertMIDI($filename, $transpose);
1113 my @preallocate_new = map { $_->{classname} } @busybots_allocated;
1114 if(@preallocate_new == @preallocate)
1116 print "sv_cmd bot_cmd setbots @{[scalar @preallocate_new]}\n";
1117 print "$precommands$commands";
1120 @preallocate = @preallocate_new;
1125 unless $@ eq "noalloc\n";