Forums > Dev

Pattr related questions

February 17, 2007 | 5:12 pm


February 18, 2007 | 1:30 pm


February 18, 2007 | 10:14 pm


February 18, 2007 | 10:37 pm


February 18, 2007 | 11:29 pm


February 19, 2007 | 8:32 pm


February 23, 2007 | 3:30 pm


February 23, 2007 | 6:24 pm


February 26, 2007 | 4:20 pm


February 26, 2007 | 11:48 pm


February 26, 2007 | 11:53 pm

This is one of the little nods in the direction of efficiency that I
also make. It certainly can’t hurt, and it probably helps a little
bit. Compared to calculating FFTs or doing video interpolation, a
symbol table lookup is a drop in the bucket, but every little bit helps.

jb

Am 27.02.2007 um 00:48 schrieb Luigi Castelli:

> Now, does it make sense – for the sake of efficiency -
> to store global pointers to symbols specifying
> attributes names in order to avoid calling ‘gensym’
> everytime?
>
> For instance, I can declare a global variable:
> t_symbol *ps_myattr;
>
> and define it in main like this:
> ps_myattr = gensym("myattr");
>
> so now I can write:
> object_attr_setfloat(x, ps_myattr, value);
>
> Does it make a difference, is it worth it? or not
> really?


February 27, 2007 | 8:02 am

Hello again,

As you probably have understood by now, I am working
on a MSP external that I would like to make compatible
with Pattr. Now, as it happens in many MSP objects I
can change the internal state of my object both with
messages or with signals connected to the object’s
inlets. I need a way to notify Pattr that the internal
state has changed when I have a signal connected.

is it safe to call object_notify(x->box,
_sym_modified, 0L);
in the perform method? Not in the while loop, but just
outside.

Here some sample code to better show what I am trying
to do:

————————————————–
static t_int *pan_tilde_perform(t_int *w)
{
t_pan_tilde *x = (t_pan_tilde *)(w[1]);
float *in = (float *)(w[2]);
float value = *(float *)(w[3]);
float *out1 = (float *)(w[4]);
float *out2 = (float *)(w[5]);
long n = (long)(w[6]);
float Lamp = x->Lamp;
float Ramp = x->Ramp;

if (x->ob.z_disabled) {
goto out;
}
if (value != x->value) {
long index = (long)(1024.f * value + 1024.f);
index = CLIP(index, 0, 2048);
float Lamp_next = gCos[index];
float Ramp_next = gSin[index];
float Lamp_slope = CALC_SLOPE(Lamp_next, Lamp);
float Ramp_slope = CALC_SLOPE(Ramp_next, Ramp);
while (n–) {
float sig = *in++;
*out1++ = sig * Lamp;
*out2++ = sig * Ramp;
Lamp += Lamp_slope;
Ramp += Ramp_slope;
}
x->value = value
x->Lamp = Lamp_next;
x->Ramp = Ramp_next;
object_notify(x->box, _sym_modified, 0L); ///
??????
} else {
while (n–) {
float sig = *in++;
*out1++ = sig * Lamp;
*out2++ = sig * Ramp;
}
}
out:
return w + 7;
————————————————–

Is Max gonna choke if the user chooses a small vector
size?
Are there different (better) techniques to achieve the
above?

Thanks for your time.

- Luigi

————————————————————
THIS E-MAIL MESSAGE IS FOR THE SOLE USE OF THE INTENDED RECIPIENT AND MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT, CONTACT THE SENDER BY E-MAIL AT SUPERBIGIO@YAHOO.COM AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE. WITHOUT PREJUDICE UCC1-207.
————————————————————

Get your own web address.
Have a HUGE year through Yahoo! Small Business.

http://smallbusiness.yahoo.com/domains/?p=BESTDEAL


February 27, 2007 | 8:08 am

Hi Luigi,
Perhaps the qelem or clock functions available in the Max SDK would
help here. You could setup a timer to poll the value of your
parameters every N ms to avoid having to do something crazy in the
audio thread. See the Writing Max Externals PDF for more on these
functions.

wes

On 2/27/07, Luigi Castelli wrote:
> Hello again,
>
> As you probably have understood by now, I am working
> on a MSP external that I would like to make compatible
> with Pattr. Now, as it happens in many MSP objects I
> can change the internal state of my object both with
> messages or with signals connected to the object’s
> inlets. I need a way to notify Pattr that the internal
> state has changed when I have a signal connected.
>
> is it safe to call object_notify(x->box,
> _sym_modified, 0L);
> in the perform method? Not in the while loop, but just
> outside.
>
> Here some sample code to better show what I am trying
> to do:
>
> ————————————————–
> static t_int *pan_tilde_perform(t_int *w)
> {
> t_pan_tilde *x = (t_pan_tilde *)(w[1]);
> float *in = (float *)(w[2]);
> float value = *(float *)(w[3]);
> float *out1 = (float *)(w[4]);
> float *out2 = (float *)(w[5]);
> long n = (long)(w[6]);
> float Lamp = x->Lamp;
> float Ramp = x->Ramp;
>
> if (x->ob.z_disabled) {
> goto out;
> }
> if (value != x->value) {
> long index = (long)(1024.f * value + 1024.f);
> index = CLIP(index, 0, 2048);
> float Lamp_next = gCos[index];
> float Ramp_next = gSin[index];
> float Lamp_slope = CALC_SLOPE(Lamp_next, Lamp);
> float Ramp_slope = CALC_SLOPE(Ramp_next, Ramp);
> while (n–) {
> float sig = *in++;
> *out1++ = sig * Lamp;
> *out2++ = sig * Ramp;
> Lamp += Lamp_slope;
> Ramp += Ramp_slope;
> }
> x->value = value
> x->Lamp = Lamp_next;
> x->Ramp = Ramp_next;
> object_notify(x->box, _sym_modified, 0L); ///
> ??????
> } else {
> while (n–) {
> float sig = *in++;
> *out1++ = sig * Lamp;
> *out2++ = sig * Ramp;
> }
> }
> out:
> return w + 7;
> ————————————————–
>
> Is Max gonna choke if the user chooses a small vector
> size?
> Are there different (better) techniques to achieve the
> above?
>
> Thanks for your time.
>
> – Luigi
>
>
>
>
>
> ————————————————————
> THIS E-MAIL MESSAGE IS FOR THE SOLE USE OF THE INTENDED RECIPIENT AND MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT, CONTACT THE SENDER BY E-MAIL AT SUPERBIGIO@YAHOO.COM AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE. WITHOUT PREJUDICE UCC1-207.
> ————————————————————
>
>
>
>
> Get your own web address.
> Have a HUGE year through Yahoo! Small Business.
> http://smallbusiness.yahoo.com/domains/?p=BESTDEAL
>


February 27, 2007 | 5:49 pm

Yes, that’s the obvious path to follow, however I am
curious about other techniques to accomplish the same
that do not involve the use of clocks or qelems.

If I use qelems I can still get backlogging if the
qelem function gets called too often, which might
happen if it’s in the perform routine, especially with
small vector sizes.

Clocks do not have this issue because you can set a
polling interval time, however my programmer sixth
sense tells me they are not what’s ideal to use in
this case.

Is it safe to use object_notify(…) directly in the
perform routine?

Any thoughts or advice?

Thanks.

- Luigi

— Wesley Smith wrote:

> Hi Luigi,
> Perhaps the qelem or clock functions available in
> the Max SDK would
> help here. You could setup a timer to poll the
> value of your
> parameters every N ms to avoid having to do
> something crazy in the
> audio thread. See the Writing Max Externals PDF for
> more on these
> functions.
>
> wes
>
> On 2/27/07, Luigi Castelli
> wrote:
> > Hello again,
> >
> > As you probably have understood by now, I am
> working
> > on a MSP external that I would like to make
> compatible
> > with Pattr. Now, as it happens in many MSP objects
> I
> > can change the internal state of my object both
> with
> > messages or with signals connected to the object’s
> > inlets. I need a way to notify Pattr that the
> internal
> > state has changed when I have a signal connected.
> >
> > is it safe to call object_notify(x->box,
> > _sym_modified, 0L);
> > in the perform method? Not in the while loop, but
> just
> > outside.
> >
> > Here some sample code to better show what I am
> trying
> > to do:
> >
> > ————————————————–
> > static t_int *pan_tilde_perform(t_int *w)
> > {
> > t_pan_tilde *x = (t_pan_tilde *)(w[1]);
> > float *in = (float *)(w[2]);
> > float value = *(float *)(w[3]);
> > float *out1 = (float *)(w[4]);
> > float *out2 = (float *)(w[5]);
> > long n = (long)(w[6]);
> > float Lamp = x->Lamp;
> > float Ramp = x->Ramp;
> >
> > if (x->ob.z_disabled) {
> > goto out;
> > }
> > if (value != x->value) {
> > long index = (long)(1024.f * value
> + 1024.f);
> > index = CLIP(index, 0, 2048);
> > float Lamp_next = gCos[index];
> > float Ramp_next = gSin[index];
> > float Lamp_slope =
> CALC_SLOPE(Lamp_next, Lamp);
> > float Ramp_slope =
> CALC_SLOPE(Ramp_next, Ramp);
> > while (n–) {
> > float sig = *in++;
> > *out1++ = sig * Lamp;
> > *out2++ = sig * Ramp;
> > Lamp += Lamp_slope;
> > Ramp += Ramp_slope;
> > }
> > x->value = value
> > x->Lamp = Lamp_next;
> > x->Ramp = Ramp_next;
> > object_notify(x->box,
> _sym_modified, 0L); ///
> > ??????
> > } else {
> > while (n–) {
> > float sig = *in++;
> > *out1++ = sig * Lamp;
> > *out2++ = sig * Ramp;
> > }
> > }
> > out:
> > return w + 7;
> > ————————————————–
> >
> > Is Max gonna choke if the user chooses a small
> vector
> > size?
> > Are there different (better) techniques to achieve
> the
> > above?
> >
> > Thanks for your time.
> >
> > – Luigi
> >
> >
> >
> >
> >
> >
>
————————————————————
> > THIS E-MAIL MESSAGE IS FOR THE SOLE USE OF THE
> INTENDED RECIPIENT AND MAY CONTAIN CONFIDENTIAL
> AND/OR PRIVILEGED INFORMATION. ANY UNAUTHORIZED
> REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS
> PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT,
> CONTACT THE SENDER BY E-MAIL AT SUPERBIGIO@YAHOO.COM
> AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE.
> WITHOUT PREJUDICE UCC1-207.
> >
>
————————————————————
> >
> >
> >
> >
> >
>
> > Get your own web address.
> > Have a HUGE year through Yahoo! Small Business.
> > http://smallbusiness.yahoo.com/domains/?p=BESTDEAL
> >
>

————————————————————
THIS E-MAIL MESSAGE IS FOR THE SOLE USE OF THE INTENDED RECIPIENT AND MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT, CONTACT THE SENDER BY E-MAIL AT SUPERBIGIO@YAHOO.COM AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE. WITHOUT PREJUDICE UCC1-207.
————————————————————

Don’t pick lemons.
See all the new 2007 cars at Yahoo! Autos.

http://autos.yahoo.com/new_cars.html


February 27, 2007 | 6:17 pm

On Feb 27, 2007, at 9:49 AM, Luigi Castelli wrote:

> If I use qelems I can still get backlogging if the
> qelem function gets called too often, which might
> happen if it’s in the perform routine, especially with
> small vector sizes.

No. Using *one* qelem or clock explicitly *prevents* backlogging,
since they are single events. As compared with defer(low) or schedule
which lead to a generation of new events one for each call. This is
the ideal way to accomplish this.

> Is it safe to use object_notify(…) directly in the
> perform routine?

No.

-Joshua


February 27, 2007 | 6:36 pm

ok, great. I understand now. Thank you.

so what’s the difference between a clock and a qelem?
Which one is most appropriate in this situation?

- Luigi

— Joshua Kit Clayton wrote:

>
> On Feb 27, 2007, at 9:49 AM, Luigi Castelli wrote:
>
> > If I use qelems I can still get backlogging if the
> > qelem function gets called too often, which might
> > happen if it’s in the perform routine, especially
> with
> > small vector sizes.
>
> No. Using *one* qelem or clock explicitly *prevents*
> backlogging,
> since they are single events. As compared with
> defer(low) or schedule
> which lead to a generation of new events one for
> each call. This is
> the ideal way to accomplish this.
>
> > Is it safe to use object_notify(…) directly in
> the
> > perform routine?
>
> No.
>
> -Joshua
>

————————————————————
THIS E-MAIL MESSAGE IS FOR THE SOLE USE OF THE INTENDED RECIPIENT AND MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT, CONTACT THE SENDER BY E-MAIL AT SUPERBIGIO@YAHOO.COM AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE. WITHOUT PREJUDICE UCC1-207.
————————————————————

Bored stiff? Loosen up…
Download and play hundreds of games for free on Yahoo! Games.

http://games.yahoo.com/games/front


February 27, 2007 | 7:18 pm

On Feb 27, 2007, at 10:36 AM, Luigi Castelli wrote:

> so what’s the difference between a clock and a qelem?

Please read dev doc. clock == scheduler event. qelem == low priority
queue event.

> Which one is most appropriate in this situation?

clock is probably best from perform.

-Joshua


Viewing 17 posts - 1 through 17 (of 17 total)