Mixing Min and Max SDK
Hi,
I am just getting my feet wet in developing externals. It is my understanding that min SDK seems to be limited in exposing the implementation of the underlying MAX SDK. I am liking the ease with which we can create an external object in C++ and bind the messages for appropriate callback. At some places, I do struggle to implement functionality in MAX SDK using the min framework - (I have not been able to figure out how to respond to the inletinfo message to mark an inlet as cold and I have been using direct calls to max::jgraphics object to get finer control on working with text layouts and justifications.)
My question to the forum is - do we have a recommended way of using the underlying MAX SDK? I am fairly conversant with programming, but new to C / C++. How do we get C++ objects to pass sucessfully into the C functions. I figured t_object* can be got from maxobj(). I am now trying to figure out how to pass a function pointer and register for callback using the class_addmethod function in a C++ class.
tx
with the 8.2 update to the max-sdk (and corresponding updates to min), externals that mix max-sdk C function calls with min C++ should easier to develop, since both now utilize the same base headers and libs. There is not much in the way of recommended practice other than, be careful with namespaces. You can see an example of this in my reply here.
Hello Rob,
Thanks. I had seen this thread a few weeks back and it really helped me getting to use Dictionaries and JGraphics from the MAX sdk. This method however does not seem to work for everything.
Currently I am studying the ITM module of MAX and trying to create a simple metro that will send a bang on every beat. Min Timers seem to not be tempo aware and don't seem to have any way of performing quantization.
Any pointers / examples? MAX crashes when I use the class_time_addattr to define a time attribute. MIN has an object called time_value. I am not sure how to use it.
OK. So, I am now using a combination of the min timer and max ITM information. I am defining a min timer object (example found in documentation (http://cycling74.github.io/min-devkit/guide/initialization).
timer<> midiClock{ this,
MIN_FUNCTION{
//This is just the definition of the timer.
//and the link to the timer call back function
midiTick();
return{};
}
};
And in the midiTick function, I figure out what the global tempo is and schedule the next call to tick appropriately.
//Get the Tempo and schedule the next tick
max::t_itm* globalITM = (max::t_itm*)max::itm_getglobal();
double tempo = max::object_attr_getfloat(globalITM, max::gensym("tempo"));
double tickDelay = 60000 / (480 * tempo);
midiClock.delay(tickDelay);
I have used 480 above so the delay is equal to one midi-tick based on the tempo. But we can change that as needed. I am not sure if this is an elegant solution as I am fetching the tempo on every tick. I however did not find a way in which I could be notified using min-devkit if the user changed the tempo.