Hi list,
If I were to make an external that has access to $ arguments, does anyone know where I can find the necessary methods for retrieving this information? Or is it only available at instantiation?
Most importantly, I am looking for a way to get the $0 value of a patch from C.
Cheers, Rich
On Sun, 23 Jan 2011, Rich E wrote:
If I were to make an external that has access to $ arguments, does anyone know where I can find the necessary methods for retrieving this information? Or is it only available at instantiation? Most importantly, I am looking for a way to get the $0 value of a patch from C.
In all cases, you need to get a canvas environment (there is one per file loaded, that is, one per distinct value of $0) :
t_canvasenvironment *e = canvas_getenv(x->parent);
but you need to have a variable in your struct for accessing your parent :
t_canvas *parent;
that you need to set in the creator (constructor) because that's the only time you can obtain that information :
x->parent = canvas_getcurrent();
but when you need to get the $0, you need the e and you use this :
e->ce_dollarzero
and if you need to get $1, $2, $3, ... you use these :
e->ce_argv[0] /* $1 */ e->ce_argv[1] /* $2 */ e->ce_argv[2] /* $3 */ ...
but you don't use indices that are >= e->ce_argc, which is the number of arguments.
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
On Jan 23, 2011, at 6:49 AM, Rich E wrote:
Hi list,
If I were to make an external that has access to $ arguments, does
anyone know where I can find the necessary methods for retrieving
this information? Or is it only available at instantiation?Most importantly, I am looking for a way to get the $0 value of a
patch from C.Cheers, Rich
I think there are a few already, like in iemlib maybe? Something like
[dollarg]
.hc
I have the audacity to believe that peoples everywhere can have three
meals a day for their bodies, education and culture for their minds,
and dignity, equality and freedom for their spirits. - Martin
Luther King, Jr.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 2011-01-23 12:49, Rich E wrote:
Hi list,
If I were to make an external that has access to $ arguments, does anyone know where I can find the necessary methods for retrieving this information? Or is it only available at instantiation?
Most importantly, I am looking for a way to get the $0 value of a patch from C.
for $0, see the various implementations in iemlib, iemguts, tof, ... for other $args there is usually no need to find them, as the user could just supply them to your object. if you really need them, there are a number of implementations out there as well, e.g. in iemlib, iemguts, tof,...
gmasdrt IOhannes
Ah, understood. Thanks for the nice code explanation and references... they both really help.
I noticed that t_canvasenvironment remains privately defined, so it's difficult to use this struct. To get the dollarzero, I saw this works:
canvas_setcurrent(x_canvas);
int dzero = canvas_getdollarzero();
Cheers, Rich
On Tue, 25 Jan 2011, Rich E wrote:
Ah, understood. Thanks for the nice code explanation and references... they both really help. I noticed that t_canvasenvironment remains privately defined, so it's difficult to use this struct. To get the dollarzero, I saw this works:
canvas_setcurrent(x_canvas); int dzero = canvas_getdollarzero();
That's an alias of pd_pushsym. You are supposed to use it with canvas_unsetcurrent (alias of pd_popsym), though I don't remember what can really go wrong if you don't unset/pop.
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
On Sat, Feb 5, 2011 at 3:44 PM, Mathieu Bouchard matju@artengine.ca wrote:
On Tue, 25 Jan 2011, Rich E wrote:
Ah, understood. Thanks for the nice code explanation and references...
they both really help. I noticed that t_canvasenvironment remains privately defined, so it's difficult to use this struct. To get the dollarzero, I saw this works:
canvas_setcurrent(x_canvas); int dzero = canvas_getdollarzero();
That's an alias of pd_pushsym. You are supposed to use it with canvas_unsetcurrent (alias of pd_popsym), though I don't remember what can really go wrong if you don't unset/pop.
Lots of stuff goes wrong if you don't call canvas_unsetcurrent after setting it. :) I know because I was running into all sorts of EXC_BAD_ACCESS signals before doing it - specifically in some experiments in opening patches via x_canvas points. Thanks for the tip, Mathieu. I actually got a couple other questions now that I have figured out a bit more, but I'll save it for another thread..
Cheers, Rich