I’m starting another thread because I was getting pretty off-topic in the thread I first mentioned the issue in. I’m trying to optimize a piece I’m writing that involves four different threads going at once at a fairly quick speed, and the first thing I thought of was to limit the amount of polyphony in each thread so that no more than a certain number of notes will be playing at once. Doing some searching in the forum, I found that thankfully there IS a “kill” command, so now the only thing I need to worry about is whether there’s a way to automatically kill processes by “age” (i.e. kill the “oldest” note still playing automatically). Does Sonic Pi provide any way to access the oldest note played in a thread?
Here’s some pseudocode I wrote that might clarify what I’m trying to do:
in_thread do # play some notes if (voices_playing > 4) do kill voices_playing.oldest end end
EDIT: I wrote the program in a pretty modular way, so instead of “play”, the sequencing thread calls a custom definition for every note. I don’t know whether this makes any difference or not.