Run (eval_file) two files in parallel only once

use_bpm 120
use_synth :piano

live_loop :a do
eval_file ‘C:\songs\trackOne.rb’
sleep 1
end

live_loop :b do
eval_file ‘C:\songs\trackTwo.rb’
sleep 1
end

The above code will run infinitely.
How to make the two loops to run only once.

If you don’t want something to loop, then the simplest solution is to not use loops :man_shrugging: :slightly_smiling_face:

I’m assuming you still want the two ‘tracks’ to start at the same time however. Sonic Pi’s way to achieve this is to use threads. For that, see the Lang section of the help for the command in_thread.
(Threads are also explained in Sonic Pi - Tutorial).

Yes. in_thread works.

2 Likes