W3C home > Mailing lists > Public > public-audio@w3.org > July to September 2012

Re: MIDI Tracks and Sequences

From: Joseph Berkovitz <joe@noteflight.com>
Date: Fri, 14 Sep 2012 10:27:34 -0400
Cc: public-audio@w3.org, Chris Wilson <cwilso@google.com>, Jussi Kalliokoski <jussi.kalliokoski@gmail.com>
Message-Id: <73B25E57-DB2C-4F12-801F-1171571AD2DA@noteflight.com>
To: James Ingram <j.ingram@netcologne.de>
James,

I do see that the closure scope of the setInterval() callback will grow over time -- not exactly recursion, but not desirable. However this seems avoidable if you use setInterval() to periodically fire a single callback rather than making a new setInterval() call each time, inside the callback. Also, if you can avoid referencing variables in the enclosing scope I don't think the stack will grow in the same way; you should be able to keep the full sequencer state in a single object that sticks around, rather than on the stack.

I am also working on MIDI-related sequencing but like Chris W, I would much prefer to keep these responsibilities outside the API, in ordinary JavaScript. I see too many opportunities for baking inflexible behavior into the API without realizing it.

…Joe

On Sep 14, 2012, at 5:07 AM, James Ingram <j.ingram@netcologne.de> wrote:

> Hi Chris, Jussi, all,
> 
> There is, after all,  a problem with my latest test [1]: Its fine for fairly small sequences, but it does not scale well.
> 
> The problem is that the sendMIDISequence() function is recursive. And it has to be that way because of the way setInterval() works. The stack is growing during the performance, and the likelihood of garbage collections (or even a crash) is increasing all the time. What happens if I want to play a 5 hour piece at a conservative 20 recursions per second?
> 
> My instinct says that the player should really be executing on a background worker thread, and using an ordinary sleep() function instead of setInterval().
> 
> But Javascript hasn't got an ordinary sleep() function, and I don't think you should give it one. Exposing a sleep() function would probably cause the whole world to seize up. :-)
> 
> So I still think the best solution would be to define Track and Sequence objects, and put the thread handling behind the API.
> The Track and Sequence objects would be quite independent of any file format. Populating them would be done by Javascript programmers (or libraries), using functions in the Track and Sequence interfaces.
> 
> best,
> James
> 
> [1] http://james-ingram.de/tests/JazzMIDIBridge/ji-known-sequence5.html
> 
> -- 
> www.james-ingram-act-two.de
> 
> 
> 

... .  .    .       Joe

Joe Berkovitz
President

Noteflight LLC
Boston, Mass.
phone: +1 978 314 6271
www.noteflight.com
Received on Friday, 14 September 2012 14:28:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 14 September 2012 14:28:11 GMT