zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit c99be90be0a3f855366f4a5b132e3b239e4ae992
parent 7729d999239766f058c730418f4517db724a0cef
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Mon, 22 Aug 2011 11:09:52 -0400

Synth: fixing fft related bugs

- convert2sine's angles were off by 90 degrees,
  fixed by determining angles based upon cosine reference
- ifft produced ringing at nyquist, fixed by nulling that channel

Diffstat:
Msrc/DSP/FFTwrapper.cpp | 6+++++-
Msrc/Synth/OscilGen.cpp | 5+++--
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/DSP/FFTwrapper.cpp b/src/DSP/FFTwrapper.cpp @@ -29,7 +29,7 @@ FFTwrapper::FFTwrapper(int fftsize_) { fftsize = fftsize_; time = new fftw_real[fftsize]; - fft = new fftw_complex[fftsize]; + fft = new fftw_complex[fftsize + 1]; planfftw = fftw_plan_dft_r2c_1d(fftsize, time, fft, @@ -67,6 +67,10 @@ void FFTwrapper::freqs2smps(const fft_t *freqs, float *smps) //Load data memcpy( (void*)fft, (const void*)freqs, fftsize*sizeof(double)); + //clear unused freq channel + fft[fftsize/2][0] = 0.0; + fft[fftsize/2][1] = 0.0; + //IDFT fftw_execute(planfftw_inv); diff --git a/src/Synth/OscilGen.cpp b/src/Synth/OscilGen.cpp @@ -52,10 +52,11 @@ inline float abs(const fft_t *freqs, off_t x) return abs(freqs[x]); } -//return angle aka phase +//return angle aka phase from a sine (not cosine wave) inline float arg(const fft_t *freqs, off_t x) { - return arg(freqs[x]); + const fft_t tmp(freqs[x].imag(), freqs[x].real()); + return arg(tmp); } /**