W3C home > Mailing lists > Public > public-audio@w3.org > January to March 2012

Re: setValueFunctionAtTime for AudioParam

From: Alistair MacDonald <al@signedon.com>
Date: Tue, 27 Mar 2012 14:58:38 -0400
Message-ID: <CAJX8r2nj=m71v_v7nCtFiK1haaLoGBYZo6-XsAzxp6YAfFphow@mail.gmail.com>
To: Patrick Borgeat <patrick@borgeat.de>
Cc: public-audio@w3.org
This is somewhat different to what I thought you were saying.

It seems like you are updating a buffer in your callback, but at the same
time you are calling "setValue..." -- thus setting a value to be
interpolated to the audio engine.

I think that could be where I got confused. Because if we set a "value" at
a time in the future, the buffer would already be being changed, then it
seems incidental to be changing the buffer in a callback.

If you are changing the buffer continuously, I believe the using the
existing JavaScript node could be better suited to your needs in this
use-case. But please correct me if I am missing something key here.





On Tue, Mar 27, 2012 at 2:25 PM, Patrick Borgeat <patrick@borgeat.de> wrote:

> B, fire the same callback many times (maybe even with a user specified
> granularity: small granularity/large buffers cache more data)
>
> As I see it case A could easily be achieved by setValueCurveAtTime and a
> auxiliary function that renders the callback function into an Float Array.
>
> Hiere a quick callback function I had in mind which would introduce
> difficulties with the current API (it actually would be possible but would
> require the user to regularly "push" values to the AudioParam). Off course
> it's a bit naive (and bad names for args and method names) but I hope
> you're getting my intentions (also code not tested ).
>
> var lfo = function(frequency, min, max) {
> var phase = 0;
> var delta = 1 / SAMPLERATE * 2 * Math.PI;
>  return function (buffer, time) {
> for(var i = 0; i < buffer.length; i++) {
> buffer[i] = (Math.sin(phase) + 1.0) * (max - min) + min;
>  phase += delta;
> if(phase >= (Math.PI * 2) {
> phase -= (Math.PI * 2);
> }
> }
> }
> }
>
> filter.frequency.setValueFunction(lfo(1, 500, 2000));
>
>
> Now the filter (a BiquadFilterNode) has a LFO running at 1Hz attached to
> its frequency, ranging from 500Hz to 2000Hz.
>
>
> Patrick
>
>
> Am 27.03.2012 um 19:26 schrieb Alistair MacDonald:
>
> Hi Patrick,
>
> I have been thinking about your use-case over the last day or so and have
> a further question.
>
> Did you want to:
>
>     A) Fire a callback, once, at an exact time?
>
>     B) Fire the same callback many times?
>
>
> Al
>
>
>


-- 
Alistair MacDonald
SignedOn, Inc - W3C Audio WG
Boston, MA, (707) 701-3730
al@signedon.com - http://signedon.com
Received on Tuesday, 27 March 2012 18:59:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:59:11 GMT