Hello all,
I'm trying to figure out how to use [singleton] from [sssad] so that I can instantiate some lookup tables once and only once for use in multiple patches.
The [singleton] help patch is a bit cryptic, but I've so far guessed that I can wrap the table-creating object like so:
[singleton WTAB waveTables]
It appears that the tables are correctly allocated by this, but they are not initialized; i.e. the arrays are created, but the code that fills them in is not triggered, even though there is a [loadbang] in [waveTables] that's supposed to trigger it.
So my question is first, am I even close to using [singleton] correctly? and secondly, do objects created by [singleton] get a loadbang?
Phil Stone http://pkstonemusic.com
Hallo, Phil Stone hat gesagt: // Phil Stone wrote:
I'm trying to figure out how to use [singleton] from [sssad] so that I can instantiate some lookup tables once and only once for use in multiple patches.
The [singleton] help patch is a bit cryptic, but I've so far guessed that I can wrap the table-creating object like so:
[singleton WTAB waveTables]
That's correct. Sorry about the cryptic help file, I'll make a better one.
It appears that the tables are correctly allocated by this, but they are not initialized; i.e. the arrays are created, but the code that fills them in is not triggered, even though there is a [loadbang] in [waveTables] that's supposed to trigger it.
So my question is first, am I even close to using [singleton] correctly? and secondly, do objects created by [singleton] get a loadbang?
They don't get a loadbang, because they are dynamically created. Dynamically created abstractions don't execute their loadbangs!
It's possible to trigger the loadbang manually with a message to the subpatch, the objects are created in. For singleton.pd this subpatch's receiver is is pd-$0-container. Attached is a version of singleton which automatically sends a loadbang message to it. After I get over my jetlag, I'll consider making this the default in sssad's version of singleton.pd as well. Also it may be useful to send the value of $0 to an outlet, maybe the first one, but that may break patches which rely on only a 0 or a 1 coming out there, so I guess I'll have to introduce a second outlet.
Frank Barknecht _ ______footils.org_ __goto10.org__
Thanks, Frank. That worked beautifully. I'm about to release something that needs this, so I guess I'll rename your new version and bundle it in with the release, until (or if) you make this part of default [sssad].
Phil
Frank Barknecht wrote:
Hallo, Phil Stone hat gesagt: // Phil Stone wrote:
I'm trying to figure out how to use [singleton] from [sssad] so that I can instantiate some lookup tables once and only once for use in multiple patches.
The [singleton] help patch is a bit cryptic, but I've so far guessed that I can wrap the table-creating object like so:
[singleton WTAB waveTables]
That's correct. Sorry about the cryptic help file, I'll make a better one.
It appears that the tables are correctly allocated by this, but they are not initialized; i.e. the arrays are created, but the code that fills them in is not triggered, even though there is a [loadbang] in [waveTables] that's supposed to trigger it.
So my question is first, am I even close to using [singleton] correctly? and secondly, do objects created by [singleton] get a loadbang?
They don't get a loadbang, because they are dynamically created. Dynamically created abstractions don't execute their loadbangs!
It's possible to trigger the loadbang manually with a message to the subpatch, the objects are created in. For singleton.pd this subpatch's receiver is is pd-$0-container. Attached is a version of singleton which automatically sends a loadbang message to it. After I get over my jetlag, I'll consider making this the default in sssad's version of singleton.pd as well. Also it may be useful to send the value of $0 to an outlet, maybe the first one, but that may break patches which rely on only a 0 or a 1 coming out there, so I guess I'll have to introduce a second outlet.
Ciao
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On Mon, 3 Sep 2007, Frank Barknecht wrote:
It's possible to trigger the loadbang manually with a message to the subpatch, the objects are created in. For singleton.pd this subpatch's receiver is is pd-$0-container. Attached is a version of singleton which automatically sends a loadbang message to it. After I get over my jetlag, I'll consider making this the default in sssad's version of singleton.pd as well.
I think that this is a good idea. Loadbang should be called whenever an object is finished being connected/installed in the context where it is supposed to be. In some dynamic patching contexts this is not necessarily obvious, so the responsibility of calling loadbang is on the patch that does the dynamic patching. Sometimes it's still not obvious when should loadbang happen, but singleton is easy enough to figure out, and in general, every patch performing dynamic patching should call loadbang on any new objects, though it's possible that pd doesn't have the infrastructure to allow doing this in general in an easy way (?).
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada