Hey
i have a threading problem with a javascript object i wrote (its for looping inside Clips and stuff)
when i defer a message before sending it to the object it works fine
but if i let midi through/delay the message the patch just freezes and ableton crashes
i really dont know where the problem is, looked at similar patches, they were sending high priority messages to the live.object too
for easier reading i cut out only the neccessary code (i even cut it down to the basics, ran it, and voila crash again...)
no other functions are executed on an event, only this you see here
//initialises Clip, isnt high priority
function initClip (clipNo) {
if (clipNo>=0) {
clipPath = "this_device canonical_parent clip_slots "+clipNo+" clip";
clipObj = new LiveAPI (this.patcher, sample_callback, clipPath);
globalObj = new LiveAPI (this.patcher, sample_callback, "live_set");
}
else {
clipObj=-1;
globalObj=-1;
}
}
//the main function which runs first in the test, is high priority (abbr mainthread==1 in the future)
function setLoopLength (length_float) {
if (length_float!=0) {
loopLength=loopDirection*length_float;
loopInActive=0;
if (isLooping==0) {
fixPoint=quantize(getFixPos());
varPoint=fixPoint+loopLength;
}
else {
varPoint=fixPoint+loopLength;
}
triggerLoopOn();
}
else {
triggerLoopOff();
}
}
//mainthread==1
function getFixPos () {
if (loopInActive==0)
return getClipPos();
else
return fixPoint;
}
//mainthreaded==1
function getClipPos () {
return clipObj.get("playing_position");
}
//mainthreade==1
function quantize (input) {
return ( ( Math.floor( (input*100) / onQuantization ) * onQuantization + onQuantization) / 100 ) ;
}
//mainthread==1
function triggerLoopOn () {
if ((loopLength==0) || (loopLength<0 && loopDirection>0) || (loopLength>0 && loopDirection<0))
triggerLoopOff();
else {
isLooping=1;
loopInActive=0;
start(varPoint,fixPoint);
outlet(0,Math.abs(loopLength));
}
}
//m==1
function start (lStart, lEnd) {
if (clipObj!=-1) {
clipObj.set("looping",1);
clipObj.set("loop_start",lStart);
clipObj.set("loop_end",lEnd);
}
}
//m==1
function triggerLoopOff () {
loopInActive=0;
post("off\n");
off();
outlet(0,0);
}
//m==1
function off () {
if (clipObj!=-1) {
clipObj.set("looping",0);
}
}
i am really desperate, because if i manage to solve this problem, i hope i ll get a better response from the LiveAPI in order to do some time critical events.
Any help would be much appreciated!!! ( i attached the whole code if you want to harm yourself :) )
EDIT: i thought that the audio (which is high priority) coming into the plugin must have conflicted my high priority schedules, so i put it on a midi track --- the same result, live crashes..

In your live script calls do you not need to provide a callback function?
clipObj = new LiveAPI (this.patcher, sample_callback, clipPath)
here sample_callback points to nothing?