Remember the difference between
eval_file - one runs the contents in a separate thread, so loops or threads which wrap
run_file need to have sleeps or syncs in them in order to wait for the external file to finish executing - whereas
eval_file runs the external file ‘in-place’ in the same thread - so any sleeps or syncs in the external file still affect the wrapping loop or thread.
Btw, your last example used cue and sync, but without those cue and sync commands there, it would most likely have behaved exactly the same, since all they did in this case was to start track one, and immediately start track two - which would have been exactly the same without the cue and sync there.
It’s not immediately clear in your last example whether you want each track to play simultaneously, or one after the other - but going with the code there, if you’re wanting them to start together, I assume also that you want the cue to happen after all the external files have finished running, so that you could tell Sonic Pi it’s ok to stop recording. So, you’d figure out which of the two external files was the longer running one, and place
cue :tick at the end of it (or, if you end up using
eval_file, placing the
cue :tick just after the call to
eval_file) - and then, just before the stop recording command, place
sync :tick - to tell Sonic Pi to wait for that event before stopping the recording.
Hopefully that explains things a little - have a go rewriting it to use sync and cue in that manner if you like - I certainly think it’s easier than keeping track of sleep times