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

Re: oscillators and the Web Audio API

From: Jussi Kalliokoski <jussi.kalliokoski@gmail.com>
Date: Wed, 8 Feb 2012 22:24:52 +0200
Message-ID: <CAJhzemWJvvAErVPeThx8Tg+4mGXE35_T1EtooqSaF_rA=sXn1w@mail.gmail.com>
To: philburk@mobileer.com
Cc: public-audio@w3.org
On Wed, Feb 8, 2012 at 9:07 PM, Phil Burk <philburk@mobileer.com> wrote:

> Hello Joe,
>
>
> On 2/8/12 7:49 AM, Joe Berkovitz wrote:
>
>> As much as I like the idea of built in high quality oscillators, I am
>> concerned about scope creep.
>>
>
> I share your concern. One can go crazy adding lots of obscure modules. But
> over time it has become evident what modules can be considered core
> functionality. For signal generators that would be:
>
> * sine - pure tones
> * sinePM - phase modulated sine oscillator for "FM"
> * sawtooth - rich spectrum for subtractive synthesis, string sounds
> * square - woody sound for reeds
> * pulse - simple timbral modulation, square is just a 50:50 pulse
> * wavetable - for arbitrary or natural sounds
>

I think pulse wave can be ditched in favour of pulse width modulation for
all waveforms (quite simple actually, I'm doing it in audiolib.js, allows
for some really awesome sounds). Also, invert sawtooth is quite useful.

Another thing to consider is the waveshape that mistakenly has the same
name as pulse wave, it's basically the same as a normal pulse wave, except
that it's linear, and hence looks like a triangle wave. The exact algorithm
is something like a = p < 0.5 ? p < 0.25 ? p * 8.0 - 1.0 : 1.0 - (p - 0.25)
* 8 : -1, where a is amplitude (-1.0 - 1.0) and p is phase (0.0 - 1.0).
It's quite common in synthesizers designed for trance and its derivatives.
:)


>
> * white noise - flat spectrum, harsh sound
> * pink noise - softer, more pleasant sound
> * red noise - useful for random modulation
>
> I will review the WebAudioAPI to see if anything else is missing.
>
>
>  Is it possible to take a v1 wavetable-like approach using prefilled
>> buffers containing various looped waveforms, played at varying playback
>> rates. instead of algorthmic oscillators?
>>
>
> A single wavetable works well over a limited pitch range. It's fine for a
> keyboard playing notes at fixed pitches.  But for sound effects the
> frequency is often modulated over several octaves and may even go negative.
> You can get some serious aliasing from that.
>
> A wavetable might work if you start with a large wavetable for the bottom
> octave and then internally generate filtered wavetables with the same size
> for the higher octaves. You can then interpolate between wavetables based
> on frequency.  But it might be easier to just provide the basic oscillator
> types with DPW band limiting. The code is tricky but quite small.


Also, these days it's hardly even an optimization to use wavetables for
oscillators anymore.


>
>
> Phil Burk
>
>
>
Received on Wednesday, 8 February 2012 20:25:23 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 8 February 2012 20:25:25 GMT