[PD-dev] dynamically allocate memory for object structure component
IOhannes m zmoelnig
zmoelnig at iem.at
Mon Sep 15 09:37:54 CEST 2014
-----BEGIN PGP SIGNED MESSAGE-----
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->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
sp->s_sr /* samplerate */
sp->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
furthermore, these values are only available once the signal graph is
compiled (that is: when the "dsp"-callback is executed).
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.
- - you should add code to your external that (re)allocates data in the
- - you can use sys_getsr() and DEFDACBLKSIZE (or just 64) as *default*
values. but be prepared to change them when you are notified.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
-----END PGP SIGNATURE-----
More information about the Pd-dev