Feb 5, 2011 at 12:27am
var noteoff = new Task(note_off,this);
No surprises there. So, before I embark on something ugly, I’m wondering what a nice, elegant way of doing this is. I’ve had the thought that I could create an array of Tasks, check to see if a task is busy, if it is, then try the next one in the array, and so on. This would probably work, but it seems a bit of a brute force method, and not very elegant.
Feb 5, 2011 at 10:30pm
I tend to stay away from built-in Tasks, just because they’ve proven troublesome when using multiple js’s in the same project in m4l. This is probably something you needn’t be wary of in plain-jane Max patches, though. Still, it might help.
I send a metro’s output into the js and set up a function inside the js like:
The ‘script’ variable is set up in global code on load like this:
Dunno if this helps you at all….I’ve gotten a lot of mileage out of it though, and this sort of method has been much more stable and maleable than the built in tasks functionality of the js object.
You probably already know this, but if you are expecting reasonably accurate timing from anything in js, make sure to set the immediate property of these functions to 1….otherwise, nothing but slop.
Feb 7, 2011 at 11:14pm
and somewhere in a function, after I schedule a note on, I can do this:
of course, everything falls apart if I run out of Tasks...:)
Feb 8, 2011 at 12:04am
I actually think you could accomplish this without js but it is hard to suggest how without knowing more details.(delay object and a trigger would be my go to)
Feb 8, 2011 at 4:48pm
I could accomplish it outside of js with makenote, but I really don’t want to go out of js. I like James’s approach – a sort of “crystal” for the timer :)
Feb 8, 2011 at 7:33pm
Thanks :) You know, what I used to do (before I discovered js Tasks were unstable in m4l) was to run a single Task which served the same function as the external metronome, and time everything from it…I also generally try to do everything in the js that I can. This all worked fine when only one js was running, but things became unstable with multiple js’s. You probably won’t have any issues (other than wonky js-style timing without immediate=1), it just makes the script less portable with Tasks embedded.
I’m curious how the Task function is built internally….the problem with my method is that you are calling a function @ every timing interval, which is bound to slow things down. But judging from the behavior I’ve observed with Tasks, I tend to think the same sort of thing is going on internally anyway when using the builtin methods.
You must be logged in to reply to this topic.