[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-----
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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJUFpdPAAoJELZQGcR/ejb40V4P/RUfyNfkehLV5rhEx2taUg0o
MHuhVaH0NiSkF6tWKeSMDWa8/G07LJl6W/R5A0E/2JrLDO7vYBxfXvqoY1tYgZfe
5CtkNH7eF5ucFJQ9WerZHKPLy1AtQCaLKr+J4NMPEP7cBCuw+1ocfF+Cov+gsALO
qDqRHaZ06zTcSi7J9AZBbEf2ryyUxjoU/0c3Wmypv01h75KJcCyYMSUjSEXvQFPB
w4T4lokfXW2gQe9ead3X8bUb3wRUCIpxO8d/rQwSkTfxGfpIlynnTcbNbBhIrZbs
BD1a25fUGiAG2MoXpv3rwAc4MU7KE+IZLFC68pshfwNV/NmBkCLColNzgHnLIkuk
SRGC4j59BBgSHQcJVQPFqtu84+Rwxfh1tMaEzbgVc1C8Xh9K1j28qsnThNIyz7+d
k2U8RMaEa3KWSklOUCCg0BhBhIhMcat+Dd2mAxsDWOcYn3rEkUKSdU6WHJJgueUa
q8nH598vumi0orHvAyuJ7pCrl+sbFsbZyQw8P7FxQ4AWcSguKQ16EpQIm5ztSJca
oXSBHGNDnlrb4J7y/Cvg4Vp6fg8rmbN8dmXSvNy7PBKGhiMX6YwvR3HbjmjTHJUa
BwATZbM52TTuF4WlwQPVUo2DtM7+ViGOD5LGKJS9ga8FupRhSl3BciU4yQKJwJC9
OGJqoqSylNh8lUDVahcI
=FUFU
-----END PGP SIGNATURE-----



More information about the Pd-dev mailing list