コード例 #1
0
ファイル: recmonitor.c プロジェクト: radarsat1/mapperRec
int recmonitor_start()
{
    mon = mapper_monitor_new(0, 0);
    if (mon) {
        db = mapper_monitor_get_db(mon);
        mapper_db_add_device_callback(db, device_callback, 0);
        mapper_db_add_signal_callback(db, signal_callback, 0);
        return 0;
    }
    return 1;
}
コード例 #2
0
ファイル: testmonitor.c プロジェクト: EQ4/libmapper
/*! Creation of a local dummy device. */
int setup_monitor()
{
    mon = mapper_monitor_new(0, SUB_DEVICE_ALL);
    if (!mon)
        goto error;
    printf("Monitor created.\n");

    db = mapper_monitor_get_db(mon);

    return 0;

  error:
    return 1;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: malloch/qtmapper
int setup_qtmapper(  ) {

    qtmapper = mapper_monitor_new();

    if ( !qtmapper ) {

        return 1;

    }

    printf( "qtmapper created\n" );

    return 0;

}
コード例 #4
0
ファイル: AgentAutoConnect.c プロジェクト: sofian/influence
struct _agentInfo *agentInit()
{
    obs[0] = obs[1] = 0;
    id = 0;

    struct _agentInfo *info = &agentInfo;
    memset(info, 0, sizeof(struct _agentInfo));

    info->influence_device_name = strdup("/influence.1");
    info->xagora_device_name = strdup("/XAgora_receiver.1");

    info->admin = mapper_admin_new(0, 0, 0);

    // add device
    info->dev = mdev_new("agent", 9000 + id, info->admin);
    while (!mdev_ready(info->dev)) {
        mdev_poll(info->dev, 100);
    }
    printf("ordinal: %d\n", mdev_ordinal(info->dev));
    fflush(stdout);

    // add monitor and monitor callbacks
    info->mon = mapper_monitor_new(info->admin, 0);
    info->db  = mapper_monitor_get_db(info->mon);
    mapper_db_add_device_callback(info->db, dev_db_callback, info);
    mapper_db_add_link_callback(info->db, link_db_callback, info);

    // add signals
    float mn=-1, mx=1;
    mdev_add_input(info->dev, "observation", 2, 'f', "norm", &mn, &mx,
                   signal_handler, 0);
    int imn=0, imx=WIDTH;
    info->sig_pos = mdev_add_output(info->dev, "position", 2, 'i', 0, &imn, &imx);
    info->sig_gain = mdev_add_output(info->dev, "gain", 1, 'f',
                               "normalized", &mn, &mx);
    mx = 0.9;
    info->sig_fade = mdev_add_output(info->dev, "fade", 1, 'f', "normalized", &mn, &mx);
    mn = -1.5;
    mx = 1.5;
    info->sig_spin = mdev_add_output(info->dev, "spin", 1, 'f', "radians", &mn, &mx);
    mn = -3.1415926;
    mx = 3.1315926;
    info->sig_dir = mdev_add_output(info->dev, "direction", 1, 'f', "radians", &mn, &mx);
    mn = -1;
    info->sig_flow = mdev_add_output(info->dev, "flow", 1, 'f', "noramlized", &mn, &mx);

    return info;
}
コード例 #5
0
ファイル: testlinear.c プロジェクト: davidhernon/libmapper-1
int setup_connection()
{
    mval src_min, src_max, dest_min, dest_max;
    src_min.f = 0.;
    src_max.f = 1.;
    dest_min.f = -10.;
    dest_max.f = 10.;

    mapper_monitor mon = mapper_monitor_new(source->admin, 0);

    char src_name[1024], dest_name[1024];
    mapper_monitor_link(mon, mdev_name(source),
                        mdev_name(destination), 0, 0);

    msig_full_name(sendsig, src_name, 1024);
    msig_full_name(recvsig, dest_name, 1024);

    mapper_connection_range_t range;
    range.src_min = &src_min;
    range.src_max = &src_max;
    range.dest_min = &dest_min;
    range.dest_max = &dest_max;
    range.known = CONNECTION_RANGE_KNOWN;

    mapper_db_connection_t props;
    props.range = range;
    props.src_length = 1;
    props.dest_length = 1;
    props.src_type = 'f';
    props.dest_type = 'f';
    props.mode = MO_LINEAR;

    mapper_monitor_connect(mon, src_name, dest_name, &props,
                           CONNECTION_RANGE_KNOWN | CONNECTION_MODE);

    // poll devices for a bit to allow time for connection
    int i = 0;
    while (i++ < 10) {
        mdev_poll(destination, 10);
        mdev_poll(source, 10);
    }

    mapper_monitor_free(mon);

    return 0;
}
コード例 #6
0
ファイル: testselect.c プロジェクト: EQ4/libmapper
int setup_connection()
{
    int count = 0;

    mapper_monitor mon = mapper_monitor_new(source->admin, 0);
    if (!mon)
        goto error;

    char src_name[1024], dest_name[1024];
    mapper_monitor_link(mon, mdev_name(source),
                        mdev_name(destination), 0, 0);

    while (!done && !source->routers) {
        if (count++ > 50)
            goto error;
        mdev_poll(source, 10);
        mdev_poll(destination, 10);
    }

    msig_full_name(sendsig, src_name, 1024);
    msig_full_name(recvsig, dest_name, 1024);
    mapper_monitor_connect(mon, src_name, dest_name, 0, 0);

    // wait until connection has been established
    while (!done && !source->routers->num_connections) {
        if (count++ > 50)
            goto error;
        mdev_poll(source, 10);
        mdev_poll(destination, 10);
    }
    eprintf("Connection established.\n");

    mapper_monitor_free(mon);

    return 0;

  error:
    return 1;
}