Forums > Dev

maximum number of attributes??


MIB
December 15, 2013 | 11:13 pm

I am writing an external (SDK 6.1.4) with a ton (43 so far) of attributes and there are some issues I don’t understand. I am using the CLASS_ATTR_ macros and everything gets added fine to the inspector, etc…

When I try to set some attributes, up to 4 random attributes in my list are getting set as well… I double and triple checked that my naming is correct.

In main() I am setting my attributes like this:

CLASS_ATTR_LONG(c, "frameHist", 0, t_MRleap, frameHist);
CLASS_ATTR_STYLE_LABEL(c, "frameHist", 0, "text", "FrameHist");
CLASS_ATTR_FILTER_CLIP(c, "frameHist", 1, 59);
CLASS_ATTR_SAVE(c,"frameHist", 0);
CLASS_ATTR_CATEGORY(c, "frameHist", 0, "Global");

and in new() I am setting my attributes to some default values and then I am calling attr_args_process(x, argc, argv);.

Am I missing something obvious? I have been going crazy over this for days now! Any help would be so much appreciated!



MIB
December 16, 2013 | 6:20 am

sorry… no, I meant if I try to set a single attribute (either through typing in the object or using the inspector), the attribute itself gets set along with up to 3 other ones… usually ones that are right above it. also, when I click the top most selected attribute (usually one of the ones that got set by mistake), ALL the attributes get deselected (the are all of type "onoff").

does this narrow it down?



MIB
December 16, 2013 | 1:07 pm

object struct:

typedef struct _MRleap
{
    t_object            ob;
    
    
    t_int64             prevFrameID;
    t_int64             curFrameID;
    
    t_bool              allDegOnOff;
    ///////////frame
    t_bool              frameRotOnOff;
    t_bool              frameMainOnOff;
    t_bool              frameRotRawOnOff;
    t_bool              frameScaleOnOff;
    t_bool              frameScaleRawOnOff;
    t_bool              frameTranslationOnOff;
    t_bool              frameTranslationRawOnOff;
    t_bool              frameTranslationNormOnOff;
    t_bool              frameRotationMatrix;
    
    float               frameRotProb;
    float               frameScaleProb;
    float               frameTranslationProb;
  
    int                 frameHist;
    ///////////hand
    t_bool              handMainOnOff;
    t_bool              handSphereOnOff;
    t_bool              handSphereNorm;
    t_bool              handPositionOnOff;
    t_bool              handPositionNormOnOff;
    t_bool              handPositionStabilizationOnOff;
    t_bool              handRotationOnOff;
    t_bool              handRotationRawOnOff;
    t_bool              handScaleRawOnOff;
    t_bool              handScaleOnOff;
    t_bool              handTranslationRawOnOff;
    t_bool              handTranslationNormOnOff;
    t_bool              handTranslationOnOff;
    t_bool              handRotationMatrix;
    t_bool              handHorizontalPlaneOnOff;
    
    float               handRotationProb;
    float               handScaleProb;
    float               handTranslationProb;
    //////pointables
    t_bool              toolMainOnOff;
    t_bool              fingerMainOnOff;
    t_bool              toolDirectionOnOff;
    t_bool              fingerDirectionOnOff;
    t_bool              toolTipPositionOnOff;
    t_bool              toolTipNormOnOff;
    t_bool              fingerTipPositionOnOff;
    t_bool              fingerTipNormOnOff;
    t_bool              toolTipVelocityOnOff;
    t_bool              fingerTipVelocityOnOff;
    t_bool              toolDimensionOnOff;
    t_bool              fingerDimensionOnOff;
    t_bool              toolTouchZoneOnOff;
    t_bool              fingerTouchZoneOnOff;
    
    ///////////////
    /////outlets
    void                *outletStart;
	void                *outletFrame;
    void                *outletHands;
    void                *outletTools;
    void                *outletFingers;
    void                *outletGestures;
    //////////////
    //////Gesture attr defaults
    float               circleMinRadius;
    float               circleMinArc;
    float               swipeMinLength;
    float               swipeMinVelocity;
    float               keyTapMinDownVelocity;
    float               keyTapHistorySeconds;
    float               keyTapMinDistance;
    float               screenTapMinForwardVelocity;
    float               screenTapHistorySeconds;
    float               screenTapMinDistance;
    
    //////Leap
	Leap::Controller	*leap;    

} t_MRleap;


MIB
December 16, 2013 | 1:14 pm

main function (I had to cut out some of the macros… it wouldn’t let me post that much text):

int C74_EXPORT main(void)
{
	t_class *c;
	
	c = class_new("MRleap", (method)MRleap_new, (method)MRleap_free, sizeof(t_MRleap), NULL, A_GIMME, 0);
    class_addmethod(c, (method)MRleap_bang,                     "bang",                               0);
    class_addmethod(c, (method)MRleap_assist,                   "assist",                    A_CANT,  0);

    /*********************************************************************/
    CLASS_ATTR_LONG(c, "frameHist", 0, t_MRleap, frameHist);
	CLASS_ATTR_STYLE_LABEL(c, "frameHist", 0, "text", "FrameHist");
    CLASS_ATTR_FILTER_CLIP(c, "frameHist", 1, 59);
	CLASS_ATTR_SAVE(c,"frameHist", 0);
    /*********************************************************************/
    CLASS_ATTR_LONG(c, "allDegOnOff", 0, t_MRleap, allDegOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "allDegOnOff", 0, "onoff", "Degrees");
	CLASS_ATTR_SAVE(c,"allDegOnOff", 0);
    /************************** FRAME ********************************/
    CLASS_ATTR_LONG(c, "frameMainOnOff", 0, t_MRleap, frameMainOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "frameMainOnOff", 0, "onoff", "FrameMain");
	CLASS_ATTR_SAVE(c,"frameMainOnOff", 0);
    /*********************************************************************/
    CLASS_ATTR_LONG(c, "frameRotOnOff", 0, t_MRleap, frameRotOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "frameRotOnOff", 0, "onoff", "FrameRot");
	CLASS_ATTR_SAVE(c,"frameRotOnOff", 0);
   
	CLASS_ATTR_LONG(c, "frameRotRawOnOff", 0, t_MRleap, frameRotRawOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "frameRotRawOnOff", 0, "onoff", "FrameRotRaw");
	CLASS_ATTR_SAVE(c,"frameRotRawOnOff", 0);
    
    CLASS_ATTR_FLOAT(c, "frameRotProb", 0, t_MRleap, frameRotProb);
	CLASS_ATTR_STYLE_LABEL(c, "frameRotProb", 0, "text", "FrameRotProb");
    CLASS_ATTR_FILTER_CLIP(c, "frameRotProb", 0, 1);
	CLASS_ATTR_SAVE(c,"frameRotProb", 0);
    /********************************************************************/
    CLASS_ATTR_LONG(c, "frameScaleOnOff", 0, t_MRleap, frameScaleOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "frameScaleOnOff", 0, "onoff", "FrameScale");
	CLASS_ATTR_SAVE(c,"frameScaleOnOff", 0);

	CLASS_ATTR_LONG(c, "frameScaleRawOnOff", 0, t_MRleap, frameScaleRawOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "frameScaleRawOnOff", 0, "onoff", "FrameScaleRaw");
	CLASS_ATTR_SAVE(c,"frameScaleRawOnOff", 0);

    CLASS_ATTR_FLOAT(c, "frameScaleProb", 0, t_MRleap, frameScaleProb);
	CLASS_ATTR_STYLE_LABEL(c, "frameScaleProb", 0, "text", "FrameScaleProb");
    CLASS_ATTR_FILTER_CLIP(c, "frameScaleProb", 0, 1);
	CLASS_ATTR_SAVE(c,"frameScaleProb", 0);
    /*********************************************************************/
    CLASS_ATTR_LONG(c, "frameTranslationOnOff", 0, t_MRleap, frameTranslationOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "frameTranslationOnOff", 0, "onoff", "FrameTrans");
	CLASS_ATTR_SAVE(c,"frameTranslationOnOff", 0);

    CLASS_ATTR_LONG(c, "frameTranslationRawOnOff", 0, t_MRleap, frameTranslationRawOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "frameTranslationRawOnOff", 0, "onoff", "FrameTransRaw");
	CLASS_ATTR_SAVE(c,"frameTranslationRawOnOff", 0);
     
    CLASS_ATTR_LONG(c, "frameTranslationNormOnOff", 0, t_MRleap, frameTranslationNormOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "frameTranslationNormOnOff", 0, "onoff", "FrameTransNorm");
	CLASS_ATTR_SAVE(c,"frameTranslationNormOnOff", 0);
    
    CLASS_ATTR_FLOAT(c, "frameTranslationProb", 0, t_MRleap, frameTranslationProb);
	CLASS_ATTR_STYLE_LABEL(c, "frameTranslationProb", 0, "text", "FrameTransProb");
    CLASS_ATTR_FILTER_CLIP(c, "frameTranslationProb", 0, 1);
	CLASS_ATTR_SAVE(c,"frameTranslationProb", 0);
    /*********************************************************************/
    CLASS_ATTR_LONG(c, "frameRotationMatrixOnOff", 0, t_MRleap, frameRotationMatrix);
	CLASS_ATTR_STYLE_LABEL(c, "frameRotationMatrixOnOff", 0, "onoff", "FrameRotMatrix");
	CLASS_ATTR_SAVE(c,"frameRotationMatrixOnOff", 0);
    /*********************************************************************/
    /************************** HAND *************************************/
    CLASS_ATTR_LONG(c, "handMainOnOff", 0, t_MRleap, handMainOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handMainOnOff", 0, "onoff", "HandMain");
	CLASS_ATTR_SAVE(c,"handMainOnOff", 0);
    /*********************************************************************/
	CLASS_ATTR_LONG(c, "handSphereOnOff", 0, t_MRleap, handSphereOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handSphereOnOff", 0, "onoff", "HandSphere");
	CLASS_ATTR_SAVE(c,"handSphereOnOff", 0);

    CLASS_ATTR_LONG(c, "handSphereNormOnOff", 0, t_MRleap, handSphereNorm);
	CLASS_ATTR_STYLE_LABEL(c, "handSphereNormOnOff", 0, "onoff", "HandSphereNorm");
	CLASS_ATTR_SAVE(c,"handSphereNormOnOff", 0);
    /*********************************************************************/
    CLASS_ATTR_LONG(c, "handPositionOnOff", 0, t_MRleap, handPositionOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handPositionOnOff", 0, "onoff", "HandPosition");
	CLASS_ATTR_SAVE(c,"handPositionOnOff", 0);
    
    CLASS_ATTR_LONG(c, "handPositionNormOnOff", 0, t_MRleap, handPositionNormOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handPositionNormOnOff", 0, "onoff", "HandPosNorm");
	CLASS_ATTR_SAVE(c,"handPositionNormOnOff", 0);
    
    CLASS_ATTR_LONG(c, "handPositionStabilizationOnOff", 0, t_MRleap, handPositionStabilizationOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handPositionStabilizationOnOff", 0, "onoff", "HandPosStable");
	CLASS_ATTR_SAVE(c,"handPositionStabilizationOnOff", 0);
    /*********************************************************************/
    CLASS_ATTR_LONG(c, "handRotationOnOff", 0, t_MRleap, handRotationOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handRotationOnOff", 0, "onoff", "HandRot");
	CLASS_ATTR_SAVE(c,"handRotationOnOff", 0);

	CLASS_ATTR_LONG(c, "handRotationRawOnOff", 0, t_MRleap, handRotationRawOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handRotationRawOnOff", 0, "onoff", "HandRotRaw");
	CLASS_ATTR_SAVE(c,"handRotationRawOnOff", 0);
    
    CLASS_ATTR_FLOAT(c, "handRotationProb", 0, t_MRleap, handRotationProb);
	CLASS_ATTR_STYLE_LABEL(c, "handRotationProb", 0, "text", "HandRotProb");
    CLASS_ATTR_FILTER_CLIP(c, "handRotationProb", 0, 1);
	CLASS_ATTR_SAVE(c,"handRotationProb", 0);
    /*********************************************************************/
    CLASS_ATTR_LONG(c, "handScaleOnOff", 0, t_MRleap, handScaleOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handScaleOnOff", 0, "onoff", "HandScale");
	CLASS_ATTR_SAVE(c,"handScaleOnOff", 0);

	CLASS_ATTR_LONG(c, "handScaleRawOnOff", 0, t_MRleap, handScaleRawOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handScaleRawOnOff", 0, "onoff", "HandScaleRaw");
	CLASS_ATTR_SAVE(c,"handScaleRawOnOff", 0);

    CLASS_ATTR_FLOAT(c, "handScaleProb", 0, t_MRleap, handScaleProb);
	CLASS_ATTR_STYLE_LABEL(c, "handScaleProb", 0, "text", "HandScaleProb");
    CLASS_ATTR_FILTER_CLIP(c, "handScaleProb", 0, 1);
	CLASS_ATTR_SAVE(c,"handScaleProb", 0);
    /*********************************************************************/
    CLASS_ATTR_LONG(c, "handTranslationOnOff", 0, t_MRleap, handTranslationOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handTranslationOnOff", 0, "onoff", "HandTrans");
	CLASS_ATTR_SAVE(c,"handTranslationOnOff", 0);

    CLASS_ATTR_LONG(c, "handTranslationRawOnOff", 0, t_MRleap, handTranslationRawOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handTranslationRawOnOff", 0, "onoff", "HandTransRaw");
	CLASS_ATTR_SAVE(c,"handTranslationRawOnOff", 0);

    CLASS_ATTR_LONG(c, "handTranslationNormOnOff", 0, t_MRleap, handTranslationNormOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handTranslationNormOnOff", 0, "onoff", "HandTransNorm");
	CLASS_ATTR_SAVE(c,"handTranslationNormOnOff", 0);

    CLASS_ATTR_FLOAT(c, "handTranslationProb", 0, t_MRleap, handTranslationProb);
	CLASS_ATTR_STYLE_LABEL(c, "handTranslationProb", 0, "text", "HandTransProb");
    CLASS_ATTR_FILTER_CLIP(c, "handTranslation  Prob", 0, 1);
	CLASS_ATTR_SAVE(c,"handTranslationProb", 0);
    /*********************************************************************/
    CLASS_ATTR_LONG(c, "handRotationMatrixOnOff", 0, t_MRleap, handRotationMatrix);
	CLASS_ATTR_STYLE_LABEL(c, "handRotationMatrixOnOff", 0, "onoff", "HandRotMatrix");
	CLASS_ATTR_SAVE(c,"handRotationMatrixOnOff", 0);
    /*********************************************************************/
    CLASS_ATTR_LONG(c, "handHorizontalPlaneOnOff", 0, t_MRleap, handHorizontalPlaneOnOff);
	CLASS_ATTR_STYLE_LABEL(c, "handHorizontalPlaneOnOff", 0, "onoff", "HandPlane");
	CLASS_ATTR_SAVE(c,"handHorizontalPlaneOnOff", 0);
    /*********************************************************************/
    /*****************************Pointalbes******************************/
    //CUT!!
    /*********************************************************************/

	class_register(CLASS_BOX, c);
    
	MRleap_class = c;
    
	return 0;
}


MIB
December 16, 2013 | 1:15 pm

(the above example of a macro that confused you was poorly chosen by me… I grabbed the first one without looking what it was. they are mostly "onoff" with some "text" ones as you can see from the entire list now)

And thanks again for looking at this. I am really lost…



MIB
December 16, 2013 | 10:04 pm

if it helps, here is what it looks like when it goes wrong…



MIB
December 17, 2013 | 12:03 am

this looks promising!! I have to run some more tests but this is a huge improvement already.

I’ll report back in a bit…



MIB
December 17, 2013 | 1:34 am

I think that did the trick. Still testing because I’m now paranoid about it but so far so good :)

Thanks so much!



MIB
December 17, 2013 | 8:30 am

hmmm… I am trying to handle integer input. Is that the way to do it, with a t_symbol?
Or is there no STYLE for this and I have to do a custom setter? Something like this?

t_max_err myobjet_setattr_myattr(t_myobject *x, void *attr, long ac, t_atom *av)
{
    if (ac && av) {
        if (atom_gettype(av) == A_LONG || atom_gettype(av) == A_FLOAT) {
            x->myattr = *av;
        else
            atom_setsym(&x->myattr, gensym(""));
    } else
        atom_setsym(&x->myattr, gensym(""));

     return MAX_ERR_NONE;
}


MIB
December 17, 2013 | 9:49 pm

sorry. I am still getting my head around the macros! I wanted to set a label in the inspector and missed that there was a CLASS_ATTR_LABEL one!!

Thanks for your patients!!

While I’m here can I bother you with one more question? When I set categories (very handy in my case!!) do they have to be alphabetically ordered in the inspector or is there a way to custom order them along the lines of CLASS_ATTR_ORDER?



MIB
December 22, 2013 | 3:15 am

That’s what I thought… maybe in the future. Thanks


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