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

Re: MIDI Tracks and Sequences

From: James Ingram <j.ingram@netcologne.de>
Date: Fri, 14 Sep 2012 11:07:19 +0200
Message-ID: <5052F3C7.1090505@netcologne.de>
To: public-audio@w3.org, Chris Wilson <cwilso@google.com>, Jussi Kalliokoski <jussi.kalliokoski@gmail.com>
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
Received on Friday, 14 September 2012 09:07:55 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 14 September 2012 09:08:00 GMT