I writing an external where I want to declare some arrays in the object structure which will have the size of the block size. I want to allocate memory using malloc with a variable that gets the block size. I know it's possible to get the sample rate with sys_getsr(); which can be used in the new instance routine. Is there something similar that gives you the block size?
On 9/14/14, Alexandros Drymonitis adrcki@gmail.com wrote:
I writing an external where I want to declare some arrays in the object structure which will have the size of the block size. I want to allocate memory using malloc with a variable that gets the block size. I know it's possible to get the sample rate with sys_getsr(); which can be used in the new instance routine. Is there something similar that gives you the block size?
I guess it's safe to use DEFDACBLKSIZE from s_stuff.h...
But this is set to 64...if I want to use a different block size? I guess it would work by making a comparison test in each dsp cycle and reset the size?...
On Sun, Sep 14, 2014 at 1:16 PM, Kjetil Matheussen <k.s.matheussen@gmail.com
wrote:
On 9/14/14, Alexandros Drymonitis adrcki@gmail.com wrote:
I writing an external where I want to declare some arrays in the object structure which will have the size of the block size. I want to allocate memory using malloc with a variable that gets the block size. I know it's possible to get the sample rate with sys_getsr(); which can be used in
the
new instance routine. Is there something similar that gives you the block size?
I guess it's safe to use DEFDACBLKSIZE from s_stuff.h...
On 9/14/14, Alexandros Drymonitis adrcki@gmail.com wrote:
But this is set to 64...if I want to use a different block size? I guess it would work by making a comparison test in each dsp cycle and reset the size?...
A different block size? Can you do that? I think Pd is always, and has always, used 64 frames per block.
On Sun, Sep 14, 2014 at 1:39 PM, Kjetil Matheussen <k.s.matheussen@gmail.com
wrote:
On 9/14/14, Alexandros Drymonitis adrcki@gmail.com wrote:
But this is set to 64...if I want to use a different block size? I guess
it
would work by making a comparison test in each dsp cycle and reset the size?...
A different block size? Can you do that? I think Pd is always, and has always, used 64 frames per block.
Audio settings? sp[0]->s_n is supposed to be pointing at the defined block size, or am I wrong?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
On 2014-09-14 12:41, Alexandros Drymonitis wrote:
A different block size? Can you do that? I think Pd is always, and has always, used 64 frames per block.
Audio settings?
hmm, those are different beasts. Pd's default blocksize and the only blocksize allowed for on a patch containing [dac~] or [adc~] is DEFDACBLKSIZE which has always been 64 (in all known incarnations of Pd-vanilla and Pd-extended; and as far as i can remember, which is *quite* some time)
even if you change the audio block size via the audio settings, within the patch you still have a default blocksize of 64 samples.
sp[0]->s_n is supposed to be pointing at the defined block size, or am I wrong?
it points to the block-size of the signal as used in your (sub)patch. that means: this is the actually used block-size when your object is fed audio (or generates audio). it is the same for all inputs and outputs of your object, since the object's iolet~s are all in the same (sub)patch, and you can only change the blocksize per (sub)patch. this can be achieved with [block~] or [switch~].
this is also the answer i would have given to your initial question:
if you need to access the block-size and samplerate within your external, use sp[0]->s_sr /* samplerate */ and sp[0]->s_n /* blocksize */
unfortunately there is (still) no member that holds the overlap factor (but i hear that there is some hope here), and it's "somehow" part of s_sr (to be precise: s_sr=signal.samplerate*signal.overlap; so "s_sr" is really the "number of samples processed per second" rather than the "samplerate" in a more traditional meaning).
in any case, you probably do *not* want to use sys_getsr(), as this will give you the *wrong* samplerate if your (sub)patch is being re-sampled.
furthermore, these values are only available once the signal graph is compiled (that is: when the "dsp"-callback is executed). AND these values *can change* during the lifetime of an object. luckily it is *guaranteed* that whenever on of these values changes, the "dsp"-callback will be re-executed, so you will be informed of any change.
SO: - - you should add code to your external that (re)allocates data in the "dsp"-callback. - - you can use sys_getsr() and DEFDACBLKSIZE (or just 64) as *default* values. but be prepared to change them when you are notified.
fgmasdr IOhannes
Yes, I see: sys_getblksize
in m_pd.h.
It looks to be hard-coded to return 64.
Of course the block size for a subpatch can be changed with [block~]. I'm not totally comfortable with the dsp operations yet, but it looks like that block size is what is represented by the member s_n of t_signal. But one of the dsp gurus should probably confirm or deny that. :)
-Jonathan
On Sunday, September 14, 2014 5:18 AM, Alexandros Drymonitis adrcki@gmail.com wrote:
I writing an external where I want to declare some arrays in the object structure which will have the size of the block size. I want to allocate memory using malloc with a variable that gets the block size. I know it's possible to get the sample rate with sys_getsr(); which can be used in the new instance routine. Is there something similar that gives you the block size?
_______________________________________________ Pd-dev mailing list Pd-dev@lists.iem.at http://lists.puredata.info/listinfo/pd-dev
That's right. Block size can change after an object is created so block-sized allocations are best put in the "dsp" routine that's called whenever DSP is started. (If a block~ changes its blocksize via a "set" message, DSP is re-started.)
cheers Miller
On Sun, Sep 14, 2014 at 08:20:25AM -0700, Jonathan Wilkes via Pd-dev wrote:
Yes, I see: sys_getblksize
in m_pd.h.
It looks to be hard-coded to return 64.
Of course the block size for a subpatch can be changed with [block~]. I'm not totally comfortable with the dsp operations yet, but it looks like that block size is what is represented by the member s_n of t_signal. But one of the dsp gurus should probably confirm or deny that. :)
-Jonathan
On Sunday, September 14, 2014 5:18 AM, Alexandros Drymonitis adrcki@gmail.com wrote:
I writing an external where I want to declare some arrays in the object structure which will have the size of the block size. I want to allocate memory using malloc with a variable that gets the block size. I know it's possible to get the sample rate with sys_getsr(); which can be used in the new instance routine. Is there something similar that gives you the block size?
Pd-dev mailing list Pd-dev@lists.iem.at http://lists.puredata.info/listinfo/pd-dev
Pd-dev mailing list Pd-dev@lists.iem.at http://lists.puredata.info/listinfo/pd-dev