- From: Jussi Kalliokoski <jussi.kalliokoski@gmail.com>
- Date: Mon, 8 Oct 2012 22:33:28 +0300
- To: Chris Rogers <crogers@google.com>
- Cc: Patrick Borgeat <patrick.borgeat@gmail.com>, Joe Berkovitz <joe@noteflight.com>, Srikumar Karaikudi Subramanian <srikumarks@gmail.com>, "public-audio@w3.org Group" <public-audio@w3.org>
- Message-ID: <CAJhzemUS8X69D0Mh1VXO6LPz+ph_LDY1y2b057c=md-jibASXQ@mail.gmail.com>
On Mon, Oct 8, 2012 at 10:30 PM, Chris Rogers <crogers@google.com> wrote: > > > On Sat, Oct 6, 2012 at 1:09 AM, Patrick Borgeat <patrick.borgeat@gmail.com > > wrote: > >> I'm having a related problem at the moment with >> setValueCurveAtTime, having a hard time figuring out how to scale a >> normalized Float32Array (values from 0 to 1) to another range (say, for a >> frequency from 2000 to 3000). Off course this could easily done in >> JavaScript but I'd prefer to generate just one Array for each curve at >> startup and scale it in the API, since it already can scale it in time. >> >> Scaling a signal is pretty easy: Put the signal through through a Gain >> with value 500, patch it into the param, and set value to 2500 (it now >> should oscillate between 2000 and 3000). >> >> Since the GainNode doesn't produce a signal we would need to feed him a >> Unity signal, but all the possibilities I see in the API would require the >> developer to specify the lifetime of the unity signal (I think it would be >> more straightforward for a UnitySourceNode to be collected automatically). >> >> > I think Joe already mentioned this, but if an AudioBufferSourceNode is in > "loop" mode, then it's not necessary to manage it's lifetime, and it will > simply play forever until gc. Also, if an application often needs to deal > with these "unity sources", then it's pretty easy to just create a single > one, then share it among any nodes needing it. > > >> Easiest way for the setValueCurveAtTime would to have 2 additional >> parameters, a mul and an add (this is common in SuperCollider for example), >> with a formula like value * mul + add. As mul could default to 1 and add >> default to 0 you wouldn't need to set it if you don't need it. >> >> > Adding these optional parameters to setValueCurveAtTime() seems quite > useful. > > >> Mut maybe a more general Mul/Add scheme for AudioParams could be found, >> such as a mul/add parameter, which would be applied to any value change. >> Again, with defaults of 1 and 0 it >> >> > I was looking at the other AudioParam scheduling methods such as > setValueAtTime(), and it seems like it's already trivial to call them like: > > param.setValueAtTime(value * mul + add, time); > > It's useful for the setValueCurveAtTime() method, since the operation > needs to happen for all values in the curve, but for the other methods, it > seems easy to do with the existing API. > Yes, and for setValueCurveAtTime(), perhaps one can use the DSP API.
Received on Monday, 8 October 2012 19:33:55 UTC