Quantcast

query buffer length into variable?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

query buffer length into variable?

Peter P.-2
Hi list,

please excuse the following beginner question.
I am trying to query the length of a buffer ~buf1 in order to store it
in a global variable, which I can then use in arguments of a Synth.new
object.

So far I have managed to do
        ~lb1={BufDur.kr(~buf1)}.play;
which gets me a continuously running UGen inside ~lb1. Is there a way
to have the actual value inside that variable instead of the UGen? I
would like to print the value, and do some language-side math on it and
use it as argument in Synth.new objects.

Thanks for all hints!

_______________________________________________
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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: query buffer length into variable?

Peter P.-2
Dear list,

please forgive the noise. I just found the .numFrames method for Buffer
which does exactly what I want.

best, P

* [hidden email] <[hidden email]> [2017-05-09 13:11]:

> Hi list,
>
> please excuse the following beginner question.
> I am trying to query the length of a buffer ~buf1 in order to store it
> in a global variable, which I can then use in arguments of a Synth.new
> object.
>
> So far I have managed to do
> ~lb1={BufDur.kr(~buf1)}.play;
> which gets me a continuously running UGen inside ~lb1. Is there a way
> to have the actual value inside that variable instead of the UGen? I
> would like to print the value, and do some language-side math on it and
> use it as argument in Synth.new objects.
>
> Thanks for all hints!
>
> _______________________________________________
> 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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: query buffer length into variable?

Scott Carver
In terms of best practices, you probably want to do something like this:

SynthDef(\bufferThing, {
    arg bufnum;
    var duration, samples, rate;
    duration = BufDur.kr(bufnum);
samples = BufSamples.kr(bufnum);
rate = BufSampleRate.kr(bufnum);
});
Synth(\bufferThing, arg:[\bufnum, ~buffer]);

Meaning - if you need the duration, samples, etc in your Synth, pass in a buffer number and get them via the Buf* Ugens. It's more robust insofar as you can change the buffer while the synth is running and everything will work correctly - and simpler, as you can just pass the buffer number, and not worry about ALSO passing e.g. duration, sample rate, etc.

- S

On Tue, May 9, 2017 at 4:25 AM <[hidden email]> wrote:
Dear list,

please forgive the noise. I just found the .numFrames method for Buffer
which does exactly what I want.

best, P

* [hidden email] <[hidden email]> [2017-05-09 13:11]:
> Hi list,
>
> please excuse the following beginner question.
> I am trying to query the length of a buffer ~buf1 in order to store it
> in a global variable, which I can then use in arguments of a Synth.new
> object.
>
> So far I have managed to do
>       ~lb1={BufDur.kr(~buf1)}.play;
> which gets me a continuously running UGen inside ~lb1. Is there a way
> to have the actual value inside that variable instead of the UGen? I
> would like to print the value, and do some language-side math on it and
> use it as argument in Synth.new objects.
>
> Thanks for all hints!
>
> _______________________________________________
> 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/
Loading...