Hallo, Julian Peterson hat gesagt: // Julian Peterson wrote:
I'm writing my first piece that will take advantage of data structures in PD, and I've stumbled upon an error that I do not understand.
I have two structures drawn in the same subpatch. One is a sequence of notes, the other is a playhead. The sequencer was working fine until I added the playhead. Now whenever I try to get data from the sequencer (getsize, get) I receive the following error:
error: getsize pd-instr1: got wrong template (pd-playhead)
My patch is attached below. Is it not possible (or not advisable) for two structures to draw to the same subpatch?
You forgot to attach the patch, but I guess what's happening is some error in traversing the data structures in the patch. If you mix several types in a subpatch - which is perfectly possible - you need to be aware, that on traversal of this subpatch you will hit pointers of different type. So assuming you have a [struct a float x] and [struct b float x] in your patch, then if you do this:
[traverse pd-data, next( | [pointer]
what comes out of [pointer] may be a pointer to "a" or a pointer to "b". So if you try to [get] at the data using this:
[get a x]
you will get an error everytime, the incoming pointer is of type "b", because then you'd need to use [get b x] instead.
A way out can be this construct:
[traverse pd-data, next( | [pointer a b] | | | | | ... do something else here | | | [get b x] | [get a x]|
Frank Barknecht _ ______footils.org_ __goto10.org__