Page 1 of 2

Undocumented functions

Posted: 21 Jan 2012 16:38
by xanadu
It would be nice if we where able to create and destroy controllers from within MaxMSP. As is appears, there are some undocumented functions for the Lemur.

The function destroyobject(obj); deletes an object from the project layout. Also, the function createobject(p, q, r, s); appears to be syntactically right. But I can't get this to create a new object on the Lemur/iPad.

I wrote a little script to test this:

Code: Select all

oscout(0, '/Test_Undocumented_Functions', 'Start');

decl p = findobject('Text2');
oscout(0, '/before_destroyobject', {p});
destroyobject(p);
p = findobject('Text2');
oscout(0, '/after_destroyobject', {p});

decl obj = createobject('Fader', 'FaderX', {0, 0, 60, 200}, RGB(70, 70, 70));
oscout(0, '/Created_object', {obj});
decl q = findobject('FaderX');
oscout(0, '/Found_object', {q});

oscout(0, '/Test_Undocumented_Functions', 'Ready');
The output is:

Code: Select all

LEMUR: /Test_Undocumented_Functions Start
LEMUR: /before_destroyobject 8828540
LEMUR: /after_destroyobject 0
LEMUR: /Created_object 0
LEMUR: /Found_object 0
LEMUR: /Test_Undocumented_Functions Ready
The deletion works, but the creation of a new control fails. I suppose this function needs other arguments.

Does anyone know how to use createobject?
Are there other undocumented functions known to lemur users on this forum?

Cheers,

Xanadu

Re: Undocumented functions

Posted: 23 Jan 2012 09:01
by axel_liine
Hi,
They are undocumented because they could very well crash at any time, and disappear in any update.
Anyway if you want to try them out, the arguments are as follow :
createobject('Fader', 'FaderX', {0,0,60,200}, parent)

where parent is the path to the parent object, or zero to create it at the root of current interface.

For instance : createobject('Fader', 'FaderX', {0,0,60,200}, Container1.Container2)

Re: Undocumented functions

Posted: 23 Jan 2012 09:42
by lABl
don't know if they are listed in the new manual, but some that multi-line script and variables undestands are:

frame
pi
setattribute(objetc, 'color',HSV())

cheers,

Re: Undocumented functions

Posted: 23 Jan 2012 17:46
by xanadu
Thanks Axel, it works! I just could not figure out the parent parameter. I know that I'm on my own when using undocumented functions.

This opens the possibility to create an empty model and set the layout on the fly. Another use of this would be to create a layout using MaxMSP code. Then save it on the iPad, synchronize it to iTunes and finish the layout and scripts in the Lemur Editor. Using code for creating repeating objects can be used for accurate placement of objects and take away the tediousness.

My best guess is that createobject uses the same code that the Lemur uses when importing a .JZML file, which is rock-steady.

When the parameters change I have to find out about the new functionality and only change it in the empty model. But if this happens that means that you guys at Liine are taking the development of the Lemur code to new horizons. That would be a good thing!

Cheers,

Willem aka Xanadu.

Re: Undocumented functions

Posted: 27 Jan 2012 14:50
by j5k
Createobject does sounds very useful. Especially for something like a live clip launcher. You could dynamically create a bunch of buttons and faders for instance to match the number of tracks you have live.

Re: Undocumented functions

Posted: 30 Jan 2012 13:01
by mbncp
As I make often changes to my setup I would love to create object by coding, but a create object by itself isn't really useful, at least it would be nice to attach an on expression script and some variables. Are those functions available ?

Re: Undocumented functions

Posted: 30 Jan 2012 14:12
by axel_liine
mbncp wrote:As I make often changes to my setup I would love to create object by coding, but a create object by itself isn't really useful, at least it would be nice to attach an on expression script and some variables. Are those functions available ?
No, there are no such functions at the time.

Re: Undocumented functions

Posted: 30 Jan 2012 23:25
by xanadu
mbncp wrote
As I make often changes to my setup I would love to create object by coding, but a create object by itself isn't really useful, at least it would be nice to attach an on expression script and some variables. Are those functions available ?
If you're using an environment like Max then that environment can be used to supply the dynamic settings you need in real time, at the expense of some cpu.

I have not tested adding variables or scripts, but I assume Axel is right, so I suppose we're out of luck here.

Fortunately the whole physics thing and all of the behariour attributes of Lemur are available for dynamic scripting. The functions Attributes and Attributes2 wil show the attributes that I know of that can gotten or set for each object type.

Attributes:

Code: Select all

decl arg = OSC_ARGS[0];

if (arg == 'Breakpoint') 
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
									   'coordinates', 'editable', 'free', 'grid', 'grid_steps', 'label', 'nbr', 'physic', 'zoom',
									   'edit', 'attraction', 'friction', 'speed', 'rest', 'holdX', 'holdY',
									   'x',ý'y'});
else if (arg == 'Dummy')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color', 'transparent',
                                       'label', 'tabbar'});
else if (arg == 'CustomButton')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'behavior', 'capture', 'label_off', 'label_on', 'outline',
									   'Mode', 'mode',
									   'x'});
else if (arg == 'Fader')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'capture', 'cursor', 'grid', 'grid_steps', 'label', 'value',
									   'physic', 'precision', 'zoom', 
									   'attraction', 'friction', 'speed',
									   'x', 'y'});
else if (arg == 'Knob')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
									   'cursor', 'grid', 'grid_steps', 'label', 'value', 'physic', 'precision',
					  			       'type', 'unit', 'mode',
									   'attraction', 'friction', 'speed',
									   'x'});
else if (arg == 'Leds')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'colors', 'row', 'column', 'multicolor', 'label',
									   'transparent'});
else if (arg == 'Menu')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'items', 'scale', 'transparent',
									   'selection'});
else if (arg == 'Monitor')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'label', 'precision', 'transparent', 'unit', 'value'});
else if (arg == 'MultiBall')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'ball_enable', 'capture', 'colors', 'grid', 'grid_steps', 'ephemere',
									   'label', 'multicolor', 'multilabel', 'nbr', 'physic',
								       'polyphony', 'pressure', 'zoom',
									   'attraction', 'friction', 'speed', 'attack', 'decay', 'sustain', 'release', 'hold', 'holdX', 'holdY',
									   'x', 'y', 'z'});
else if (arg == 'MultiSlider')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'bipolar', 'gradient', 'grid', 'grid_steps', 'horizontal',
									   'label', 'multicolor', 'nbr', 'physic',
									   'tension', 'friction', 'height',
									   'x'});
else Attributes2(OSC_ARGS);
Attributes2

Code: Select all

decl arg = OSC_ARGS[0];

if (arg == 'Pads')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
									   'capture', 'colors', 'column', 'label', 'labels',
									   'attack', 'decay', 'sustain', 'release', 'hold',
									   'row', 'multicolor', 'multilabel',
									   'x'});
else if (arg == 'Range')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'capture', 'grid', 'grid_steps', 'horizontal',
									   'label', 'physic',
									   'tension', 'friction', 'min_height', 'max_height', 'drag',
									   'x'});
else if (arg == 'RingArea')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'capture', 'label',
									   'attraction', 'friction', 'speed', 'attractor_x', 'attractor_y',
									   'x', 'y'});
else if (arg == 'SignalScope')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'label', 'mode','transparent',
									    'x', 'y', 'timebase'});
else if (arg == 'SurfaceLCD')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'diplay', 'target','transparent'});
else if (arg == 'Switches')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'capture', 'colors', 'row', 'column', 'label', 'labels',
									   'multicolor', 'multilabel', 'paint', 'radio',
									   'x'});
else if (arg == 'Text')
		oscout(0, '/Attributes', {arg, 'name', 'rect', 'color',
                                       'content', 'transparent'});
else oscout(0, '/Attributes', {arg, '<not an object type>'});
My function Value to get / set a value is in early alpha. It should always return the current value of an attribute and it should set the attribute if a value is optionally supplied. At the moment this function looks at this:

Code: Select all

decl obj = findobject(OSC_ARGS[0]);
decl attr = OSC_ARGS[1];

decl val;
if (attr == 'rect')
		val = getobjectrect(obj);
else
		val = getattribute(obj, attr);

if (val != 0)
		oscout(0, '/Value', {OSC_ARGS[0], attr, val});
else
		oscout(0, '/Value', {OSC_ARGS[0], attr, getexpression(obj, OSC_ARGS[1])});

if (sizeof(OSC_ARGS) > 2)
{
		oscout(0, 'Value set', OSC_ARGS[2]);
		setexpression(obj, attr, OSC_ARGS[2]);
}
Cheers,

Willem aka Xanadu

Re: Undocumented functions

Posted: 31 Jan 2012 01:10
by Macciza
Hi
There is also a getattributelist(object) function that you may want to use to generate your data
Apart from that, thanks, it is interesting to see the different ways people program stuff
Cheers
MM

Re: Undocumented functions

Posted: 31 Jan 2012 12:17
by bxsj
Talking about undocumented functions. What about the Gesture object? It's availabe in the Jazz Editor but not in the Lemur Editor.
I did a little test and voila, it's possible to create a Gesture object in the Jazz Editor, save it and the use in the Lemur Editro.
... and it works ... will this be available in a future update? is there any more documenation/information about this object?

Btw. there are existing templates and libs for the Lemur that use the Gesture object. E.g.the pinch value could be used to control zoom attributes.

Cheers,
BxSj