send am ITM transport a tempo or location from the SDK?

Iain Duncan's icon

Hi devs, I notice in the docs there are no itm functions for setting tempo or location (though there are, oddly enough, for time signature!). Has anyone managed this other ways than sending a message to a transport object? ie is there a message I could send from C to an itm object to achieve this?

Iain Duncan's icon

I've figured out tempo, this works:

    double tempo = 120;
    t_itm *itm = itm_getglobal();
    itm_reference(itm);
    t_atom a;
    atom_setfloat(&a, tempo);
    // send the message to the itm object
    t_max_err err = NULL; 
    err = object_method_typed(itm, gensym("tempo"), 1, &a, NULL);
    if(err){
        object_error((t_object *)x, "s4m: error sending tempo message");
    }
    itm_dereference(itm);
For position, in the Max gui I can send a transport a list message of bars, beats, units and it will seek to it. However, when I try to send a list message to it from the SDK, I get an error message saying the itm object doesn't understand list, which is odd. So this does not work:

    double ticks = (double) s7_real(arg_1);
    t_itm *itm = itm_getglobal();
    itm_reference(itm);
    // sending a max list message to the itm object, which does not work for some reason
    long bars, beats;
    double units;
    itm_tickstobarbeatunits(itm, ticks, &bars, &beats, &units, TIME_FLAGS_LOCATION);
    post("  - bars: %i beats: %i units: %5.2f", bars, beats, units); 
    t_atom atoms[3];
    atom_setlong( &atoms[0], bars);
    atom_setlong( &atoms[1], beats);
    atom_setfloat( &atoms[2], units);
    // send the message to the itm object
    t_max_err err = NULL; 
    err = object_method_typed(itm, gensym("list"), 3, atoms, NULL);