<HTML><HEAD></HEAD>
<BODY>
<DIV dir=ltr id=idOWAReplyText93336>
<DIV dir=ltr><FONT size=2>As an aside to Chris McCormick's comments, I wonder if it might also be useful/possible/appropriate (or not) to provide access to media data in the way that the ActionScript computeSpectrum function does: </FONT></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr><A href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/SoundMixer.html#computeSpectrum%28%29" target=_blank><FONT size=2>http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/SoundMixer.html#computeSpectrum%28%29</FONT></A></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>Sample visualization using Canvas with computeSpectrum: </FONT><A href="http://www2.nihilogic.dk/labs/canvas_music_visualization/" target=_blank><FONT size=2>http://www2.nihilogic.dk/labs/canvas_music_visualization/</FONT></A></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>Sam Dutton</FONT></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>----------------------------------------------------------------------<BR><BR>Message: 1<BR>Date: Sun, 9 Aug 2009 11:16:01 +1000<BR>From: Silvia Pfeiffer <silviapfeiffer1@gmail.com><BR>Subject: Re: [whatwg] Codecs for <audio> and <video><BR>To: Chris McCormick <chris@mccormick.cx><BR>Cc: whatwg@lists.whatwg.org<BR>Message-ID:<BR><2c0e02830908081816v74711d64ya72c8cc11550baa4@mail.gmail.com><BR>Content-Type: text/plain; charset=ISO-8859-1<BR><BR>On Sun, Aug 9, 2009 at 3:15 AM, Chris McCormick<chris@mccormick.cx> wrote:<BR>> On Wed, Jul 08, 2009 at 09:24:42AM -0700, Charles Pritchard wrote:<BR>>> There are two use cases that I think are important: a codec<BR>>> implementation (let's use Vorbis),<BR>>> and an accessibility implementation, working with a <canvas> element.<BR>><BR>> Here are a few more use-cases that many people would consider just as<BR>> important:<BR>><BR>> * Browser based music software and synthesis toys.<BR>> * New types of 'algorithmic' music like that pioneered by Brian Eno.<BR>> * Browser based games which want to use procedural audio instead of<BR>> pre-rendered sound effects.<BR>><BR>> I'd like to reiterate the previously expressed sentiment that only implementing<BR>> pre-rendered audio playback is like having a browser that only supports static<BR>> images loaded from the server instead of animations and <canvas> tags.<BR>><BR>> What is really needed is a DSP vector processor which runs outside of ECMA<BR>> script, but with a good API so that the ECMAscripts can talk to it directly.<BR>> Examples of reference software, mostly open source, which do this type of thing<BR>> follow:<BR>><BR>> * Csound<BR>> * Supercollider<BR>> * Pure Data<BR>> * Nyquist<BR>> * Chuck<BR>> * Steinberg VSTs<BR>><BR>> I am going to use the terms "signal vector", "audio buffer", and "array"<BR>> interchangeably below.<BR>><BR>> Four major types of synthesis would be useful, but they are pretty much<BR>> isomorphic, so any one of them could be implemented as a base-line:<BR>><BR>> * Wavetable (implement vector write/read/lookup operators)<BR>> * FM & AM (implement vector + and * operators)<BR>> * Subtractive (implement unit delay from which you can build filters)<BR>> * Frequency domain (implemnt FFT and back again)<BR>><BR>> Of these, I feel that wavetable synthesis should be the first type of synthesis<BR>> to be implemented, since most of the code for manipulating audio buffers is<BR>> already going to be in the browsers and exposing those buffers shouldn't be<BR>> hugely difficult. Basically what this would take is ensuring some things about<BR>> the audio tag:<BR>><BR>> * Supports playback of arbitrarily small buffers.<BR>> * Seamlessly loops those small buffers.<BR>> * Allows read/write access to those buffers from ECMAscript.<BR>><BR>> Given the above, the other types of synthesis are possible, albeit slowly. For<BR>> example, FM & AM synthesis are possible by adding adding/multiplying vectors of<BR>> sine data together into a currently looping audio buffer. Subtractive synthesis<BR>> is possible by adding delayed versions of the data in the buffer to itself.<BR>> Frequency domain synthesis is possible by analysing the data in the buffer with<BR>> FFT (and reverse FFT) and writing back new data. I see this API as working as<BR>> previously posted, by Charles Prichard, but with the following extra<BR>> possibility:<BR>><BR>> <audio id='mybuffer'><BR>> buffer = document.getElementById("mybuffer");<BR>> // here myfunc is a function which will change<BR>> // the audio buffer each time the buffer loops<BR>> buffer.loopCallback = myfunc;<BR>> buffer.loop = True;<BR>> buffer.play();<BR>><BR>> Of course, the ECMA script is probably going to be too slow in the short term,<BR>> so moving forward it would be great if there was a library/API which can do the<BR>> following vector operations in the background at a speed faster than doing them<BR>> directly, element by element inside ECMAscript (a bit like Python's Numeric<BR>> module). All inputs and outputs are signal vectors/audio tag buffers:<BR>><BR>> * + - add two signal vectors (2 input, 1 output)<BR>> * * - multiply two signal vectors (2 input, 1 output)<BR>> * z - delay a signal vector with customisable sample length (2 input, 1 output)<BR>> * read - do a table lookup (1 input, 1 output)<BR>> * write - do a table write (2 input, 1 output)<BR>> * copy - memcpy a signal vector (1 input, 1 output)<BR>> * fft do a fast fourier transform - (1 input, 2 output)<BR>> * rfft do a reverse fast fourier transform - (2 inputs, 1 output)<BR>><BR>> It would be so great if it was possible to unify the above into an API that<BR>> looked and worked something like this:<BR>><BR>> <audio id='mybuffer'><BR>><BR>> outbuffer = document.getElementById("mybuffer");<BR>><BR>> b = new AudioBuffer(64)<BR>> for (x=0; x<64; x++)<BR>> ? ? ? ?b[x] = Math.sin(x / 64 * Math.PI)a;<BR>><BR>> // inside the loopCallback do a vector multiplication of the data in our buffer<BR>> // with a sine wave we created earlier.<BR>> outbuffer.multiply(b);<BR>><BR><BR>Why don't you just implement an example in javascript to show off what<BR>you're talking about and make a use case for having it implemented<BR>inside the browsers?<BR><BR>Cheers,<BR>Silvia,<BR><BR></FONT></DIV></DIV><br/><font face="Times New Roman" size="3"><a href="http://www.bbc.co.uk">http://www.bbc.co.uk</a><br/>This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.<br/>If you have received it in error, please delete it from your system.<br/>Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.<br/>Please note that the BBC monitors e-mails sent or received.<br/>Further communication will signify your consent to this.</font></BODY></HTML>