I'm trying to get a continuous ambient mix 'app', where once a SndBuf finishes playback, another will be instantiated. There should always be two SndBufs playing at all times.
I can get this scenario working easily enough but the memory used by earlier playback isn't being freed up. It seems that as long as a parent shred (required to instantiate and monitor the sndbufs) is while-ing away eternally, the sndbuf remains in resident memory. This is a problem because as more sound files are selected and played the computer will eventually run out of memory.
Switching to the command line I find I can chuck + simple sndbuf playing files and once playback is complete, memory use goes back to what it was. I already have a perl script running to take care of environment and execution of the program on boot, so I can modify that to periodically add new chucks.
The problem now shifts to knowing when to identify that the current file has completed playback, and a new file should be added. OSC seems a good way of getting information from Chuck to the script. There's a Perl library for running an OSC server, so it seems like this could well work.
But before I go down this slightly Rube Goldberg route, I wanted to check: is this really the Best Way(TM)?