mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-19 12:16:16 -04:00
ZynAddSubFX: eliminate global data in favour of per-synth data
OscilGen::tmpsmps and OscilGen::outoscilFFTfreqs were static member variables initialized once in LocalZynAddSubFx class. However having this data global is not a good idea because it gets modified by each synth (possibly in parallel), causing heavy distortion under various circumstances. Now that this data is allocated and used per-synth everything works fine.
This commit is contained in:
@@ -60,9 +60,6 @@ LocalZynAddSubFx::LocalZynAddSubFx()
|
||||
{
|
||||
denormalkillbuf[i] = (RND-0.5)*1e-16;
|
||||
}
|
||||
|
||||
OscilGen::tmpsmps = new REALTYPE[OSCIL_SIZE];
|
||||
newFFTFREQS( &OscilGen::outoscilFFTfreqs, OSCIL_SIZE/2 );
|
||||
}
|
||||
++s_instanceCount;
|
||||
|
||||
@@ -80,8 +77,6 @@ LocalZynAddSubFx::~LocalZynAddSubFx()
|
||||
if( --s_instanceCount == 0 )
|
||||
{
|
||||
delete[] denormalkillbuf;
|
||||
delete[] OscilGen::tmpsmps;
|
||||
deleteFFTFREQS( &OscilGen::outoscilFFTfreqs );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,12 @@
|
||||
#include "OscilGen.h"
|
||||
#include "../Effects/Distorsion.h"
|
||||
|
||||
REALTYPE *OscilGen::tmpsmps;//this array stores some termporary data and it has SOUND_BUFFER_SIZE elements
|
||||
FFTFREQS OscilGen::outoscilFFTfreqs;
|
||||
|
||||
|
||||
OscilGen::OscilGen(FFTwrapper *fft_,Resonance *res_):Presets(){
|
||||
setpresettype("Poscilgen");
|
||||
fft=fft_;
|
||||
res=res_;
|
||||
tmpsmps = new REALTYPE[OSCIL_SIZE];
|
||||
newFFTFREQS(&outoscilFFTfreqs, OSCIL_SIZE/2);
|
||||
newFFTFREQS(&oscilFFTfreqs,OSCIL_SIZE/2);
|
||||
newFFTFREQS(&basefuncFFTfreqs,OSCIL_SIZE/2);
|
||||
|
||||
@@ -45,6 +43,8 @@ OscilGen::OscilGen(FFTwrapper *fft_,Resonance *res_):Presets(){
|
||||
};
|
||||
|
||||
OscilGen::~OscilGen(){
|
||||
delete[] tmpsmps;
|
||||
deleteFFTFREQS(&outoscilFFTfreqs);
|
||||
deleteFFTFREQS(&basefuncFFTfreqs);
|
||||
deleteFFTFREQS(&oscilFFTfreqs);
|
||||
};
|
||||
|
||||
@@ -107,11 +107,11 @@ class OscilGen:public Presets{
|
||||
|
||||
bool ADvsPAD;//if it is used by ADsynth or by PADsynth
|
||||
|
||||
static REALTYPE *tmpsmps;//this array stores some termporary data and it has SOUND_BUFFER_SIZE elements
|
||||
static FFTFREQS outoscilFFTfreqs;
|
||||
|
||||
private:
|
||||
|
||||
REALTYPE *tmpsmps;//this array stores some termporary data and it has SOUND_BUFFER_SIZE elements
|
||||
FFTFREQS outoscilFFTfreqs;
|
||||
|
||||
REALTYPE hmag[MAX_AD_HARMONICS],hphase[MAX_AD_HARMONICS];//the magnituides and the phases of the sine/nonsine harmonics
|
||||
// private:
|
||||
FFTwrapper *fft;
|
||||
|
||||
Reference in New Issue
Block a user