Получить имя объекта coll в Max C API - PullRequest
0 голосов
/ 23 сентября 2019

Я пишу внешнюю версию Max MSP.

Я потерян в документации по Max C API уже несколько часов и не могу найти способ получить имя объекта coll от Макса.C API.

https://cycling74.com/sdk/max-sdk-8.0.3/html/index.html

Если объект | coll foo |, foo - это символ, который я хочу получить.

Я могу перебрать патчер иполучить указатели на все ящики, а затем на объекты, вызвав jbox_get_object() с указателями на ящики.Я попытался получить много атрибутов объектов, которые я получил, и все работает нормально.

Я не могу найти, где хранятся данные, которые я хочу получить и как они называются.

Буду признателен за помощь.

Спасибо.

Ответы [ 2 ]

1 голос
/ 23 сентября 2019

[coll] очень редко документировано, вы должны спросить об этом на форуме разработчиков Cycling74.Ниже то, что я делаю в [posit] после обхода патчера, чтобы найти ящик колла.hth / * j

#include “coll.h”

<snip>

t_object *o;
t_coll   *collob;
t_object *jb;
t_symbol *collname;

<snip>

o = jbox_get_object(jb);
collob = (t_coll *)o;
collname = (t_symbol *)collob->c_x->c_sym;

</snip>
0 голосов
/ 23 сентября 2019

Спасибо, пользователь12106422!Вот как я реализовал это в своей функции итератора, и она отлично работает.

#include "coll.h"

//in your iterator function .. 
long  patcher_iterator(<replace this with your external type> *x, t_object *b) {

    //check if object is a coll
    if(strncmp(object_classname( jbox_get_object(b) )->s_name, "coll",4) == 0){
        t_coll  *collobject;
        t_symbol *collname;

        collob = (t_coll *)jbox_get_object(b);
        collname = (t_symbol *)collobject->c_x->c_sym;
        post("--The name of the coll is (%s) ", collname->s_name);
    }
}

Я также хотел бы поделиться coll.h здесь для общего блага.

/* -------- coll.c -- the collection object --------------- */

#include "ext.h"
// #include "edit.h"
#include "ext_wind.h"
#include "ext_common.h"
#include "ext_strings.h"
#include "ext_critical.h"

#define C_EMBED 1

/* ddz 06/09/94:
    * fixed interspersed (entremele) use of next and prev messages
    * added assistance for third outlet
    * prototyped functions and removed voids
    * fixed truncating on sorts
*/

/* sde use to fill the read and write flags */
#define FILE_DIALOG 1   /* use dialogs to get file name */
#define FILE_NAMED 2    /* symbol specifies file name */

#define Index_Integer 1
#define Index_Symbol 2

typedef struct celem {  /* doubly linked list element */
    short e_size;
    short e_extra;
    long e_index;
    t_symbol *e_assoc;
    struct celem *e_next;
    struct celem *e_prev;
    t_atom e_data[1];       /* dummy */
} t_celem;

typedef struct xcoll {
    t_object c_ob;
    void *c_data;           // linklist
    //t_celem c_head;       /* head of list elements */
    t_celem *c_next;        /* element to be returned by "next" */
    t_celem *c_prev;        /* element to be returned by "prev" */
    void *c_out2;           /* next "end" signal outlet */
    char c_read,c_write;    /* flags for reading & writing */
    char c_freeing,c_saveme;
    char c_embed;           /* embed in owning patcher? */
    t_symbol *c_sym;        /* associated symbol? */
    struct ed *c_edit;      /* edit window */
    short c_refcount;       /* reference count */
    struct coll *c_refcoll; /* list of "colls" that reference this xcoll */
    /* sde filename, volume, and MAX type */
    t_symbol *c_fn;
    short c_vol;
    short c_bin;
    long  c_type;           /* type of the file that was read in */
    short c_modified;   
    long c_filetype;        /* for filetype message -- allowed types */
    long c_modcount;
} t_xcoll;


typedef struct coll {
    t_object c_ob;
    t_xcoll *c_x;
    t_symbol *c_sym;
    void *c_out2;
    /* sde third outlet bangs after reading data */
    void *c_out3;
    void *c_out4;
    struct coll *c_nextref; /* next in the list of colls that share this coll's xcoll */
    void *c_owner;
    long c_nosearch;
} t_coll;
...