ref: c21acb9af53c574313b6265afe6806cc69b4ee43
parent: fe8782394f247e915509a3e32a6e0b8614ee783b
author: Paul Brossier <piem@piem.org>
date: Mon Dec 30 14:20:28 EST 2013
src/: improve build with -Wdeclaration-after-statement
--- 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);
--- 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_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 @@
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];
--- 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;
--- a/src/io/sink_sndfile.c
+++ b/src/io/sink_sndfile.c
@@ -46,6 +46,7 @@
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 @@
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 @@
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 @@
}
}
- 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);
--- 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;
--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -49,10 +49,11 @@
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;
--- a/src/pitch/pitch.c
+++ b/src/pitch/pitch.c
@@ -366,10 +366,11 @@
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 {
--- a/src/pitch/pitchspecacf.c
+++ b/src/pitch/pitchspecacf.c
@@ -56,7 +56,7 @@
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 @@
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.;
}
--- a/src/pitch/pitchyinfft.c
+++ b/src/pitch/pitchyinfft.c
@@ -57,6 +57,8 @@
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 @@
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]) {
--- a/src/synth/wavetable.c
+++ b/src/synth/wavetable.c
@@ -42,12 +42,12 @@
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 @@
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);
}
--- a/src/tempo/beattracking.c
+++ b/src/tempo/beattracking.c
@@ -61,8 +61,6 @@
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 @@
* 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;
--- 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);
--- 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);
--
⑨