W3C home > Mailing lists > Public > public-audio@w3.org > October to December 2012

Re: AudioBuffer mutability

From: Srikumar Karaikudi Subramanian <srikumarks@gmail.com>
Date: Tue, 30 Oct 2012 21:41:30 +0530
Cc: Chris Rogers <crogers@google.com>, Joseph Berkovitz <joe@noteflight.com>, Ehsan Akhgari <ehsan.akhgari@gmail.com>, public-audio@w3.org
Message-Id: <F8E71CCC-E955-4B83-BC18-E8478CA1F7A8@gmail.com>
To: robert@ocallahan.org
> An AudioBuffer would always be usable with any number of AudioBufferSourceNodes. No-one is suggesting changing that.

Although that's true, the getChannelData() API suggests a symmetry of buffer access between the JS side and the audio system. If the buffer were to be read+write locked upon binding to a source node, we'd end up with a reference to a typed array on the JS side that can neither be written to nor read from ... which is a very unusual state to leave a common JS object in. To isolate the two sides, the AudioBuffer API has to change to something like this -

var f32 = new Float32Array([...]);
var buf = context.createBuffer(numChannels, numFrames, sampleRate);
buf.writeChannelData(chan, f32, offset);
buf.readChannelData(chan, f32, offset);

If a buffer is "in use", then the write can be specd to complete after a render quantum and the read can be specd to block during the current render quantum (or perhaps take a callback argument for async read). The "f32" then remains exclusive to JS land.

-Kumar

On 30 Oct, 2012, at 3:07 PM, "Robert O'Callahan" <robert@ocallahan.org> wrote:

> On Tue, Oct 30, 2012 at 9:26 PM, Srikumar Karaikudi Subramanian <srikumarks@gmail.com> wrote:
>> At a small cost, you can keep a copy of the buffer on the main thread to satisfy these requirements.
> 
> If a buffer were to be read locked once assigned to a source node, it would mean we cannot assign the same buffer to multiple source nodes to trigger multiple voices using the same underlying sample (like with granular synthesis) ...
> 
> An AudioBuffer would always be usable with any number of AudioBufferSourceNodes. No-one is suggesting changing that.
> 
> Rob
> -- 
> Jesus called them together and said, “You know that the rulers of the Gentiles lord it over them, and their high officials exercise authority over them. Not so with you. Instead, whoever wants to become great among you must be your servant, and whoever wants to be first must be your slave — just as the Son of Man did not come to be served, but to serve, and to give his life as a ransom for many.” [Matthew 20:25-28]
> 
Received on Tuesday, 30 October 2012 16:12:16 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:50:03 UTC