W3C home > Mailing lists > Public > public-audio@w3.org > July to September 2012

Re: Wavetable example?

From: Raymond Toy <rtoy@google.com>
Date: Mon, 23 Jul 2012 10:46:47 -0700
Message-ID: <CAE3TgXFbwUo8YBQwiDd5=tQ95Y5dPBq8sgdki_QrORCEg264PQ@mail.gmail.com>
To: Matt Diamond <mdiamond@jhu.edu>
Cc: Marcus Geelnard <mage@opera.com>, Peter van der Noord <peterdunord@gmail.com>, Ray Bellis <ray@bellis.me.uk>, public-audio@w3.org
On Mon, Jul 23, 2012 at 10:26 AM, Matt Diamond <mdiamond@jhu.edu> wrote:

> Hmm... does this mean that a wavetable could be used as an IFFT? Or more
> specifically, given a frequency snapshot of an audio signal, could a
> WaveTable be constructed that generates a signal representing that
> frequency content?
>
>
I guess it could be.  But note that the table length is limited to 4096.
 Also, the first element of the table corresponds to the fundamental
frequency, which is set by the frequency attribute of the oscillator node.
 I guess for an IFFT, you'd set that to 1.

I didn't try this, but it seems easy enough to do an experiment.

Ray

Matt
>
>
> On Mon, Jul 23, 2012 at 10:06 AM, Raymond Toy <rtoy@google.com> wrote:
>
>>
>>
>> On Mon, Jul 23, 2012 at 12:34 AM, Marcus Geelnard <mage@opera.com> wrote:
>>
>>> Den 2012-07-22 20:17:06 skrev Ray Bellis <ray@bellis.me.uk>:
>>>
>>>
>>>  On 22/07/2012 13:58, Peter van der Noord wrote:
>>>>
>>>>> Hmmm, my math knowledge isnt of the level that i have an immediate idea
>>>>> about how that would work :)
>>>>>
>>>>
>>>> OK, here's a more concrete example.
>>>>
>>>> A square wave is defined as a series of the *odd* harmonics where the
>>>> contribution of each harmonic is inversely proportional to its harmonic
>>>> number.
>>>>
>>>> So the second, fourth, etc harmonics are all *zero*.
>>>>
>>>> The third harmonic is 1/3 the amplitude of the fundamental, and the
>>>> fifth is 1/5, etc.
>>>>
>>>> See http://en.wikipedia.org/wiki/**Square_wave<http://en.wikipedia.org/wiki/Square_wave>
>>>>
>>>> So the input "cos" table would just look like:
>>>>
>>>> [ 0, 1, 0, 1/3, 0, 1/5, 0, 1/7, 0, 1/9, ... ]
>>>>
>>>> The sin table for a square wave doesn't need any values because the
>>>> harmonics are all in phase.  So just use all zeroes.
>>>>
>>>>
>>> That's right. Another way of thinking of it is that the WaveTable is
>>> essentially the Fourier transform of a time domain periodic signal. So, if
>>> you have a single period of a time domain signal that you want to use as a
>>> WaveTable, take the FFT of that signal and use the real portion as the cos
>>> table, and the imaginary portion as the sin table (haven't tried it, but it
>>> should work).
>>
>>
>> Yes, this is exactly how it's supposed to work.  If it doesn't, it's a
>> bug, so please let us know. :-)
>>
>> Ray
>>
>>
>
Received on Monday, 23 July 2012 17:47:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 July 2012 17:47:17 GMT