Re: JavaScriptNode Tone Generation

Hi Ryan,

Thanks again for the example.  I really like it!

On Thu, May 12, 2011 at 9:48 PM, Ryan Berdeen <> wrote:

> Hi Chris,
> Glad you found the example useful. I tried to make it as terse and
> simple as possible, so I glossed over a few points.
> For the call
>    context.createJavaScriptNode(1024, 1, 1);
> I think the second argument should be 0, as there are no inputs. For
> the third argument, I'm not sure I understand you exactly. The intent
> here was to have a single output buffer and use only the first channel
> of that buffer. Have I got this right? The example differs from the
> spec, because it looks like in the current implementation the
> outputBuffer attribute of the event is just a buffer, rather than an
> array of numberOfOutputs buffers. Regardless, I think the example
> would be more clear if it filled both channels.

I'm sorry that I've created a little confusion in the way this is documented
to work in the specification.  I'm going to just change the specification to
the simple interpretation everyone has been assuming: 2nd argument is number
of channels of the input (can be zero channels for no input), 3rd argument
is number of channels for the output (can be zero for no output).  For now
in the current implementation, number of channels should be 0, 1, 2 (later
could be 5.1, etc.)

I don't think this will break anyone's code, just make the specification
match what people are using.

My original intention was to allow the JavaScriptAudioNode to have multiple
inputs and outputs. An AudioNode input or output can contain multiple
channels.  Think of it this way: when you plug headphones into a headphone
jack, the cable is actually carrying two channels (left and right).  But
there's just one plug and one cable that you plug-in.  Thus there's one
output with two channels.  So, given my original design it would have been
possible to create a JavaScriptAudio node with two outputs, for example with
the first output having two channels, and the second one being 5.1 (like an
HDMI cable)

I think if we keep it simple for the common use case which most people will
use, then we could extend the API later to allow adding more inputs or
outputs if necessary.

Give me a little while to implement this as I've described for the common
use case, but for those using it right now, it has one input and one output
and both are stereo.  Currently 2nd and 3rd arguments are ignored!


Received on Friday, 13 May 2011 20:58:46 UTC