Hi all,
I'm trying to send a typedmess() from within the C-code of an external to the patch that it currently resides on. But in order to do so, I need the symbol name of the patch.
So the question:
From within a method call of an external, can I somehow find the pointer
to the symbol name of the current patcher?
Thanks to anyone who can help! -Mike Wozniewski
Okay, so I've found the following function:
t_canvas *z = canvas_getcurrent();
Now does anyone know how to get the symbol name for that canvas? I need something like z->s_thing so that I can send a message to the canvas, but t_canvas has no s_thing member.
Any help is greatly appreciated.
-Mike
On Mon, 2005-05-09 at 00:19 -0400, Mike Wozniewski wrote:
Hi all,
I'm trying to send a typedmess() from within the C-code of an external to the patch that it currently resides on. But in order to do so, I need the symbol name of the patch.
So the question:
From within a method call of an external, can I somehow find the pointer
to the symbol name of the current patcher?
Thanks to anyone who can help! -Mike Wozniewski
t_canvas *z = canvas_getcurrent();
iirc, it's only allowed to call this in the constructor ...
a t_canvas is a _glist possibly you can access it with z->gl_name ... (have a look at g_canvas.h for implementation details) but be aware that you are not allowed to include g_canvas.h, since it's a private header... so your binaries will only work with different versions of pd
hth .... tim
Hi Tim,
Thanks for that info - it works now! ...though I had to make one addition. I needed to use canvas_makebindsym() to allow sending messages to the canvas symbol (see #3 in code below).
I have just one last clarification... I don't quite understand what you meant when you said:
but be aware that you are not allowed to include g_canvas.h, since it's a private header... so your binaries will only work with different versions of pd
It seems to work great for me (standard Pd version 0.38.4)... I suppose this is because I compiled my external with the headers from my current Pd version. Do you mean that the binary will not work if I give it to someone with another version of Pd? Why would g_canvas.h change that much?
----------
Anyway... I will recap for those who want to dynamically generate objects on the same patch that your external resides on:
1) include g_canvas.h:
#include "g_canvas.h"
2) In the struct for your object, hold a t_symbol for the canvas:
typedef struct _externName { t_object x_obj; t_symbol *canvasSymbol; ... } t_externName}
3) In the constructor:
canvasSymbol = canvas_makebindsym(canvas_getcurrent()->gl_name);
4) Then in any method, generate a new object on the canvas with:
typedmess(x->canvasSymbol->s_thing, gensym("obj"), ... );
That's it.
-Mike
On Mon, 2005-05-09 at 22:00 +0000, Tim Blechmann wrote:
t_canvas *z = canvas_getcurrent();
iirc, it's only allowed to call this in the constructor ...
a t_canvas is a _glist possibly you can access it with z->gl_name ... (have a look at g_canvas.h for implementation details) but be aware that you are not allowed to include g_canvas.h, since it's a private header... so your binaries will only work with different versions of pd
hth .... tim
but be aware that you are not allowed to include g_canvas.h, since it's a private header... so your binaries will only work with different versions of pd
It seems to work great for me (standard Pd version 0.38.4)... I suppose this is because I compiled my external with the headers from my current Pd version. Do you mean that the binary will not work if I give it to someone with another version of Pd?
exactly ... i doubt that binaries will work in 0.37 or 0.39
Why would g_canvas.h change that much?
don't ask me ... ask miller
cheers ... tim