I think the best practice here is to
- load all your buffers into a single Array
- store the array into a global variable (
~myBuffers
or something), so you refer to individual buffers as~myBuffers[0]
,~myBuffers[1]
etc)
I think it’s best to only load buffers once if you are not really changing them all the time. Even though you are working with a relatively small number of sound files, you may end up hitting the maximum number of buffers allocated in the server if you are reloading them many many times in a single session. You could work around this with a Buffer.freeAll
line inserted before you your buffer loading code, but it’s better design to remove redundant work from your code. That means separating your buffer loading code (which sounds like you really only need to do once at the beginning of the session) from your pattern definition code (which sounds like you are changing often within a single session).
In my own projects, even after I have it all finished and do not intend to do any further edits to the code, I still typically like to have a separate scd file to do all one-time server stuff (like loading buffers and SynthDefs), and another file to create all my Pbinds etc. I find it easier to debug this way.
Hope this helps,
Bruno