Hey everybody, I hope it's okay for me to start a broader discussion on a well trodden path...
I am trying to reach the final frontier of Pure Data which is achieving truly sample accurate looping of many long wav files that stay in sync and don't degrade over time
My current setup is this:
Audio files are loaded into arrays on loadbang using soundfiler and arrays are resized to the total sample length of audio file.
When the audio file is needed, the array is set, then read using the phasor and tabread4 objects from the iem double precision library: https://git.iem.at/pd/iem_dp
My choice of these objects is because I found that the vanilla phasor~ and tabread4~ objects would result in synchronisation issues between audio files after a few minutes of looped playback. Thankfully, this issue is totally negated by use of the double precision objects.
I'm overall quite happy with this setup but there are a few issues that I would love to find a workaround for.
There is an imposed limit on the amount of audio files I can use. The patch I have created is being embedded on iOS using libpd, and depending on the device there is a variable limit on the total size of all the arrays contained within the patch. The easiest way I've gotten around this is to lower the sample rate of the wav files to allow for more musical material in smaller arrays but of course this comes with the cost of degraded sound quality.
Loading 100s of megabytes of wav files into arrays on startup takes quite a while.
Audio files are guaranteed to be different lengths (all relative to the bpm of the composition so they loop in a musical way) but so far I see no feasible option of defining a sample length or multiple there of and sticking to it.
It is essential that I can access the audio samples immediately, I have seen a method on this forum that I really like which involves loading the first few seconds of an audio file to an array, reading that array with tabplay~ then sending a message to a readsf~ object with a onset to takeover playback when tabplay~ has finished reading the array: https://forum.bela.io/d/709-reading-multiple-samples-and-cpu-overload
This works wonders for oneshot sounds but I cannot find a way to translate this method into looping sounds without having audible clicks and the loop point of the sample.
I have also come across the readanysf~ external which promises sample accurate looping: https://puredata.info/downloads/readanysf but I cannot successfully build it to try out for myself.
I would greatly appreciate your thoughts on the matter, I absolutely love Pd and I really want it to delivery and get over this hurdle!
Thanks