Hello Cow.
It will not work because the action takes times: @eval_when_load is supposed to trigger “instantaneous” evaluation (i.e., function no process, no delay, etc.).
But it is easy trigger the sending of the messages to Bach.roll on demand only, after the start of the score. You can send a max message “setvar send2bach 1” that will trigger a whenever which runs the code. Put at the begining of your score:
@fun_def split_tab($t)
{
@local $tt := [], $reste := $t
loop {
$tt.push_back($reste.take(500))
$reste := $reste.drop(500)
} while (!$reste.empty())
return $tt
}
whenever ($send2bach)
{
@local $tab := @bach_score(), $ttab := @split_tab($tab), $i := 0
loop 0.1s
{
forall $e in $ttab[$i] { msgbsco $e }
$i += 1
} while ($i < $ttab.size())
}
After the start of the score, send the max message “setvar send2bach 1” to antescofo. It will trigger the whenever and run the code. If you don’t send the message, no message will be sent to Bach.roll.