zynaddsubfx

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

commit 450a0231d421d05ea7a61ef815bf20d181e69a60
parent f314f32d8e666460b3f83d0c3fd3514382500640
Author: paulnasca <paulnasca>
Date:   Sun, 28 Nov 2004 17:06:40 +0000

*** empty log message ***

Diffstat:
Msrc/DSP/FFTwrapper.C | 10++++++----
Msrc/Synth/OscilGen.C | 10+++++-----
2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/DSP/FFTwrapper.C b/src/DSP/FFTwrapper.C @@ -58,33 +58,35 @@ void FFTwrapper::smps2freqs(REALTYPE *smps,FFTFREQS freqs){ rfftw_one(planfftw,tmpfftdata1,tmpfftdata2); for (int i=0;i<fftsize/2;i++) { freqs.c[i]=tmpfftdata2[i]; - freqs.s[i]=tmpfftdata2[fftsize-1-i]; + if (i!=0) freqs.s[i]=tmpfftdata2[fftsize-i]; }; #else for (int i=0;i<fftsize;i++) tmpfftdata1[i]=smps[i]; fftw_execute(planfftw); for (int i=0;i<fftsize/2;i++) { freqs.c[i]=tmpfftdata1[i]; - freqs.s[i]=tmpfftdata1[fftsize-1-i]; + if (i!=0) freqs.s[i]=tmpfftdata1[fftsize-i]; }; #endif + tmpfftdata2[fftsize/2]=0.0; }; /* * do the Inverse Fast Fourier Transform */ void FFTwrapper::freqs2smps(FFTFREQS freqs,REALTYPE *smps){ + tmpfftdata2[fftsize/2]=0.0; #ifdef FFTW_VERSION_2 for (int i=0;i<fftsize/2;i++) { tmpfftdata1[i]=freqs.c[i]; - tmpfftdata1[fftsize-1-i]=freqs.s[i]; + if (i!=0) tmpfftdata1[fftsize-i]=freqs.s[i]; }; rfftw_one(planfftw_inv,tmpfftdata1,tmpfftdata2); for (int i=0;i<fftsize;i++) smps[i]=tmpfftdata2[i]; #else for (int i=0;i<fftsize/2;i++) { tmpfftdata2[i]=freqs.c[i]; - tmpfftdata2[fftsize-1-i]=freqs.s[i]; + if (i!=0) tmpfftdata2[fftsize-i]=freqs.s[i]; }; fftw_execute(planfftw_inv); for (int i=0;i<fftsize;i++) smps[i]=tmpfftdata2[i]; diff --git a/src/Synth/OscilGen.C b/src/Synth/OscilGen.C @@ -410,7 +410,7 @@ void OscilGen::oscilfilter(){ max=sqrt(max); if (max<1e-10) max=1.0; REALTYPE imax=1.0/max; - for (int i=1;i<OSCIL_SIZE;i++) { + for (int i=1;i<OSCIL_SIZE/2;i++) { oscilFFTfreqs.s[i]*=imax; oscilFFTfreqs.c[i]*=imax; }; @@ -566,7 +566,7 @@ void OscilGen::spectrumadjust(){ }; REALTYPE max=0.0; for (int i=0;i<OSCIL_SIZE/2;i++){ - REALTYPE tmp=pow(oscilFFTfreqs.s[i],2)+pow(oscilFFTfreqs.s[i],2.0); + REALTYPE tmp=pow(oscilFFTfreqs.c[i],2)+pow(oscilFFTfreqs.s[i],2.0); if (max<tmp) max=tmp; }; max=sqrt(max); @@ -574,7 +574,7 @@ void OscilGen::spectrumadjust(){ for (int i=0;i<OSCIL_SIZE/2;i++){ REALTYPE mag=sqrt(pow(oscilFFTfreqs.s[i],2)+pow(oscilFFTfreqs.c[i],2.0))/max; - REALTYPE phase=atan2(oscilFFTfreqs.c[i],oscilFFTfreqs.s[i]); + REALTYPE phase=atan2(oscilFFTfreqs.s[i],oscilFFTfreqs.c[i]); switch (Psatype){ case 1: mag=pow(mag,par); @@ -671,8 +671,8 @@ void OscilGen::prepare(){ }; if (Pcurrentbasefunc==0) {//the sine case for (i=0;i<MAX_AD_HARMONICS;i++){ - oscilFFTfreqs.s[i+1]=-hmag[i]*sin(hphase[i]*(i+1))/2.0; - oscilFFTfreqs.c[i+1]=hmag[i]*cos(hphase[i]*(i+1))/2.0; + oscilFFTfreqs.c[i+1]=-hmag[i]*sin(hphase[i]*(i+1))/2.0; + oscilFFTfreqs.s[i+1]=hmag[i]*cos(hphase[i]*(i+1))/2.0; }; } else { for (j=0;j<MAX_AD_HARMONICS;j++){