From: Paul Brossier Date: Mon, 30 Dec 2013 23:20:28 +0000 (-0400) Subject: src/: improve build with -Wdeclaration-after-statement X-Git-Tag: 0.4.1~102^2~7 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=c21acb9af53c574313b6265afe6806cc69b4ee43;p=aubio.git src/: improve build with -Wdeclaration-after-statement --- diff --git a/src/cvec.c b/src/cvec.c index 1b60ed49..6d1edb83 100644 --- a/src/cvec.c +++ b/src/cvec.c @@ -22,10 +22,11 @@ #include "cvec.h" cvec_t * new_cvec( uint_t length) { + cvec_t * s; if ((sint_t)length <= 0) { return NULL; } - cvec_t * s = AUBIO_NEW(cvec_t); + s = AUBIO_NEW(cvec_t); s->length = length/2 + 1; s->norm = AUBIO_ARRAY(smpl_t,s->length); s->phas = AUBIO_ARRAY(smpl_t,s->length); diff --git a/src/fmat.c b/src/fmat.c index 09b3a8c7..78330201 100644 --- a/src/fmat.c +++ b/src/fmat.c @@ -22,11 +22,12 @@ #include "fmat.h" fmat_t * new_fmat (uint_t height, uint_t length) { + fmat_t * s; + uint_t i,j; if ((sint_t)length <= 0 || (sint_t)height <= 0 ) { return NULL; } - fmat_t * s = AUBIO_NEW(fmat_t); - uint_t i,j; + s = AUBIO_NEW(fmat_t); s->height = height; s->length = length; s->data = AUBIO_ARRAY(smpl_t*,s->height); @@ -126,6 +127,10 @@ void fmat_weight(fmat_t *s, fmat_t *weight) { } void fmat_copy(fmat_t *s, fmat_t *t) { + uint_t i; +#if !HAVE_MEMCPY_HACKS + uint_t i,j; +#endif if (s->height != t->height) { AUBIO_ERR("trying to copy %d rows to %d rows \n", s->height, t->height); @@ -137,12 +142,10 @@ void fmat_copy(fmat_t *s, fmat_t *t) { return; } #if HAVE_MEMCPY_HACKS - uint_t i; for (i=0; i< s->height; i++) { memcpy(t->data[i], s->data[i], t->length * sizeof(smpl_t)); } #else - uint_t i,j; for (i=0; i< t->height; i++) { for (j=0; j< t->length; j++) { t->data[i][j] = s->data[i][j]; diff --git a/src/fvec.c b/src/fvec.c index d0bfbfcd..a96afd9c 100644 --- a/src/fvec.c +++ b/src/fvec.c @@ -22,10 +22,11 @@ #include "fvec.h" fvec_t * new_fvec( uint_t length) { + fvec_t * s; if ((sint_t)length <= 0) { return NULL; } - fvec_t * s = AUBIO_NEW(fvec_t); + s = AUBIO_NEW(fvec_t); s->length = length; s->data = AUBIO_ARRAY(smpl_t, s->length); return s; diff --git a/src/io/sink_sndfile.c b/src/io/sink_sndfile.c index 7d2aaea9..8437e053 100644 --- a/src/io/sink_sndfile.c +++ b/src/io/sink_sndfile.c @@ -46,6 +46,7 @@ struct _aubio_sink_sndfile_t { aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate) { aubio_sink_sndfile_t * s = AUBIO_NEW(aubio_sink_sndfile_t); + SF_INFO sfinfo; if (path == NULL) { AUBIO_ERR("Aborted opening null path\n"); @@ -58,7 +59,6 @@ aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate) s->path = path; /* set output format */ - SF_INFO sfinfo; AUBIO_MEMSET(&sfinfo, 0, sizeof (sfinfo)); sfinfo.samplerate = s->samplerate; sfinfo.channels = s->channels; @@ -91,6 +91,7 @@ void aubio_sink_sndfile_do(aubio_sink_sndfile_t *s, fvec_t * write_data, uint_t uint_t i, j, channels = s->channels; int nsamples = channels*write; smpl_t *pwrite; + sf_count_t written_frames; if (write > s->max_size) { AUBIO_WRN("trying to write %d frames, but only %d can be written at a time", @@ -106,7 +107,7 @@ void aubio_sink_sndfile_do(aubio_sink_sndfile_t *s, fvec_t * write_data, uint_t } } - sf_count_t written_frames = sf_write_float (s->handle, s->scratch_data, nsamples); + written_frames = sf_write_float (s->handle, s->scratch_data, nsamples); if (written_frames/channels != write) { AUBIO_WRN("trying to write %d frames to %s, but only %d could be written", write, s->path, (uint_t)written_frames); diff --git a/src/lvec.c b/src/lvec.c index aaae18a9..07423fbc 100644 --- a/src/lvec.c +++ b/src/lvec.c @@ -22,10 +22,11 @@ #include "lvec.h" lvec_t * new_lvec( uint_t length) { + lvec_t * s; if ((sint_t)length <= 0) { return NULL; } - lvec_t * s = AUBIO_NEW(lvec_t); + s = AUBIO_NEW(lvec_t); s->length = length; s->data = AUBIO_ARRAY(lsmp_t, s->length); return s; diff --git a/src/mathutils.c b/src/mathutils.c index f1061569..b782bd26 100644 --- a/src/mathutils.c +++ b/src/mathutils.c @@ -49,10 +49,11 @@ fvec_t * new_aubio_window (char_t * window_type, uint_t length) { fvec_t * win = new_fvec (length); + uint_t err; if (win == NULL) { return NULL; } - uint_t err = fvec_set_window (win, window_type); + err = fvec_set_window (win, window_type); if (err != 0) { del_fvec(win); return NULL; diff --git a/src/pitch/pitch.c b/src/pitch/pitch.c index 7247ae25..e32673da 100644 --- a/src/pitch/pitch.c +++ b/src/pitch/pitch.c @@ -366,10 +366,11 @@ aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) void aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out) { + smpl_t pitch = 0., period; aubio_pitch_slideblock (p, ibuf); aubio_pitchspecacf_do (p->p_object, p->buf, out); //out->data[0] = aubio_bintofreq (out->data[0], p->samplerate, p->bufsize); - smpl_t pitch = 0., period = out->data[0]; + period = out->data[0]; if (period > 0) { pitch = p->samplerate / period; } else { diff --git a/src/pitch/pitchspecacf.c b/src/pitch/pitchspecacf.c index 7b25a225..cae5eecc 100644 --- a/src/pitch/pitchspecacf.c +++ b/src/pitch/pitchspecacf.c @@ -56,7 +56,7 @@ new_aubio_pitchspecacf (uint_t bufsize) void aubio_pitchspecacf_do (aubio_pitchspecacf_t * p, fvec_t * input, fvec_t * output) { - uint_t l; + uint_t l, tau; fvec_t *fftout = p->fftout; // window the input for (l = 0; l < input->length; l++) { @@ -74,7 +74,7 @@ aubio_pitchspecacf_do (aubio_pitchspecacf_t * p, fvec_t * input, fvec_t * output p->acf->data[l] = fftout->data[l]; } // get the minimum - uint_t tau = fvec_min_elem (p->acf); + tau = fvec_min_elem (p->acf); // get the interpolated minimum output->data[0] = fvec_quadratic_peak_pos (p->acf, tau) * 2.; } diff --git a/src/pitch/pitchyinfft.c b/src/pitch/pitchyinfft.c index cdd0af4d..3608b292 100644 --- a/src/pitch/pitchyinfft.c +++ b/src/pitch/pitchyinfft.c @@ -57,6 +57,8 @@ static const smpl_t weight[] = { aubio_pitchyinfft_t * new_aubio_pitchyinfft (uint_t samplerate, uint_t bufsize) { + uint_t i = 0, j = 1; + smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0; aubio_pitchyinfft_t *p = AUBIO_NEW (aubio_pitchyinfft_t); p->winput = new_fvec (bufsize); p->fft = new_aubio_fft (bufsize); @@ -66,8 +68,6 @@ new_aubio_pitchyinfft (uint_t samplerate, uint_t bufsize) p->tol = 0.85; p->win = new_aubio_window ("hanningz", bufsize); p->weight = new_fvec (bufsize / 2 + 1); - uint_t i = 0, j = 1; - smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0; for (i = 0; i < p->weight->length; i++) { freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) samplerate; while (freq > freqs[j]) { diff --git a/src/synth/wavetable.c b/src/synth/wavetable.c index c0714840..e4e08953 100644 --- a/src/synth/wavetable.c +++ b/src/synth/wavetable.c @@ -42,12 +42,12 @@ struct _aubio_wavetable_t { aubio_wavetable_t *new_aubio_wavetable(uint_t samplerate, uint_t blocksize) { + uint_t i = 0; aubio_wavetable_t *s = AUBIO_NEW(aubio_wavetable_t); if ((sint_t)samplerate <= 0) { AUBIO_ERR("Can not create wavetable with samplerate %d\n", samplerate); goto beach; } - uint_t i = 0; s->samplerate = samplerate; s->blocksize = blocksize; s->wavetable_length = WAVETABLE_LEN; @@ -114,12 +114,12 @@ void aubio_wavetable_do_multi ( aubio_wavetable_t * s, fmat_t * input, fmat_t * smpl_t pos = s->last_pos; for (j = 0; j < output->length; j++) { smpl_t inc = aubio_parameter_get_next_value( s->freq ); + smpl_t amp = aubio_parameter_get_next_value ( s->amp ); inc *= (smpl_t)(s->wavetable_length) / (smpl_t) (s->samplerate); pos += inc; while (pos > s->wavetable_length) { pos -= s->wavetable_length; } - smpl_t amp = aubio_parameter_get_next_value ( s->amp ); for (i = 0; i < output->height; i++) { output->data[i][j] = amp * interp_2(s->wavetable, pos); } diff --git a/src/tempo/beattracking.c b/src/tempo/beattracking.c index d1d362c3..3f1708c4 100644 --- a/src/tempo/beattracking.c +++ b/src/tempo/beattracking.c @@ -61,8 +61,6 @@ new_aubio_beattracking (uint_t winlen, uint_t hop_size, uint_t samplerate) aubio_beattracking_t *p = AUBIO_NEW (aubio_beattracking_t); uint_t i = 0; - p->hop_size = hop_size; - p->samplerate = samplerate; /* default value for rayleigh weighting - sets preferred tempo to 120bpm */ smpl_t rayparam = 60. * samplerate / 120. / hop_size; smpl_t dfwvnorm = EXP ((LOG (2.0) / rayparam) * (winlen + 2)); @@ -72,6 +70,8 @@ new_aubio_beattracking (uint_t winlen, uint_t hop_size, uint_t samplerate) * 1 onset frame [128] */ uint_t step = winlen / 4; /* 1.5 seconds */ + p->hop_size = hop_size; + p->samplerate = samplerate; p->lastbeat = 0; p->counter = 0; p->flagstep = 0; diff --git a/src/temporal/a_weighting.c b/src/temporal/a_weighting.c index 819d6f72..a2d84303 100644 --- a/src/temporal/a_weighting.c +++ b/src/temporal/a_weighting.c @@ -28,11 +28,12 @@ uint_t aubio_filter_set_a_weighting (aubio_filter_t * f, uint_t samplerate) { + uint_t order; lsmp_t *a, *b; lvec_t *as, *bs; aubio_filter_set_samplerate (f, samplerate); - lvec_t *bs = aubio_filter_get_feedforward (f); - lvec_t *as = aubio_filter_get_feedback (f); - lsmp_t *b = bs->data, *a = as->data; - uint_t order = aubio_filter_get_order (f); + bs = aubio_filter_get_feedforward (f); + as = aubio_filter_get_feedback (f); + b = bs->data, a = as->data; + order = aubio_filter_get_order (f); if (order != 7) { AUBIO_ERROR ("order of A-weighting filter must be 7, not %d\n", order); diff --git a/src/temporal/c_weighting.c b/src/temporal/c_weighting.c index 45c2894e..be658bfb 100644 --- a/src/temporal/c_weighting.c +++ b/src/temporal/c_weighting.c @@ -28,11 +28,12 @@ uint_t aubio_filter_set_c_weighting (aubio_filter_t * f, uint_t samplerate) { + uint_t order; lsmp_t *a, *b; lvec_t *as, *bs; aubio_filter_set_samplerate (f, samplerate); - lvec_t *bs = aubio_filter_get_feedforward (f); - lvec_t *as = aubio_filter_get_feedback (f); - lsmp_t *b = bs->data, *a = as->data; - uint_t order = aubio_filter_get_order (f); + bs = aubio_filter_get_feedforward (f); + as = aubio_filter_get_feedback (f); + b = bs->data, a = as->data; + order = aubio_filter_get_order (f); if ( order != 5 ) { AUBIO_ERROR ("order of C-weighting filter must be 5, not %d\n", order);