[LAD] Converting single-cycle wave to harmonic spectrum

Fons Adriaensen fons at linuxaudio.org
Mon May 10 15:51:38 CEST 2021


On Mon, May 10, 2021 at 03:17:12PM +0200, Jeanette C. wrote:

> There are numerous audiofiles around containing one single cycle wave to
> be used with multiple wavetable synthesizers, both in hard and software.
> I can only assume that these are matched to the number of samples they
> contain. Some of them CERTAINLY proclaimed this fact,

OK. In that case the actual frequency will be R / N where R is the sample
rate and N the length in samples. This is very probably not exactly an
musical pitch in the equally tempered scale, but that doesn't matter
since the wavetable synth will have to resample it anyway.

So in this case, all you need is an FFT with a size equal to the lenght
of your single cycle sample. There is no faster method.

I just checked, FFTW3 can do any size.

Normally you'd just use the real-to-complex fft. For prime lengths, this
may become slower than normal (N^2 complexity instead of N log N). If this
matters (it probably won't), you could use the complex-to-complex fft with
the imaginary part set to zero, this will be faster (always N log N).

In all cases, the N / 2 + 1 first elements of the output will correspond
to the harmonics, so you just the square root of the power of each.

Ciao,

-- 
FA
 


More information about the Linux-audio-dev mailing list