Hallo all,
I'm working on my complex DS sequencer, and the time has come that I'd like to read and write sequences from it.
The problem is this: all of my templates are written like [pd $0.note-template] to allow multiple instances of the sequencer, but this seems to be incompatible with reading and writing data from a subpatch ( like [write my-data.structure( - [pd $0.data] ), because the $0 is expanded in the written file (so it's full of "template 90953loopMarkerTemplate;" etc. rather than "template $0loopMarkerTemplate;").
The immediate thought was to split the templates into a separate patch altogether, and spawn it before creating the sequencer or use a singleton approach. But, this ruins using [change( messages from [struct]s as well as selectively turning on and off [draw*]n elements on a per-sequencer basis.
The only other option AFAICT is to forget DS reading and writing and just mirror the data in lists with SSSAD, but that would be a shame considering the capability exists already.
It seems to me that the written datastructure definition should preserve $0, no? Anyone have any other ideas?
(apologies if this is unclear, I'm very tired at the moment) Best Luke
Luke,
I think this should be allowed, hell, even the use of other $ arguments. It would be nice to be able to allow abstractions to create their own private data structures, or at least ones that could be named based on a creation argument.
If nothing else, it would prevent any kind of structure naming clashes between objects that define structure with the same name.
I had, like you, tried this same thing only to find that the saves files were then having those structures renamed.
It would also be nice if you could store a reference to any type of data structure within one of these "private" data structures... of course, the abstraction being passed this arbitrary pointer to a data structure wouldn't know what to do with it, but it could be sent out an outlet to some outside processing code. Could this be done by adding a 'pointer' type to the structure definition? Something like:
[struct my-struct float value pointer object]
Mike
On Sun, Nov 30, 2008 at 9:32 PM, Luke Iannini lukexipd@gmail.com wrote:
Hallo all,
I'm working on my complex DS sequencer, and the time has come that I'd like to read and write sequences from it.
The problem is this: all of my templates are written like [pd $0.note-template] to allow multiple instances of the sequencer, but this seems to be incompatible with reading and writing data from a subpatch ( like [write my-data.structure( - [pd $0.data] ), because the $0 is expanded in the written file (so it's full of "template 90953loopMarkerTemplate;" etc. rather than "template $0loopMarkerTemplate;").
The immediate thought was to split the templates into a separate patch altogether, and spawn it before creating the sequencer or use a singleton approach. But, this ruins using [change( messages from [struct]s as well as selectively turning on and off [draw*]n elements on a per-sequencer basis.
The only other option AFAICT is to forget DS reading and writing and just mirror the data in lists with SSSAD, but that would be a shame considering the capability exists already.
It seems to me that the written datastructure definition should preserve $0, no? Anyone have any other ideas?
(apologies if this is unclear, I'm very tired at the moment) Best Luke
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
this is why i gave up on datastructs the first time i learnt how to use them. i always just thought i was doing something wrong.
Then how do you deal with situations where you need to store related info like this? I could see that it would be very easy to come up with an alternative, using something like an external written in Lua (or even in C), that would allow for the storing of related/structured data.
What do you do?
Mike
On Mon, Dec 1, 2008 at 2:30 AM, hard off hard.off@gmail.com wrote:
this is why i gave up on datastructs the first time i learnt how to use them. i always just thought i was doing something wrong.
i dunno. i gave up. i didn't look for a solution.
was just saying that it was the $0 problem that finally made me too frustrated to continue.
Well, I would be interested in knowing how many people actually use data structures, and if they do, is it for the ability to create graphical editors of the data.
Mike
On Mon, Dec 1, 2008 at 3:42 AM, hard off hard.off@gmail.com wrote:
i dunno. i gave up. i didn't look for a solution.
was just saying that it was the $0 problem that finally made me too frustrated to continue.
Hallo, Mike McGonagle hat gesagt: // Mike McGonagle wrote:
I think this should be allowed, hell, even the use of other $ arguments. It would be nice to be able to allow abstractions to create their own private data structures, or at least ones that could be named based on a creation argument.
All this *is* allowed. But Luke's problem is more general: If you use $0, its value is only valid in a running patch. This not only affects data structures, but everything, i.e. also qlist, textfile and so on.
If you write the value of $0 into textfile, you get something like 1023, which probably is not the same value $0 has when you reload the file later in a different context.
It all boils down to the fact, that Pd only has global scoping and that using $0 is just a limited workaround, but not adding a real local scope.
The only thing that could be considered local scope in Pd are direct patch cord connections: They are as local as it gets.
So what I generally do if I use $0-structs is to not save the data structure instances with "write pd-x" but traverse and parse them down into [textfile] and use that for storing and reloading. I.e. with
[struct $0-a float x float y]
and a data subpatch [pd x], I'd use traverse pd-x, and write each x,y-pair into [textfile]. Then to reload, I clear pd-x, and dump the textfile's contents to an [append $0-a x y].
This acctually has the advantage, that I can prepare the textfile in a text editor or so.
Frank Barknecht Do You RjDj.me? _ ______footils.org__
Hum, I have had this issue with other things using $0, and it seems almost impossible while developing a patch to NOT save over a patch containing a $0 reference. There are some situations that I have learned not to do this, but that was only after several lost patches and data...
While it has been a while, I believe that those other issues also involved data structures.
While Pd is a great tool, it does have several things that will bite you, unless you heed Marshal Brodeen's advice, "It's easy, once you know the secret..."
Mike
On Mon, Dec 1, 2008 at 4:54 AM, Frank Barknecht fbar@footils.org wrote:
Hallo, Mike McGonagle hat gesagt: // Mike McGonagle wrote:
I think this should be allowed, hell, even the use of other $ arguments. It would be nice to be able to allow abstractions to create their own private data structures, or at least ones that could be named based on a creation argument.
All this *is* allowed. But Luke's problem is more general: If you use $0, its value is only valid in a running patch. This not only affects data structures, but everything, i.e. also qlist, textfile and so on.
If you write the value of $0 into textfile, you get something like 1023, which probably is not the same value $0 has when you reload the file later in a different context.
It all boils down to the fact, that Pd only has global scoping and that using $0 is just a limited workaround, but not adding a real local scope.
The only thing that could be considered local scope in Pd are direct patch cord connections: They are as local as it gets.
So what I generally do if I use $0-structs is to not save the data structure instances with "write pd-x" but traverse and parse them down into [textfile] and use that for storing and reloading. I.e. with
[struct $0-a float x float y]
and a data subpatch [pd x], I'd use traverse pd-x, and write each x,y-pair into [textfile]. Then to reload, I clear pd-x, and dump the textfile's contents to an [append $0-a x y].
This acctually has the advantage, that I can prepare the textfile in a text editor or so.
Ciao
Frank Barknecht Do You RjDj.me? _ ______footils.org__
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hallo, Mike McGonagle hat gesagt: // Mike McGonagle wrote:
Hum, I have had this issue with other things using $0, and it seems almost impossible while developing a patch to NOT save over a patch containing a $0 reference. There are some situations that I have learned not to do this, but that was only after several lost patches and data...
Hm, I guess I don't completely understand what you are referring to. Of course, the filename that is used to store the settings should not contain the value of $0 in its name.
Generally $0 should be considered a volatile value that is only living inside of Pd objects' names.
Frank
On Mon, Dec 1, 2008 at 5:25 AM, Frank Barknecht fbar@footils.org wrote:
Hallo, Mike McGonagle hat gesagt: // Mike McGonagle wrote:
Hm, I guess I don't completely understand what you are referring to.
Probably my inability to remember exactly what happened. Data Structures just seems to me to be one of the hardest parts of Pd.
Mike
Hi,
i'm working on an abstraction with data structures inside (franks tutorial was very helpful http://puredata.info/community/projects/convention04/lectures/tk-barknecht/t... ) and i use $1 in the name of the template (like this: struct $1-template float y array numbers $1-template-num), this works and i have a workaround for getting both - a non changing part in the data structure which is quite unique for each instance of the abstracion ( ;) i just have to take care not to give two abstractions the same creation argument). g.
ps.: in the tutorial by Gregorio Garcia Karman is also a good starting point ( http://puredata.info/Members/ggkarman/Tutoriales/datastruct_en_02/view )
Frank Barknecht schrieb:
Hallo, Mike McGonagle hat gesagt: // Mike McGonagle wrote:
I think this should be allowed, hell, even the use of other $ arguments. It would be nice to be able to allow abstractions to create their own private data structures, or at least ones that could be named based on a creation argument.
All this *is* allowed. But Luke's problem is more general: If you use $0, its value is only valid in a running patch. This not only affects data structures, but everything, i.e. also qlist, textfile and so on.
If you write the value of $0 into textfile, you get something like 1023, which probably is not the same value $0 has when you reload the file later in a different context.
It all boils down to the fact, that Pd only has global scoping and that using $0 is just a limited workaround, but not adding a real local scope.
The only thing that could be considered local scope in Pd are direct patch cord connections: They are as local as it gets. So what I generally do if I use $0-structs is to not save the data structure instances with "write pd-x" but traverse and parse them down into [textfile] and use that for storing and reloading. I.e. with [struct $0-a float x float y]
and a data subpatch [pd x], I'd use traverse pd-x, and write each x,y-pair into [textfile]. Then to reload, I clear pd-x, and dump the textfile's contents to an [append $0-a x y].
This acctually has the advantage, that I can prepare the textfile in a text editor or so.
Ciao
On Mon, Dec 01, 2008 at 11:54:34AM +0100, Frank Barknecht wrote:
Hallo, Mike McGonagle hat gesagt: // Mike McGonagle wrote:
I think this should be allowed, hell, even the use of other $ arguments. It would be nice to be able to allow abstractions to create their own private data structures, or at least ones that could be named based on a creation argument.
So what I generally do if I use $0-structs is to not save the data structure instances with "write pd-x" but traverse and parse them down into [textfile] and use that for storing and reloading. I.e. with
I do the same, but I use sssad to store the serialised data which gives the user flexibility about where they want to save it. Check out the [pd load] and [pd save] subpatches in s-nadsr~ for an example of how to do this with datastructures:
http://mccormick.cx/viewcvs/*checkout*/s-abstractions/s-nadsr~.pd?root=svn
Best,
Chris.