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

Re: Oscillators with time-domain custom wave shape

From: <hughr2005@gmail.com>
Date: Mon, 30 Mar 2015 10:42:07 -0700 (PDT)
Message-Id: <1427737327315.dd955e26@Nodemailer>
To: "Josh Nielsen" <josh@joshontheweb.com>
Cc: "s p" <sebpiq@gmail.com>, public-audio@w3.org
To get the perfect saw necessary for using it for iteration, you’d have to add an infinite number of sine waves. It’s the same problem @sebpiq was having with his first solution attempt, specifying the waveform in the frequency domain. To do this properly you really need to be able to specify the wave in the time domain.

Sent from Mailbox

On Mon, Mar 30, 2015 at 5:33 PM, Josh Nielsen <josh@joshontheweb.com>

> 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 21:20:01 UTC

This archive was generated by hypermail 2.3.1 : Monday, 30 March 2015 21:20:02 UTC