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

Re: Oscillators with time-domain custom wave shape

From: Josh Nielsen <josh@joshontheweb.com>
Date: Tue, 31 Mar 2015 05:33:24 +1300
Message-ID: <CAMgQFxDLZ2cdWfaxExZ0Z3LaSUpE+hi1ebJodrgio7ENLbOnvQ@mail.gmail.com>
To: s p <sebpiq@gmail.com>
Cc: "public-audio@w3.org" <public-audio@w3.org>
What about using additive synthesis?  You can make a sawtooth by combining
multiple sine waves where you double the hz and half the amplitude
successively.

On Tue, Mar 31, 2015 at 3:10 AM, s p <sebpiq@gmail.com> wrote:

> Hi all!
>
> In the past days I've struggled to get an oscillator that would output an
> exact sawtooth. The use case for me is to modulate an AudioParam and the
> approximative sawtooth provided by the OscillatorNode is not precise
> enough. For example, I wanted to loop through a sound file, using
> WaveShaperNode, and drive the read position in that file with a sawtooth,
> but since the decrease after the top of the sawtooth is not instant, you
> can hear a very loud artifact when you reach the end of the file (peak of
> the saw), a bit like fast rewind.
>
> There is 2 solutions I thought about to get this working (I wont mention
> the 3rd one, it's too ugly).
>
> First using the OscillatorNode with a custom wave shape, but I didn't even
> try because I know I will never get something clean enough, since the wave
> shape is specified in the frequency domain.
>
> Second, using BufferSourceNode, and I was sure it would work. I created a
> buffer with my wave shape, which I loop, and I control the frequency
> through directly modulating playbackRate. Turns out this doesn't work on
> Chrome and is glitchy on Firefox. http://jsfiddle.net/gh144L2u/
>
> I think it would be great to have a way to do this, in order to have a
> fully predictable wave shape if needed. Is this an intended use-case for
> BufferSourceNode? In that case I believe the spec is not precise enough
> about how playbackRate should be handled. Paul Adenot told me that in
> Firefox the BufferSourceNode is not optimized for fast playbackRate
> changes, and also playbackRate is a k-rate param which might be alright ...
> Is this rather a use-case for OscillatorNode? This would require a new
> param... etc ...
>
> Any thoughts on this?
>
> --
>
> *S├ębastien Piquemal*
>
>  -----* @sebpiq*
>  ----- http://github.com/sebpiq
>  ----- http://funktion.fm
>



-- 
Thanks,
Josh Nielsen
@joshontheweb <http://twitter.com/joshontheweb>
joshontheweb.com
Received on Monday, 30 March 2015 16:34:13 UTC

This archive was generated by hypermail 2.3.1 : Monday, 30 March 2015 16:34:15 UTC