Re: Query all buffers on server

[email protected] Wed, 05 May 2021 10:04:24 +0200
Newsgroups gmane.comp.audio.supercollider.user
Message-ID <[email protected]>
Yes, I managed to find the .cachedBuffersDo method (with some help from David Granström), and when checking the .path attribute of the returned buffers it was quite easy to determine if the buffers I want to load are already loaded or not.

But writing a class for this sounds like a good idea!

Mattias

[email protected] writes:

> well, there is...
> Buffer.cachedBuffersDo(s, {|b| b.postln})
> and...
> s.cachedBuffersDo{|b| b.postln}
> which both do the same thing.
>
> but note that they will also return Buffers you have allocated - not only the soundfiles you've read from disk (which i believe is what you want).
> so this empty buffer also show up among there...
> b= Buffer.alloc(s, 1000);
>
> but by asking for the buffer's path you can filter out which ones that are of interest...
> Buffer.cachedBuffersDo(s, {|b| if(b.path.notNil, {b.postln})})
>
> although that will still not work 100% because buffers loaded directly using server commands will not show...
> s.sendMsg(\b_allocRead, 0, "/Users/asdf/somesoundfile.wav")
>
> so a better approach is perhaps to write your own 'BufferPool' class or function that would keep track of your buffers.  when you'd ask it for a buffer name it'd look it up (IdentityDictionary) and return that Buffer object if it's already loaded - else load and return.
>
> _f
>
>> 3 maj 2021 kl. 09:32 skrev [email protected]:
>> 
>> Hi!
>> 
>> Is there an easy way to query all loaded buffers on the server, to avoid loading the same buffer twice?
>> 
>> Thank you!
>> 
>> _______________________________________________
>> sc-users mailing list
>> 
>> info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
>> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
>> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>
>
>   #|
>      fredrikolofsson.com     musicalfieldsforever.com
>   |#
>
>
> _______________________________________________
> sc-users mailing list
>
> info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/