From: Hugo Villeneuve Date: Mon, 5 Sep 2011 15:15:27 +0000 (-0400) Subject: Fix GCC warnings for variably modified arrays X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=4072fbe804677b7a8e50fc594fd01719e5fc7d76;p=hvgrip.git Fix GCC warnings for variably modified arrays --- diff --git a/src/gain_analysis.c b/src/gain_analysis.c index a28101e..85b006a 100644 --- a/src/gain_analysis.c +++ b/src/gain_analysis.c @@ -98,13 +98,13 @@ typedef signed int Int32_t; #define YULE_ORDER 10 #define BUTTER_ORDER 2 #define RMS_PERCENTILE 0.95 // percentile which is louder than the proposed level -#define MAX_SAMP_FREQ 48000. // maximum allowed sample frequency [Hz] -#define RMS_WINDOW_TIME 0.050 // Time slice size [s] -#define STEPS_per_dB 100. // Table entries per dB -#define MAX_dB 120. // Table entries for 0...MAX_dB (normal max. values are 70...80 dB) +#define MAX_SAMP_FREQ 48000 // maximum allowed sample frequency [Hz] +#define RMS_WINDOW_TIME 50 // Time slice size [ms] +#define STEPS_per_dB 100 // Table entries per dB +#define MAX_dB 120 // Table entries for 0...MAX_dB (normal max. values are 70...80 dB) #define MAX_ORDER (BUTTER_ORDER > YULE_ORDER ? BUTTER_ORDER : YULE_ORDER) -#define MAX_SAMPLES_PER_WINDOW (size_t) (MAX_SAMP_FREQ * RMS_WINDOW_TIME) // max. Samples per Time slice +#define MAX_SAMPLES_PER_WINDOW (MAX_SAMP_FREQ * RMS_WINDOW_TIME / 1000) // max. Samples per Time slice #define PINK_REF 64.82 //298640883795 // calibration value Float_t linprebuf [MAX_ORDER * 2]; @@ -223,7 +223,7 @@ ResetSampleFrequency ( long samplefreq ) { default: return INIT_GAIN_ANALYSIS_ERROR; } - sampleWindow = (int) ceil (samplefreq * RMS_WINDOW_TIME); + sampleWindow = (int) ceil (samplefreq * ( (float_t) RMS_WINDOW_TIME) / 1000); lsum = 0.; rsum = 0.; @@ -314,7 +314,7 @@ AnalyzeSamples ( const Float_t* left_samples, const Float_t* right_samples, size cursamplepos += cursamples; totsamp += cursamples; if ( totsamp == sampleWindow ) { // Get the Root Mean Square (RMS) for this set of samples - double val = STEPS_per_dB * 10. * log10 ( (lsum+rsum) / totsamp * 0.5 + 1.e-37 ); + double val = (float_t) STEPS_per_dB * 10. * log10 ( (lsum+rsum) / totsamp * 0.5 + 1.e-37 ); int ival = (int) val; if ( ival < 0 ) ival = 0; if ( ival >= sizeof(A)/sizeof(*A) ) ival = sizeof(A)/sizeof(*A) - 1;