On Fri, 2011-11-04 at 11:26 +0100, katja wrote:
By coincidence I noticed an svn commit access request from Damian Stewart, back in 2008, where he proposes to 'implement multithreaded [soundfiler] read' (http://lists.puredata.info/pipermail/pd-dev/2008-12/012447.html). What has become of this? Is there any code from this project?
[readsf~] and writesf~] are threaded, they operate in a child process. I guess it could not be otherwise? Because they do not intend to read all samples at once. Looking at the code in d_soundfile.c, I can understand why the whole of Pd should not be multithreaded. It is a lot of overhead. But [soundfiler~] read is another exceptional case indeed, it needs carefully scheduled loading if it is not to cause buffer underruns elsewhere. Such loading in portions would also mean the whole audiofile is not immediately available in memory. Therefore, the result would somehow be equivalent to the '[readsf~]-in-an-upsampled-patch' trick.
The problem with the '[readsf~]-in-an-upsampled-patch' approach is that you cannot know how fast you can do it without interrupting audio. Also you cannot really fine-tune it since you can only set it to a speed to any power of two. Ideally, a threaded [soundfiler] would load the file as fas as possible in the background without interfering with Pd's main process and then it would output a bang when done.
Roman