sfinfo~ inside an object

klaus filip's icon

i would like to get the info of any soundfile just like sfinfo~ does,

and handle these data inside my object.

i know, i can create a new object in my external like this

t_object *newInfo = object_new(CLASS_BOX, gensym("sfinfo~"), gensym(""));

x->info = jbox_get_object(newInfo);

but then how to "listen" to its outlets ?

or is there another way to get the header of a soundfile.

i need channels, samplerate and length

thanks for any insights

klaus

Jan M's icon

I only started looking at Max object dev very recently - and only via the Min-DevKit. A t_object class in the Min-DevKit has a functions named try_call returning the result of a message as atoms.

/// Try to call a named message.  
/// @param	name	The name of the message to attempt to call.
/// @param	args	Any args you wish to pass to the message call. 
/// @return	If the message doesn't exist an empty set of atoms.
///		Otherwise the results of the message.

atoms try_call(const std::string& name, const atoms& args = {});

Maybe by looking into the implementation you can find out what's the c code behind it.

Joe Steccato's icon

i also asked about this on the Max Discord, where 11olsen mentioned an undocumented(?) "jsoundfile" CLASS_NOBOX which I found some implementation of in RNBO~ compiled code

pdelges's icon

There is a sndfile_info function in Max' API.

Have a look at ext_sndfile.h