diff --git a/src/effects/Biquad.h b/src/effects/Biquad.h index 0f6ebf235..788bb4a4e 100644 --- a/src/effects/Biquad.h +++ b/src/effects/Biquad.h @@ -1,10 +1,5 @@ #ifndef __BIQUAD_H__ #define __BIQUAD_H__ - -#if 0 -//initialisations not supported in MSVC 2013. -//Gives error C2905 -// Do not make conditional on compiler. typedef struct { float* pfIn {}; float* pfOut {}; @@ -15,22 +10,6 @@ typedef struct { float fPrevOut {}; float fPrevPrevOut {}; } BiquadStruct; -#else -// WARNING: This structure may need initialisation. -typedef struct { - float* pfIn; - float* pfOut; - float fNumerCoeffs [3]; // B0 B1 B2 - float fDenomCoeffs [2]; // A1 A2 - float fPrevIn; - float fPrevPrevIn; - float fPrevOut; - float fPrevPrevOut; -} BiquadStruct; -#endif - - - void Biquad_Process (BiquadStruct* pBQ, int iNumSamples); void ComplexDiv (float fNumerR, float fNumerI, float fDenomR, float fDenomI, float* pfQuotientR, float* pfQuotientI); bool BilinTransform (float fSX, float fSY, float* pfZX, float* pfZY); diff --git a/src/effects/Reverb.cpp b/src/effects/Reverb.cpp index 8d290e09e..ebbd850a4 100644 --- a/src/effects/Reverb.cpp +++ b/src/effects/Reverb.cpp @@ -75,25 +75,12 @@ FactoryPresets[] = { XO("Cathedral"), { 90, 16, 90, 50, 100, 0, 0, -20, 100, false } }, }; -#if 0 -//initialisations not supported in MSVC 2013. -//Gives error C2905 -// Do not make conditional on compiler. -struct Reverb_priv_t -{ - reverb_t reverb; - float *dry {}; - float *wet[2] { {}, {} }; -}; -#else -// WARNING: This structure may need initialisation. struct Reverb_priv_t { reverb_t reverb; float *dry; float *wet[2]; }; -#endif // // EffectReverb @@ -189,7 +176,7 @@ bool EffectReverb::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelName mNumChans = 2; } - mP.reinit(mNumChans, true); + mP = (Reverb_priv_t *) calloc(sizeof(*mP), mNumChans); for (int i = 0; i < mNumChans; i++) { @@ -212,7 +199,12 @@ bool EffectReverb::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelName bool EffectReverb::ProcessFinalize() { - mP.reset(); + for (int i = 0; i < mNumChans; i++) + { + reverb_delete(&mP[i].reverb); + } + + free(mP); return true; } diff --git a/src/effects/Reverb.h b/src/effects/Reverb.h index c2637f975..c3e49ac18 100644 --- a/src/effects/Reverb.h +++ b/src/effects/Reverb.h @@ -98,7 +98,7 @@ private: private: unsigned mNumChans {}; - ArrayOf mP; + Reverb_priv_t *mP; Params mParams; diff --git a/src/effects/Reverb_libSoX.h b/src/effects/Reverb_libSoX.h index 64708b0bb..e13325269 100644 --- a/src/effects/Reverb_libSoX.h +++ b/src/effects/Reverb_libSoX.h @@ -29,38 +29,23 @@ using std::max; #define FIFO_SIZE_T size_t #define FIFO_MIN 0x4000 #define fifo_read_ptr(f) fifo_read(f, (FIFO_SIZE_T)0, NULL) -#define lsx_zalloc(var, n) (var.reinit(n, true), var.get()) -#define filter_advance(p) if (--(p)->ptr < (p)->buffer.get()) (p)->ptr += (p)->size +#define lsx_zalloc(var, n) var = (float *)calloc(n, sizeof(*var)) +#define filter_advance(p) if (--(p)->ptr < (p)->buffer) (p)->ptr += (p)->size +#define filter_delete(p) free((p)->buffer) -#if 0 -//initialisations not supported in MSVC 2013. -//Gives error C2905 -// Do not make conditional on compiler. typedef struct { - ArrayOf data; - size_t allocation {}; /* Number of bytes allocated for data. */ - size_t item_size {}; /* Size of each item in data */ - size_t begin {}; /* Offset of the first byte to read. */ - size_t end {}; /* 1 + Offset of the last byte byte to read. */ -} fifo_t; -#else -// WARNING: This structure may need initialisation. -typedef struct { - ArrayOf data; + char * data; size_t allocation; /* Number of bytes allocated for data. */ size_t item_size; /* Size of each item in data */ size_t begin; /* Offset of the first byte to read. */ size_t end; /* 1 + Offset of the last byte byte to read. */ } fifo_t; -#endif static void fifo_clear(fifo_t * f) { f->end = f->begin = 0; } - - static void * fifo_reserve(fifo_t * f, FIFO_SIZE_T n) { n *= f->item_size; @@ -70,19 +55,19 @@ static void * fifo_reserve(fifo_t * f, FIFO_SIZE_T n) while (1) { if (f->end + n <= f->allocation) { - void *p = f->data.get() + f->end; + void *p = f->data + f->end; f->end += n; return p; } if (f->begin > FIFO_MIN) { - memmove(f->data.get(), f->data.get() + f->begin, f->end - f->begin); + memmove(f->data, f->data + f->begin, f->end - f->begin); f->end -= f->begin; f->begin = 0; continue; } f->allocation += n; - f->data.reinit(f->allocation); + f->data = (char *)realloc(f->data, f->allocation); } } @@ -96,7 +81,7 @@ static void * fifo_write(fifo_t * f, FIFO_SIZE_T n, void const * data) static void * fifo_read(fifo_t * f, FIFO_SIZE_T n, void * data) { - char * ret = f->data.get() + f->begin; + char * ret = f->data + f->begin; n *= f->item_size; if (n > (FIFO_SIZE_T)(f->end - f->begin)) return NULL; @@ -106,18 +91,22 @@ static void * fifo_read(fifo_t * f, FIFO_SIZE_T n, void * data) return ret; } +static void fifo_delete(fifo_t * f) +{ + free(f->data); +} + static void fifo_create(fifo_t * f, FIFO_SIZE_T item_size) { f->item_size = item_size; f->allocation = FIFO_MIN; - f->data.reinit(f->allocation); + f->data = (char *)malloc(f->allocation); fifo_clear(f); } typedef struct { size_t size; - ArrayOf buffer; - float * ptr; + float * buffer, * ptr; float store; } filter_t; @@ -210,29 +199,24 @@ static void filter_array_process(filter_array_t * p, } } -#if 0 -//initialisations not supported in MSVC 2013. -//Gives error C2905 -// Do not make conditional on compiler. -typedef struct { - float feedback {}; - float hf_damping {}; - float gain {}; - fifo_t input_fifo {}; - filter_array_t chan[2]; - ArrayOf out[2]; -} reverb_t; -#else -// WARNING: This structure may need initialisation. +static void filter_array_delete(filter_array_t * p) +{ + size_t i; + + for (i = 0; i < array_length(allpass_lengths); ++i) + filter_delete(&p->allpass[i]); + for (i = 0; i < array_length(comb_lengths); ++i) + filter_delete(&p->comb[i]); +} + typedef struct { float feedback; float hf_damping; float gain; fifo_t input_fifo; filter_array_t chan[2]; - ArrayOf out[2]; + float * out[2]; } reverb_t; -#endif static void reverb_create(reverb_t * p, double sample_rate_Hz, double wet_gain_dB, @@ -270,7 +254,17 @@ static void reverb_process(reverb_t * p, size_t length) { size_t i; for (i = 0; i < 2 && p->out[i]; ++i) - filter_array_process(p->chan + i, length, (float *) fifo_read_ptr(&p->input_fifo), p->out[i].get(), &p->feedback, &p->hf_damping, &p->gain); + filter_array_process(p->chan + i, length, (float *) fifo_read_ptr(&p->input_fifo), p->out[i], &p->feedback, &p->hf_damping, &p->gain); fifo_read(&p->input_fifo, length, NULL); } +static void reverb_delete(reverb_t * p) +{ + size_t i; + for (i = 0; i < 2 && p->out[i]; ++i) { + free(p->out[i]); + filter_array_delete(p->chan + i); + } + fifo_delete(&p->input_fifo); +} +