Correct JS syntax for M4L API Clip class "replace_selected_notes" series?

Feb 22, 2010 at 7:21am

Correct JS syntax for M4L API Clip class "replace_selected_notes" series?

Hi! Could anybody show me the proper JS syntax used to call the M4L API Clip class “replace_selected_notes” series?

call replace_selected notes
call notes 2
call note 60 0.0 0.5 100 0
call note 62 0.6 0.5 100 0
call done

I’m a tad confused due to there not being a “note” property for the
Clip class.

Any help would be greatly appreciated!!

W.

#48668
Feb 23, 2010 at 12:46am

watchClip = new LiveAPI(this.patcher, null, “live_set tracks 0 clip_slots 0 clip”);
watchClip.call(“replace_selected_notes”);
watchClip.call(“notes”, 1);
watchClip.call(“note 60 0.0 0.5 100 0″); //see note below
watchClip.call(“done”);

the point at which i say see note is the sticky part. i hand over an array instead of a string, but i am being lazy and secretive.

MAKE SURE you keep a decimal point in those 2 numbers that have decimal points.

#174922
Feb 23, 2010 at 4:29am

that’s what I thought, yet I am getting 2 errors;

1.Clip has no attribute “note 60 0.0 0.5 100 0″
2.wrong note count

any idea as to why?

W.

#174923
Feb 23, 2010 at 3:20pm

yes.

it can’t be a string. you must pass an array. (i was not sure of this, but now i am. i went with an array because i already had the note as an array, so it was just happy coincidence for me.)

and the parts that they say have to be doubles HAVE to be doubles. they MUST have decimal points.

it just doesn’t count any note message it doesn’t think is correct.

#174924
Feb 23, 2010 at 3:22pm

noteArray = ['note', 60, 0.0, 0.5, 100, 0];

watchClip = new LiveAPI(this.patcher, null, “live_set tracks 0 clip_slots 0 clip”);
watchClip.call(“replace_selected_notes”);
watchClip.call(“notes”, 1);
watchClip.call(noteArray);
watchClip.call(“done”);

#174925
Feb 23, 2010 at 3:24pm

eventually, i will post my whole solution in the form of the patch i am working on, but i hope this helped you.

#174926
Feb 24, 2010 at 2:09am

Yeah absolutely.Thanks. I tried passing an array minus the note portion. Thanks for the clarification!!

W

#174927
Feb 24, 2010 at 7:17am

When passing a float value of 0.0 as a parameter in the call, it is converted into an integer and then the compiler throws an “Invalid Syntax” Error due to the appropriate positions in the array not being floats. This only happens when 0.0 is used, 0.5 for instance, is recognized as a float!

The 0.0 in the call message comes up in the Max window as 0 !

Could this be a bug?
Has anybody else experienced this?

#174928
Feb 24, 2010 at 1:11pm

it isn’t quite a bug. it IS frustrating. javascript is ‘dynamic,’ so it interprets what a var is supposed to be and can usually figure it out correctly. but not in this case. i think the reason is that js is handing the number back to a less dynamically typed language.

and it would happen any time one of those numbers i s a whole number. any time. so annoying.

in any case, make 2 number objects from the 2 indexes and use toFixed. and then you are fine.

#174929
Mar 7, 2010 at 1:55am

http://docs.monome.org/doku.php?id=app:gs.clipstep

and now i can stop being secretive!

#174930

You must be logged in to reply to this topic.