Re: oscillators and the Web Audio API

Hello Jussi,

On 2/8/12 12:24 PM, Jussi Kalliokoski wrote:
> 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).

I'm not sure I understand the semantics. What is "pulse width 
modulation" if there is no pulse? Is it some form of phase modulation?

Phase modulation on all waveforms could be handy. Note that in 
synthesizers that do "FM", eg. Yamaha DX7, are typically doing phase 
modulation. It is simpler and sounds as good.

 > Also, invert sawtooth is quite useful.

Yes. It is really handy when used as an LFO. You can get an inverted 
sawtooth either by using a negative frequency or a negative gain.

> 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).

I'm trying to figure it out. Is this an equivalent?

a = (p < 0.5)
     ? ( (p < 0.25) ? ((p * 8.0) - 1.0) : (1.0 - ((p - 0.25) * 8)) )
     : -1,

  p         a
0.00     -1.0
0.25     +1.0
0.5      -1.0
0.75     -1.0

So half of it looks like a triangle wave and half is -1.0.  Cool. I'll 
have to try that.

BTW, I forgot and left triangle out of my list.

Phil Burk

Received on Wednesday, 8 February 2012 21:20:39 UTC