Re: Oscillators with time-domain custom wave shape

(Should really move this thread to public-audio-dev, or stack-overflow)

We have an issue open on "mathematically correct oscillators" for this kind
of case (https://github.com/WebAudio/web-audio-api/issues/244).  Note that
1) oscillators are bandwidth-limited, so you can't do this from
OscillatorNode today, and 2) playbackRate being k-rate is probably going to
cause issues with using looping an audiobuffer to do this.

Honestly - use a scriptprocessor, for now.

On Mon, Mar 30, 2015 at 9:33 AM, Josh Nielsen <josh@joshontheweb.com> wrote:

> 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 18:00:53 UTC