获取 Max C 中的 coll 对象的名称 API

Get the name of a coll object in Max C API

我正在编写外部 Max MSP。

我在 Max C API 文档中迷失了几个小时,无法找到从 Max C [=32] 获取 coll 对象名称的方法=].

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

如果对象是| coll foo |,foo就是我要得到的符号

我能够遍历修补程序并获取指向所有框的指针,然后通过使用指向框的指针调用 jbox_get_object() 来获取指向对象的指针。我尝试获取我得到的对象的许多属性,一切正常。

我似乎找不到我想要获取的数据存储在哪里以及它叫什么。

非常感谢您的帮助。

谢谢。

[coll] 的文档很少,您应该在 Cycling74 开发论坛上提问。下面是我在 [posit] 中遍历 patcher 找到一个 coll 的盒子后所做的。 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>

谢谢用户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;