From e94fa1d65e5555b78cae164f7b9ca5a6f363d8b8 Mon Sep 17 00:00:00 2001 From: James Crook Date: Sat, 18 Mar 2017 16:05:12 +0000 Subject: [PATCH] Fix compilation on MSVC2013 Express. MSVC2013 Express does not support some initialisation syntax for structs and instead gives error C2905. This workaround to get us compiling again may need revisiting. --- src/effects/Biquad.h | 21 +++++++++++++++++++++ src/effects/Reverb.cpp | 13 +++++++++++++ src/effects/Reverb_libSoX.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/src/effects/Biquad.h b/src/effects/Biquad.h index 788bb4a4e..0f6ebf235 100644 --- a/src/effects/Biquad.h +++ b/src/effects/Biquad.h @@ -1,5 +1,10 @@ #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 {}; @@ -10,6 +15,22 @@ 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 a3667d428..e3fa56d48 100644 --- a/src/effects/Reverb.cpp +++ b/src/effects/Reverb.cpp @@ -75,12 +75,25 @@ 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 diff --git a/src/effects/Reverb_libSoX.h b/src/effects/Reverb_libSoX.h index e14a543d7..64708b0bb 100644 --- a/src/effects/Reverb_libSoX.h +++ b/src/effects/Reverb_libSoX.h @@ -32,6 +32,10 @@ using std::max; #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 +#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. */ @@ -39,12 +43,24 @@ typedef struct { 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; + 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; @@ -194,6 +210,10 @@ 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 {}; @@ -202,6 +222,17 @@ typedef struct { filter_array_t chan[2]; ArrayOf out[2]; } reverb_t; +#else +// WARNING: This structure may need initialisation. +typedef struct { + float feedback; + float hf_damping; + float gain; + fifo_t input_fifo; + filter_array_t chan[2]; + ArrayOf out[2]; +} reverb_t; +#endif static void reverb_create(reverb_t * p, double sample_rate_Hz, double wet_gain_dB,