# Wavetable and Nyquist: which size do I need?

I was reading this tutorial by the master earlevel, while trying to build some sort of wavetable.

He says First, let’s back up and figure out how long our tables need to be. Recalling that we need to sample a signal at greater than twice the highest frequency component, that means that for 368 harmonics, we need at least 368 x 2 + 1 samples, or a table length of at least 737 samples., refering to a 40hz (lowest wavetable frequency) and the following harmonics (up to 14720 hz).

Not really sure about those 737 samples keeping the sampling theorem by Nyquist. Should be 40 * 368 * 2 + 1 samples needed? That's the real "highest frequency component" of the signal. Why 368 * 2 + 1?

Not really sure why I just need a 737 samples to express a signal that reach ~15khz.

• If you want a fundamental at 40 Hz, you need one complete sine/cosine at 40Hz to be covered by the table. This table could be played back-to-back at 40 times/second in order to produce a continous 40Hz sinoid waveform. As sines are boring in the long run, you might want to add harmonics. The more samples in the table (still repeated at 40 times/s), the more harmonics you can add. This translates into a higher samplerate. 737x40=29480 samples/second, sufficient for a tone of ~15kHz? Mar 16, 2021 at 19:54

The wavetable is ignorant or agnostic about the playback rate and the sample rate in Hz. What the wavetable knows about is how many points or samples define the waveform, $$N$$. All it knows is the amplitude and phase of every harmonic (which are two numbers for each harmonic), and with a little bit of nuance regarding the DC component and, if the number of wavetable samples is even, the Nyquist component.

There is no phase property of the DC component, just a bipolar amplitude, which is fully described by one real number.

Because of aliasing, the Nyquist component must be a cosine component with no sine component to it at all.

So if $$N$$ is odd, you can fully define the DC component and both the amplitude and phase of $$\frac{N-1}{2}$$ harmonics, all below Nyquist.

If $$N$$ is even, you can fully define the DC component, the amplitude and phase of $$\frac{N}{2}-1$$ harmonics below Nyquist, and only the bipolar amplitude of the harmonic at Nyquist.

In all cases, $$N$$ real numbets fully define the wavetable and the DFT maps these $$N$$ numbers to the harmonic amplitude and phase data which are also fully defined by $$N$$ real numbers.

The fundamental frequency is fixed at $$40Hz$$, that means you will sample a period of 1/40 second.

The Nyquist frequency says that you must sample your signal twice every period for any relevant frequency.

If you take $$737$$ samples, you have 736 periods (the first sample is at time zero). If you take these samples at a constant rate in a period of $$1/40$$ second, it means that the sampling period is $$1/40/736=1/1/29440$$ second (29440 samples per second), and the corresponding nyquist frequency is $$(29440/s)/2 = 14720Hz$$

• I really don't get it :) Let me iterate in another way. How many samples do I need for sampling a signal of 22050hz? 44100 right? (as the minimun sample rate in any daw, for example). Not sure why I just need 737 samples here for sampling a signal of 14720hz :O It doesn't make sense... Mar 15, 2021 at 16:29
• I mean: 44100 : 22050 = 29440 : 14720, not 44100 : 22050 = 29440 : 736 :O Mar 15, 2021 at 16:47
• Notice that he is talking about number of samples in a period of 1/40 second, not samples per second.
– Bob
Mar 15, 2021 at 18:20
• I see. But in any case, he sample a signal of near 15khz into a table with 2048 samples :O Can't understand how this is sufficient... Mar 15, 2021 at 18:28
• The number of samples is independent of the sampling frequency. You could have 10 samples of a signal of 20kHz at sample rate of 100kHz, that would correspond to 0.1ms, there is nothing wrong with this, but in this case you would be unable to detect low frequencies.
– Bob
Mar 15, 2021 at 18:37