javascript callback speed
Hi,
I'm wondering is there any way to change the speed of data output in a callback function in js/max?
My data is coming out too fast and I need to slow it down just a little bit, but make sure all data is kept.
It seems max doesnt allow setTimeout(), so I'm stuck with using Tasks. I've looked at Tasks but cant seem to get my head around them. Are there any examples anywhere that I could fit into a callback?
Cheers
N
The deferlow object ?
Deferlow doesnt work I'm afraid. This is for OSC communication, so deferlow doesnt allow me to slow this down enough. I need to slow it down, so it takes 1 ms or something like this, to get the data to flow through properly.
well the Task Object would work like this
function bang() {
post("banged \n");
var tsk = new Task(myCallback, this, "FooBarBaz");
tsk.schedule(500); // execute once in 500 ms.
}
function myCallback(arg) {
post("I was called \n");
post(arg + "\n");
};
myCallback.local = 1;
But it seems to be strange that your code is "too fast". I have the impression the timing problem might be somewhere else...
... because if you receive/create data faster than you send it you will sooner or later run out of memory...
Yes, youre right Jan the problem is somewhere else. Im sending messages over OSC to a controller that is dropping the messages, because theyre coming too fast. Its not possible to fix the controller, so Im having to hack Max to slow the data down.
Ive written another post on the issue in the hope I can find a way round it - https://cycling74.com/forums/change-object-detect-multiple-changes/