Re: AudioParam constructor

Yeah, that being the main case and also that of abstraction layers, such as
if someone wrote, for instance something called a MixerNode, that uses gain
nodes to take multiple inputs and such, maybe AUXes or whatever. Also, now
that I think of it, it would be pretty handy if AudioParam was an instance
of EventTarget, so you could add listener hooks to such things as onChange
or onAutomationEnd (I don't know about this one), don't you think? It might
complicate the thing a bit, but at the benefit of hackability, and that's
always a good thing if you want to attract developers. Also, now that I'm
asking, can you dereference AudioParams? For example, make two separate
AudioGainNodes and make them share the AudioParam for .gain? As here:

var gain1 = ctx.createGainNode();
var gain2 = ctx.createGainNode();
gain1.gain = gain2.gain;
gain1.gain.value = 0.5;

And that would change the value of both? I could've just tried, but quite
honestly I'm pretty ill and tired, so I'll just ask. :)

I think that would be a useful feature to have, if it's not that way. After
all, it only follows the same logic as do most things in javascript, for
example being able to do Array.prototype.slice.call(arguments, 1); sorta
things.

I realize these things have many complicating effects, implementation-wise,
but I'm just throwing things at you and the rest of us, to see whether you
think they're good ideas or not.

Another thing about AudioParam on my mind may be completely absurd, the
fever talking and impossible to implement (I'm not sure if V8 for instance
allows that, without changing the toString), but what if the primitive of
AudioParam was the value of it? That way one could use normal number values
in stead of AudioParams, if one pleases, and yet not making horrible
performance sacrifices in checking whether it's an audio param or not on
every sample, for example:

sample = sample * myGainlikeEffect.gain;

versus

sample = sample * (isNaN(myGainlikeEffect.gain) ?
myGainlikeEffect.gain.value : myGainlikeEffect.gain.value);

This would be similar to behaviour of Date(), as +new Date does the same
trick as (new Date).getTime().

I'm sorry not having brought up these things earlier, but such things come
to mind only when you have a working prototype to play with.

Jussi

On Mon, Jun 6, 2011 at 9:33 PM, Chris Rogers <crogers@google.com> wrote:

> Hmmm, that's an interesting idea.  I assume you're talking in the context
> of a JavaScriptAudioNode?  In this case, I can see where it might be useful
> to add your own AudioParams to the JavaScriptAudioNode, then they could be
> automated (envelope, fade-in/out, LFO, etc.) just like any other parameter.
>  If you wanted to get sample-accurate parameter data then we'd have to add
> another method (something like requesting to fill a Float32Array for a given
> time range) from AudioParam, so custom DSP code can do useful things with
> it...
>
> Chris
>
>
> On Mon, Jun 6, 2011 at 10:26 AM, Jussi Kalliokoski <
> jussi.kalliokoski@gmail.com> wrote:
>
>> Hello Chris, others,
>>
>> Is there a way to create an AudioParam from your code, I've tried several
>> things in the fashion of
>>
>> new (new webkitAudioContext).createGainNode().gain.constructor
>>
>> but I keep getting errors, like Illegal constructor. Is it possible to do?
>> Would be pretty handy when crafting your own effects.
>>
>> Jussi
>>
>
>

Received on Monday, 6 June 2011 20:48:49 UTC