Re: Comments on AudioWorklet examples

Hi Hongchan,

It's great that we're on the same page now as far as understanding how you
intended things to work in the examples to date.

But in your new example, I find I'm confused about how its AWN class could
be instantiated in the main scope, since you are now defining it only
within an AWGlobalScope, and (implicitly) moving AudioWorkletNode out of
the main scope.

But an AWN seems fine (and even desirable) to have in the main global
scope. Why can it not be an ordinary class, whose superclass (AWN) takes
care of the business of coordinating with the AWP? If you define the AWN
subclass inside AWGlobalScope, then you've got to instantiate it in some
special way.

I felt the earlier AW design accomplished this perfectly, in which the
string name served to match up the AWN with its corresponding AWP class,
and had to be provided to the AWN constructor. I was never seeking to
change that aspect of things.

So either of the following feel simpler to me, and are very similar to what
you  had already proposed:

1. With two distinct classes:

/* Main scope (window) */

class FooNode extends AudioWorkletNode {
  get parameterDescriptors () {}
  constructor (context, options) {
    super(context, 'foo', options);
  },
  onmessage () {}
};

var foo = new FooNode(context, {});

/* AudioWorkletGlobalScope */
registerAudioWorkletProcessor('foo',
  class extends AudioWorkletProcessor {
    process (inputs, outputs, parameters) {},
    onmessage () {}
  }
);


2. With a Processor class alone, using AWN raw and unsubclassed:

/* Main scope (window) */

var foo = new AudioWorkletNode(context, 'foo');
foo.someParam.value = 1;

/* AudioWorkletGlobalScope */
registerAudioWorkletProcessor('foo',
  class extends AudioWorkletProcessor {
    process (inputs, outputs, parameters) {},
    onmessage () {}
  }
);

Received on Thursday, 2 June 2016 00:44:50 UTC