shithub: aubio

Download patch

ref: 09908e6a6c423a43432b01fc9eebcf0d475e52d9
parent: 8a05420e5dd8c7b8b2447f82dc919765876511b3
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Aug 18 20:45:52 EDT 2023

port/build the library

diff: cannot open b/src/plan9//null: file does not exist: 'b/src/plan9//null'
--- a/src/aubio_priv.h
+++ b/src/aubio_priv.h
@@ -266,11 +266,13 @@
 #define AUBIO_MAX_CHANNELS 1024
 
 /* pi and 2*pi */
+#ifndef PI
 #ifndef M_PI
 #define PI         (3.14159265358979323846)
 #else
 #define PI         (M_PI)
 #endif
+#endif
 #define TWO_PI     (PI*2.)
 
 #ifndef PATH_MAX
@@ -314,6 +316,7 @@
 /** complex = CEXPC(complex) */
 #define CEXPC     cexp
 /** sample = ARGC(complex) */
+#undef ARGC
 #define ARGC      carg
 /** sample = ABSC(complex) norm */
 #define ABSC      cabs
--- a/src/effects/pitchshift_dummy.c
+++ b/src/effects/pitchshift_dummy.c
@@ -34,14 +34,17 @@
 
 void aubio_pitchshift_do (aubio_pitchshift_t * o UNUSED, const fvec_t * in UNUSED,
     fvec_t * out UNUSED) {
+  USED(o, in, out);
 }
 
 void del_aubio_pitchshift (aubio_pitchshift_t * o UNUSED) {
+  USED(o);
 }
 
 aubio_pitchshift_t *new_aubio_pitchshift (const char_t * method UNUSED,
     smpl_t pitchscale UNUSED, uint_t hop_size UNUSED, uint_t samplerate UNUSED)
 {
+  USED(method, pitchscale, hop_size, samplerate);
   AUBIO_ERR ("aubio was not compiled with rubberband\n");
   return NULL;
 }
@@ -48,23 +51,28 @@
 
 uint_t aubio_pitchshift_set_pitchscale (aubio_pitchshift_t * o UNUSED, smpl_t pitchscale UNUSED)
 {
+  USED(o, pitchscale);
   return AUBIO_FAIL;
 }
 
 smpl_t aubio_pitchshift_get_pitchscale (aubio_pitchshift_t * o UNUSED)
 {
+  USED(o);
   return 1.;
 }
 
 uint_t aubio_pitchshift_set_transpose (aubio_pitchshift_t * o UNUSED, smpl_t transpose UNUSED) {
+  USED(o, transpose);
   return AUBIO_FAIL;
 }
 
 smpl_t aubio_pitchshift_get_transpose (aubio_pitchshift_t * o UNUSED) {
+  USED(o);
   return 0.;
 }
 
 uint_t aubio_pitchshift_get_latency (aubio_pitchshift_t * o UNUSED) {
+  USED(o);
   return 0.;
 }
 
--- a/src/effects/timestretch_dummy.c
+++ b/src/effects/timestretch_dummy.c
@@ -36,9 +36,11 @@
 aubio_timestretch_do (aubio_timestretch_t * o UNUSED, fvec_t * out UNUSED,
     uint_t * read UNUSED)
 {
+  USED(o, out, read);
 }
 
 void del_aubio_timestretch (aubio_timestretch_t * o UNUSED) {
+  USED(o);
 }
 
 aubio_timestretch_t *
@@ -45,6 +47,7 @@
 new_aubio_timestretch (const char_t * method UNUSED,
     smpl_t pitchscale UNUSED, uint_t hop_size UNUSED, uint_t samplerate UNUSED)
 {
+  USED(method, pitchscale, hop_size, samplerate);
   AUBIO_ERR ("timestretch: aubio was not compiled with rubberband\n");
   return NULL;
 }
@@ -51,50 +54,61 @@
 
 uint_t aubio_timestretch_set_stretch (aubio_timestretch_t * o UNUSED, smpl_t stretch UNUSED)
 {
+  USED(o, stretch);
   return AUBIO_FAIL;
 }
 
 smpl_t aubio_timestretch_get_stretch (aubio_timestretch_t * o UNUSED)
 {
+  USED(o);
   return 1.;
 }
 
 uint_t aubio_timestretch_set_pitchscale (aubio_timestretch_t * o UNUSED, smpl_t pitchscale UNUSED)
 {
+  USED(o, pitchscale);
   return AUBIO_FAIL;
 }
 
 uint_t aubio_timestretch_get_samplerate (aubio_timestretch_t * o UNUSED) {
+  USED(o);
   return 0;
 }
 
 smpl_t aubio_timestretch_get_pitchscale (aubio_timestretch_t * o UNUSED)
 {
+  USED(o);
   return 1.;
 }
 
 uint_t aubio_timestretch_set_transpose (aubio_timestretch_t * o UNUSED, smpl_t transpose UNUSED) {
+  USED(o, transpose);
   return AUBIO_FAIL;
 }
 
 smpl_t aubio_timestretch_get_transpose (aubio_timestretch_t * o UNUSED) {
+  USED(o);
   return 0.;
 }
 
 uint_t aubio_timestretch_get_latency (aubio_timestretch_t * o UNUSED) {
+  USED(o);
   return 0.;
 }
 
 uint_t aubio_timestretch_reset(aubio_timestretch_t *o UNUSED) {
+  USED(o);
   return AUBIO_FAIL;
 }
 
 sint_t aubio_timestretch_push(aubio_timestretch_t * o UNUSED, fvec_t * in
     UNUSED, uint_t length UNUSED) {
+  USED(o, in, length);
   return AUBIO_FAIL;
 }
 
 sint_t aubio_timestretch_get_available(aubio_timestretch_t * o UNUSED) {
+  USED(o);
   return AUBIO_FAIL;
 }
 // end of dummy implementation
--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -509,7 +509,7 @@
 }
 
 uint_t fvec_peakpick(const fvec_t * onset, uint_t pos) {
-  uint_t tmp=0;
+  uint_t tmp;
   tmp = (onset->data[pos] > onset->data[pos-1]
       &&  onset->data[pos] > onset->data[pos+1]
       &&  onset->data[pos] > 0.);
@@ -656,7 +656,7 @@
 {
   uint_t i, j, length = input->length;
   smpl_t *data, *acf;
-  smpl_t tmp = 0;
+  smpl_t tmp;
   data = input->data;
   acf = output->data;
   for (i = 0; i < length; i++) {
--- /dev/null
+++ b/src/mkfile
@@ -1,0 +1,137 @@
+</$objtype/mkfile
+
+LIB=libaubio.a$O
+CFLAGS=$CFLAGS -DHAVE_CONFIG_H -D__plan9__ -p -Iplan9 -I. -I/sys/include/npe
+
+HFILES=\
+	aubio.h\
+	aubio_priv.h\
+	cvec.h\
+	effects/pitchshift.h\
+	effects/timestretch.h\
+	fmat.h\
+	fvec.h\
+	io/audio_unit.h\
+	io/ioutils.h\
+	io/sink.h\
+	io/sink_wavwrite.h\
+	io/source.h\
+	io/source_apple_audio.h\
+	io/source_avcodec.h\
+	io/source_sndfile.h\
+	io/source_wavread.h\
+	lvec.h\
+	mathutils.h\
+	musicutils.h\
+	notes/notes.h\
+	onset/onset.h\
+	onset/peakpicker.h\
+	pitch/pitch.h\
+	pitch/pitchfcomb.h\
+	pitch/pitchmcomb.h\
+	pitch/pitchschmitt.h\
+	pitch/pitchspecacf.h\
+	pitch/pitchyin.h\
+	pitch/pitchyinfast.h\
+	pitch/pitchyinfft.h\
+	spectral/awhitening.h\
+	spectral/dct.h\
+	spectral/fft.h\
+	spectral/filterbank.h\
+	spectral/filterbank_mel.h\
+	spectral/mfcc.h\
+	spectral/phasevoc.h\
+	spectral/specdesc.h\
+	spectral/tss.h\
+	synth/sampler.h\
+	synth/wavetable.h\
+	tempo/beattracking.h\
+	tempo/tempo.h\
+	temporal/a_weighting.h\
+	temporal/biquad.h\
+	temporal/c_weighting.h\
+	temporal/filter.h\
+	temporal/resampler.h\
+	types.h\
+	utils/hist.h\
+	utils/log.h\
+	utils/parameter.h\
+	utils/scale.h\
+	vecutils.h\
+
+OFILES=\
+	cvec.$O\
+	effects/pitchshift_dummy.$O\
+	effects/rubberband_utils.$O\
+	effects/timestretch_dummy.$O\
+	fmat.$O\
+	fvec.$O\
+	io/audio_unit.$O\
+	io/ioutils.$O\
+	io/sink.$O\
+	io/sink_wavwrite.$O\
+	io/source.$O\
+	io/source_apple_audio.$O\
+	io/source_avcodec.$O\
+	io/source_sndfile.$O\
+	io/source_wavread.$O\
+	io/utils_apple_audio.$O\
+	lvec.$O\
+	mathutils.$O\
+	musicutils.$O\
+	notes/notes.$O\
+	onset/onset.$O\
+	onset/peakpicker.$O\
+	pitch/pitch.$O\
+	pitch/pitchfcomb.$O\
+	pitch/pitchmcomb.$O\
+	pitch/pitchschmitt.$O\
+	pitch/pitchspecacf.$O\
+	pitch/pitchyin.$O\
+	pitch/pitchyinfast.$O\
+	pitch/pitchyinfft.$O\
+	spectral/awhitening.$O\
+	spectral/dct.$O\
+	spectral/dct_accelerate.$O\
+	spectral/dct_fftw.$O\
+	spectral/dct_ipp.$O\
+	spectral/dct_ooura.$O\
+	spectral/dct_plain.$O\
+	spectral/fft.$O\
+	spectral/filterbank.$O\
+	spectral/filterbank_mel.$O\
+	spectral/mfcc.$O\
+	spectral/ooura_fft8g.$O\
+	spectral/phasevoc.$O\
+	spectral/specdesc.$O\
+	spectral/statistics.$O\
+	spectral/tss.$O\
+	synth/sampler.$O\
+	synth/wavetable.$O\
+	tempo/beattracking.$O\
+	tempo/tempo.$O\
+	temporal/a_weighting.$O\
+	temporal/biquad.$O\
+	temporal/c_weighting.$O\
+	temporal/filter.$O\
+	temporal/resampler.$O\
+	utils/hist.$O\
+	utils/log.$O\
+	utils/parameter.$O\
+	utils/scale.$O\
+	utils/strutils.$O\
+	utils/windll.$O\
+	vecutils.$O\
+
+UPDATE=\
+	mkfile\
+	$HFILES\
+	${OFILES:%.$O=%.c}\
+	${LIB:/$objtype/%=/386/%}\
+
+CLEANFILES=$OFILES
+
+</sys/src/cmd/mklib
+
+%.$O: %.c
+	$CC $CFLAGS -o $target $stem.c
--- a/src/notes/notes.c
+++ b/src/notes/notes.c
@@ -173,7 +173,7 @@
 static void
 note_append (fvec_t * note_buffer, smpl_t curnote)
 {
-  uint_t i = 0;
+  uint_t i;
   for (i = 0; i < note_buffer->length - 1; i++) {
     note_buffer->data[i] = note_buffer->data[i + 1];
   }
--- a/src/onset/onset.c
+++ b/src/onset/onset.c
@@ -55,7 +55,7 @@
 /* execute onset detection function on iput buffer */
 void aubio_onset_do (aubio_onset_t *o, const fvec_t * input, fvec_t * onset)
 {
-  smpl_t isonset = 0;
+  smpl_t isonset;
   aubio_pvoc_do (o->pv,input, o->fftgrain);
   /*
   if (apply_filtering) {
--- a/src/onset/peakpicker.c
+++ b/src/onset/peakpicker.c
@@ -91,8 +91,8 @@
   fvec_t *onset_peek = p->onset_peek;
   fvec_t *thresholded = p->thresholded;
   fvec_t *scratch = p->scratch;
-  smpl_t mean = 0., median = 0.;
-  uint_t j = 0;
+  smpl_t mean, median;
+  uint_t j;
 
   /* push new novelty to the end */
   fvec_push(onset_keep, onset->data[0]);
--- a/src/pitch/pitch.c
+++ b/src/pitch/pitch.c
@@ -406,7 +406,7 @@
 }
 
 /* do method for each algorithm */
-void
+static void
 aubio_pitch_do_mcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf)
 {
   aubio_filter_do_outplace (p->filter, ibuf, p->filtered);
@@ -415,10 +415,10 @@
   obuf->data[0] = aubio_bintofreq (obuf->data[0], p->samplerate, p->bufsize);
 }
 
-void
+static void
 aubio_pitch_do_yin (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf)
 {
-  smpl_t pitch = 0.;
+  smpl_t pitch;
   aubio_pitch_slideblock (p, ibuf);
   aubio_pitchyin_do (p->p_object, p->buf, obuf);
   pitch = obuf->data[0];
@@ -431,10 +431,10 @@
 }
 
 
-void
+static void
 aubio_pitch_do_yinfft (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf)
 {
-  smpl_t pitch = 0.;
+  smpl_t pitch;
   aubio_pitch_slideblock (p, ibuf);
   aubio_pitchyinfft_do (p->p_object, p->buf, obuf);
   pitch = obuf->data[0];
@@ -446,10 +446,10 @@
   obuf->data[0] = pitch;
 }
 
-void
+static void
 aubio_pitch_do_yinfast (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf)
 {
-  smpl_t pitch = 0.;
+  smpl_t pitch;
   aubio_pitch_slideblock (p, ibuf);
   aubio_pitchyinfast_do (p->p_object, p->buf, obuf);
   pitch = obuf->data[0];
@@ -461,10 +461,10 @@
   obuf->data[0] = pitch;
 }
 
-void
+static void
 aubio_pitch_do_specacf (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out)
 {
-  smpl_t pitch = 0., period;
+  smpl_t pitch, 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);
@@ -477,7 +477,7 @@
   out->data[0] = pitch;
 }
 
-void
+static void
 aubio_pitch_do_fcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out)
 {
   aubio_pitch_slideblock (p, ibuf);
@@ -485,10 +485,10 @@
   out->data[0] = aubio_bintofreq (out->data[0], p->samplerate, p->bufsize);
 }
 
-void
+static void
 aubio_pitch_do_schmitt (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out)
 {
-  smpl_t period, pitch = 0.;
+  smpl_t period, pitch;
   aubio_pitch_slideblock (p, ibuf);
   aubio_pitchschmitt_do (p->p_object, p->buf, out);
   period = out->data[0];
@@ -501,21 +501,23 @@
 }
 
 /* conversion callbacks */
-smpl_t
+static smpl_t
 freqconvbin(smpl_t f, uint_t samplerate, uint_t bufsize)
 {
   return aubio_freqtobin(f, samplerate, bufsize);
 }
 
-smpl_t
+static smpl_t
 freqconvmidi (smpl_t f, uint_t samplerate UNUSED, uint_t bufsize UNUSED)
 {
+  USED(samplerate, bufsize);
   return aubio_freqtomidi (f);
 }
 
-smpl_t
+static smpl_t
 freqconvpass (smpl_t f, uint_t samplerate UNUSED, uint_t bufsize UNUSED)
 {
+  USED(samplerate, bufsize);
   return f;
 }
 
--- a/src/pitch/pitchmcomb.c
+++ b/src/pitch/pitchmcomb.c
@@ -223,7 +223,7 @@
   smpl_t xx;
   uint_t position = 0;
 
-  uint_t root_peak = 0;
+  uint_t root_peak;
   uint_t tmpl = 0;
   smpl_t tmpene = 0.;
 
--- a/src/pitch/pitchschmitt.c
+++ b/src/pitch/pitchschmitt.c
@@ -83,7 +83,6 @@
       }
       t1 = (sint_t) (A1 * trigfact + 0.5);
       t2 = -(sint_t) (A2 * trigfact + 0.5);
-      startpoint = 0;
       for (j = 1; j < blockSize && schmittBuffer[j] <= t1; j++);
       for (     ; j < blockSize - 1 && !(schmittBuffer[j] >= t2 &&
              schmittBuffer[j + 1] < t2); j++);
--- a/src/pitch/pitchyinfft.c
+++ b/src/pitch/pitchyinfft.c
@@ -57,8 +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;
+  uint_t i, j = 1;
+  smpl_t freq, a0, a1, f0, f1;
   aubio_pitchyinfft_t *p = AUBIO_NEW (aubio_pitchyinfft_t);
   p->winput = new_fvec (bufsize);
   p->fft = new_aubio_fft (bufsize);
--- /dev/null
+++ b/src/plan9/config.h
@@ -1,0 +1,10 @@
+#define HAVE_AUBIO_DOUBLE 1
+#define HAVE_C99_VARARGS_MACROS 1
+#define HAVE_ERRNO_H 1
+#define HAVE_LIMITS_H 1
+#define HAVE_MATH_H 1
+#define HAVE_STDARG_H 1
+#define HAVE_STDIO_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+#define __STRICT_ANSI__
--- a/src/spectral/awhitening.c
+++ b/src/spectral/awhitening.c
@@ -42,7 +42,7 @@
 void
 aubio_spectral_whitening_do (aubio_spectral_whitening_t * o, cvec_t * fftgrain)
 {
-  uint_t i = 0;
+  uint_t i;
   uint_t length = MIN(fftgrain->length, o->peak_values->length);
   for (i = 0; i < length; i++) {
     smpl_t tmp = MAX(o->r_decay * o->peak_values->data[i], o->floor);
--- a/src/spectral/dct_ooura.c
+++ b/src/spectral/dct_ooura.c
@@ -67,7 +67,7 @@
 }
 
 void aubio_dct_ooura_do(aubio_dct_ooura_t *s, const fvec_t *input, fvec_t *output) {
-  uint_t i = 0;
+  uint_t i;
   fvec_copy(input, s->input);
   aubio_ooura_ddct(s->size, -1, s->input->data, s->ip, s->w);
   // apply orthonormal scaling
@@ -79,7 +79,7 @@
 }
 
 void aubio_dct_ooura_rdo(aubio_dct_ooura_t *s, const fvec_t *input, fvec_t *output) {
-  uint_t i = 0;
+  uint_t i;
   fvec_copy(input, s->input);
   s->input->data[0] *= s->scalers[2];
   for (i = 1; i < s->input->length; i++) {
--- a/src/spectral/fft.c
+++ b/src/spectral/fft.c
@@ -534,7 +534,7 @@
 }
 
 void aubio_fft_get_norm(const fvec_t * compspec, cvec_t * spectrum) {
-  uint_t i = 0;
+  uint_t i;
   spectrum->norm[0] = ABS(compspec->data[0]);
   for (i=1; i < spectrum->length - 1; i++) {
     spectrum->norm[i] = SQRT(SQR(compspec->data[i])
--- a/src/spectral/filterbank_mel.c
+++ b/src/spectral/filterbank_mel.c
@@ -216,6 +216,7 @@
 static uint_t aubio_filterbank_check_freqs (aubio_filterbank_t *fb UNUSED,
     smpl_t samplerate, smpl_t *freq_min, smpl_t *freq_max)
 {
+  USED(fb);
   if (samplerate <= 0) {
     AUBIO_ERR("filterbank: set_mel_coeffs samplerate should be > 0\n");
     return AUBIO_FAIL;
--- a/src/spectral/ooura_fft8g.c
+++ b/src/spectral/ooura_fft8g.c
@@ -307,12 +307,6 @@
 
 void aubio_ooura_cdft(int n, int isgn, smpl_t *a, int *ip, smpl_t *w)
 {
-    void makewt(int nw, int *ip, smpl_t *w);
-    void bitrv2(int n, int *ip, smpl_t *a);
-    void bitrv2conj(int n, int *ip, smpl_t *a);
-    void cftfsub(int n, smpl_t *a, smpl_t *w);
-    void cftbsub(int n, smpl_t *a, smpl_t *w);
-    
     if (n > (ip[0] << 2)) {
         makewt(n >> 2, ip, w);
     }
@@ -332,13 +326,6 @@
 
 void aubio_ooura_rdft(int n, int isgn, smpl_t *a, int *ip, smpl_t *w)
 {
-    void makewt(int nw, int *ip, smpl_t *w);
-    void makect(int nc, int *ip, smpl_t *c);
-    void bitrv2(int n, int *ip, smpl_t *a);
-    void cftfsub(int n, smpl_t *a, smpl_t *w);
-    void cftbsub(int n, smpl_t *a, smpl_t *w);
-    void rftfsub(int n, smpl_t *a, int nc, smpl_t *c);
-    void rftbsub(int n, smpl_t *a, int nc, smpl_t *c);
     int nw, nc;
     smpl_t xi;
     
@@ -379,14 +366,6 @@
 
 void aubio_ooura_ddct(int n, int isgn, smpl_t *a, int *ip, smpl_t *w)
 {
-    void makewt(int nw, int *ip, smpl_t *w);
-    void makect(int nc, int *ip, smpl_t *c);
-    void bitrv2(int n, int *ip, smpl_t *a);
-    void cftfsub(int n, smpl_t *a, smpl_t *w);
-    void cftbsub(int n, smpl_t *a, smpl_t *w);
-    void rftfsub(int n, smpl_t *a, int nc, smpl_t *c);
-    void rftbsub(int n, smpl_t *a, int nc, smpl_t *c);
-    void dctsub(int n, smpl_t *a, int nc, smpl_t *c);
     int j, nw, nc;
     smpl_t xr;
     
@@ -438,14 +417,6 @@
 
 void aubio_ooura_ddst(int n, int isgn, smpl_t *a, int *ip, smpl_t *w)
 {
-    void makewt(int nw, int *ip, smpl_t *w);
-    void makect(int nc, int *ip, smpl_t *c);
-    void bitrv2(int n, int *ip, smpl_t *a);
-    void cftfsub(int n, smpl_t *a, smpl_t *w);
-    void cftbsub(int n, smpl_t *a, smpl_t *w);
-    void rftfsub(int n, smpl_t *a, int nc, smpl_t *c);
-    void rftbsub(int n, smpl_t *a, int nc, smpl_t *c);
-    void dstsub(int n, smpl_t *a, int nc, smpl_t *c);
     int j, nw, nc;
     smpl_t xr;
     
@@ -497,12 +468,6 @@
 
 void aubio_ooura_dfct(int n, smpl_t *a, smpl_t *t, int *ip, smpl_t *w)
 {
-    void makewt(int nw, int *ip, smpl_t *w);
-    void makect(int nc, int *ip, smpl_t *c);
-    void bitrv2(int n, int *ip, smpl_t *a);
-    void cftfsub(int n, smpl_t *a, smpl_t *w);
-    void rftfsub(int n, smpl_t *a, int nc, smpl_t *c);
-    void dctsub(int n, smpl_t *a, int nc, smpl_t *c);
     int j, k, l, m, mh, nw, nc;
     smpl_t xr, xi, yr, yi;
     
@@ -593,12 +558,6 @@
 
 void aubio_ooura_dfst(int n, smpl_t *a, smpl_t *t, int *ip, smpl_t *w)
 {
-    void makewt(int nw, int *ip, smpl_t *w);
-    void makect(int nc, int *ip, smpl_t *c);
-    void bitrv2(int n, int *ip, smpl_t *a);
-    void cftfsub(int n, smpl_t *a, smpl_t *w);
-    void rftfsub(int n, smpl_t *a, int nc, smpl_t *c);
-    void dstsub(int n, smpl_t *a, int nc, smpl_t *c);
     int j, k, l, m, mh, nw, nc;
     smpl_t xr, xi, yr, yi;
     
@@ -683,9 +642,8 @@
 
 #include <math.h>
 
-void makewt(int nw, int *ip, smpl_t *w)
+static void makewt(int nw, int *ip, smpl_t *w)
 {
-    void bitrv2(int n, int *ip, smpl_t *a);
     int j, nwh;
     smpl_t delta, x, y;
     
@@ -719,7 +677,7 @@
 }
 
 
-void makect(int nc, int *ip, smpl_t *c)
+static void makect(int nc, int *ip, smpl_t *c)
 {
     int j, nch;
     smpl_t delta;
@@ -741,7 +699,7 @@
 /* -------- child routines -------- */
 
 
-void bitrv2(int n, int *ip, smpl_t *a)
+static void bitrv2(int n, int *ip, smpl_t *a)
 {
     int j, j1, k, k1, l, m, m2;
     smpl_t xr, xi, yr, yi;
@@ -841,7 +799,7 @@
 }
 
 
-void bitrv2conj(int n, int *ip, smpl_t *a)
+static void bitrv2conj(int n, int *ip, smpl_t *a)
 {
     int j, j1, k, k1, l, m, m2;
     smpl_t xr, xi, yr, yi;
@@ -950,10 +908,8 @@
 }
 
 
-void cftfsub(int n, smpl_t *a, smpl_t *w)
+static void cftfsub(int n, smpl_t *a, smpl_t *w)
 {
-    void cft1st(int n, smpl_t *a, smpl_t *w);
-    void cftmdl(int n, int l, smpl_t *a, smpl_t *w);
     int j, j1, j2, j3, l;
     smpl_t x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
     
@@ -1002,10 +958,8 @@
 }
 
 
-void cftbsub(int n, smpl_t *a, smpl_t *w)
+static void cftbsub(int n, smpl_t *a, smpl_t *w)
 {
-    void cft1st(int n, smpl_t *a, smpl_t *w);
-    void cftmdl(int n, int l, smpl_t *a, smpl_t *w);
     int j, j1, j2, j3, j4, j5, j6, j7, l;
     smpl_t wn4r, x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, 
         y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, 
@@ -1119,7 +1073,7 @@
 }
 
 
-void cft1st(int n, smpl_t *a, smpl_t *w)
+static void cft1st(int n, smpl_t *a, smpl_t *w)
 {
     int j, k1;
     smpl_t wn4r, wtmp, wk1r, wk1i, wk2r, wk2i, wk3r, wk3i, 
@@ -1334,7 +1288,7 @@
 }
 
 
-void cftmdl(int n, int l, smpl_t *a, smpl_t *w)
+static void cftmdl(int n, int l, smpl_t *a, smpl_t *w)
 {
     int j, j1, j2, j3, j4, j5, j6, j7, k, k1, m;
     smpl_t wn4r, wtmp, wk1r, wk1i, wk2r, wk2i, wk3r, wk3i, 
@@ -1577,7 +1531,7 @@
 }
 
 
-void rftfsub(int n, smpl_t *a, int nc, smpl_t *c)
+static void rftfsub(int n, smpl_t *a, int nc, smpl_t *c)
 {
     int j, k, kk, ks, m;
     smpl_t wkr, wki, xr, xi, yr, yi;
@@ -1602,7 +1556,7 @@
 }
 
 
-void rftbsub(int n, smpl_t *a, int nc, smpl_t *c)
+static void rftbsub(int n, smpl_t *a, int nc, smpl_t *c)
 {
     int j, k, kk, ks, m;
     smpl_t wkr, wki, xr, xi, yr, yi;
@@ -1629,7 +1583,7 @@
 }
 
 
-void dctsub(int n, smpl_t *a, int nc, smpl_t *c)
+static void dctsub(int n, smpl_t *a, int nc, smpl_t *c)
 {
     int j, k, kk, ks, m;
     smpl_t wkr, wki, xr;
@@ -1650,7 +1604,7 @@
 }
 
 
-void dstsub(int n, smpl_t *a, int nc, smpl_t *c)
+static void dstsub(int n, smpl_t *a, int nc, smpl_t *c)
 {
     int j, k, kk, ks, m;
     smpl_t wkr, wki, xr;
--- a/src/spectral/specdesc.c
+++ b/src/spectral/specdesc.c
@@ -91,6 +91,7 @@
 void aubio_specdesc_energy  (aubio_specdesc_t *o UNUSED,
     const cvec_t * fftgrain, fvec_t * onset) {
   uint_t j;
+  USED(o);
   onset->data[0] = 0.;
   for (j=0;j<fftgrain->length;j++) {
     onset->data[0] += SQR(fftgrain->norm[j]);
@@ -101,6 +102,7 @@
 void aubio_specdesc_hfc(aubio_specdesc_t *o UNUSED,
     const cvec_t * fftgrain, fvec_t * onset){
   uint_t j;
+  USED(o);
   onset->data[0] = 0.;
   for (j=0;j<fftgrain->length;j++) {
     onset->data[0] += (j+1)*fftgrain->norm[j];
--- a/src/spectral/statistics.c
+++ b/src/spectral/statistics.c
@@ -63,7 +63,7 @@
 smpl_t
 cvec_centroid (const cvec_t * spec)
 {
-  smpl_t sum = 0., sc = 0.;
+  smpl_t sum, sc = 0.;
   uint_t j;
   sum = cvec_sum (spec); 
   if (sum == 0.) {
@@ -79,7 +79,7 @@
 smpl_t
 cvec_moment (const cvec_t * spec, uint_t order)
 {
-  smpl_t sum = 0., centroid = 0., sc = 0.;
+  smpl_t sum, centroid, sc = 0.;
   uint_t j;
   sum = cvec_sum (spec); 
   if (sum == 0.) {
@@ -97,6 +97,7 @@
 aubio_specdesc_centroid (aubio_specdesc_t * o UNUSED, const cvec_t * spec,
     fvec_t * desc)
 {
+  USED(o);
   desc->data[0] = cvec_centroid (spec); 
 }
 
@@ -104,6 +105,7 @@
 aubio_specdesc_spread (aubio_specdesc_t * o UNUSED, const cvec_t * spec,
     fvec_t * desc)
 {
+  USED(o);
   desc->data[0] = cvec_moment (spec, 2);
 }
 
@@ -112,6 +114,7 @@
     fvec_t * desc)
 {
   smpl_t spread;
+  USED(o);
   spread = cvec_moment (spec, 2);
   if (spread == 0) {
     desc->data[0] = 0.;
@@ -126,6 +129,7 @@
     fvec_t * desc)
 {
   smpl_t spread;
+  USED(o);
   spread = cvec_moment (spec, 2);
   if (spread == 0) {
     desc->data[0] = 0.;
@@ -140,7 +144,8 @@
     fvec_t * desc)
 {
   uint_t j;
-  smpl_t norm = 0, sum = 0.; 
+  smpl_t norm = 0, sum; 
+  USED(o);
   // compute N * sum(j**2) - sum(j)**2
   for (j = 0; j < spec->length; j++) {
     norm += j*j;
@@ -168,6 +173,7 @@
     fvec_t * desc)
 {
   uint_t j; smpl_t sum;
+  USED(o);
   sum = cvec_sum (spec); 
   desc->data[0] = 0;
   if (sum == 0.) {
@@ -186,6 +192,7 @@
     fvec_t *desc)
 {
   uint_t j; smpl_t cumsum, rollsum;
+  USED(o);
   cumsum = 0.; rollsum = 0.;
   for (j = 0; j < spec->length; j++) {
     cumsum += SQR (spec->norm[j]);
--- a/src/synth/wavetable.c
+++ b/src/synth/wavetable.c
@@ -41,7 +41,7 @@
 
 aubio_wavetable_t *new_aubio_wavetable(uint_t samplerate, uint_t blocksize)
 {
-  uint_t i = 0;
+  uint_t i;
   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);
@@ -170,6 +170,7 @@
 uint_t
 aubio_wavetable_load ( aubio_wavetable_t *s UNUSED, const char_t *uri UNUSED)
 {
+  USED(s, uri);
   AUBIO_ERR("wavetable: load method not implemented yet, see sampler\n");
   return AUBIO_FAIL;
 }
--- a/src/tempo/beattracking.c
+++ b/src/tempo/beattracking.c
@@ -60,7 +60,7 @@
 {
 
   aubio_beattracking_t *p = AUBIO_NEW (aubio_beattracking_t);
-  uint_t i = 0;
+  uint_t i;
   /* 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));
@@ -131,9 +131,9 @@
   uint_t step = bt->step;
   uint_t laglen = bt->rwv->length;
   uint_t winlen = bt->dfwv->length;
-  uint_t maxindex = 0;
+  uint_t maxindex;
   //number of harmonics in shift invariant comb filterbank
-  uint_t numelem = 4;
+  uint_t numelem;
 
   smpl_t phase;                 // beat alignment (step - lastbeat)
   smpl_t beat;                  // beat position
@@ -264,7 +264,7 @@
 uint_t
 fvec_gettimesig (fvec_t * acf, uint_t acflen, uint_t gp)
 {
-  sint_t k = 0;
+  sint_t k;
   smpl_t three_energy = 0., four_energy = 0.;
   if (gp < 2) return 4;
   if (acflen > 6 * gp + 2) {
@@ -290,7 +290,7 @@
   sint_t counter = bt->counter;
   uint_t flagstep = bt->flagstep;
   smpl_t gp = bt->gp;
-  smpl_t bp = bt->bp;
+  smpl_t bp;
   smpl_t rp = bt->rp;
   smpl_t rp1 = bt->rp1;
   smpl_t rp2 = bt->rp2;
@@ -355,7 +355,6 @@
     for (j = 0; j < laglen; j++)
       bt->gwv->data[j] =
           EXP (-.5 * SQR ((smpl_t) (j + 1. - gp)) / SQR (bt->g_var));
-    flagconst = 0;
     bp = gp;
     /* flat phase weighting */
     fvec_ones (bt->phwv);
--- a/src/temporal/resampler.c
+++ b/src/temporal/resampler.c
@@ -84,6 +84,7 @@
 aubio_resampler_t *
 new_aubio_resampler (smpl_t ratio UNUSED, uint_t type UNUSED)
 {
+  USED(ratio, type);
   AUBIO_ERR ("aubio was not compiled with libsamplerate\n");
   return NULL;
 }
@@ -91,10 +92,12 @@
 void
 del_aubio_resampler (aubio_resampler_t * s UNUSED)
 {
+  USED(s);
 }
 
 void
 aubio_resampler_do (aubio_resampler_t * s UNUSED, const fvec_t * input UNUSED, fvec_t * output UNUSED)
 {
+  USED(s, input, output);
 }
 #endif /* HAVE_SAMPLERATE */
--- a/src/utils/hist.c
+++ b/src/utils/hist.c
@@ -73,7 +73,7 @@
  */
 void aubio_hist_do (aubio_hist_t *s, fvec_t *input) {
   uint_t j;
-  sint_t tmp = 0;
+  sint_t tmp;
   aubio_scale_do(s->scaler, input);
   /* reset data */
   fvec_zeros(s->hist);
@@ -89,7 +89,7 @@
 
 void aubio_hist_do_notnull (aubio_hist_t *s, fvec_t *input) {
   uint_t j;
-  sint_t tmp = 0;
+  sint_t tmp;
   aubio_scale_do(s->scaler, input);
   /* reset data */
   fvec_zeros(s->hist);
@@ -106,7 +106,7 @@
 
 void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input) {
   uint_t i;
-  sint_t tmp = 0;
+  sint_t tmp;
   smpl_t ilow = fvec_min(input);
   smpl_t ihig = fvec_max(input);
   smpl_t step = (ihig-ilow)/(smpl_t)(s->nelems);
--- a/src/utils/log.c
+++ b/src/utils/log.c
@@ -33,6 +33,7 @@
 aubio_default_log(sint_t level, const char_t *message, void * data UNUSED)
 {
   FILE *out;
+  USED(data);
   out = stdout;
   if (level == AUBIO_LOG_ERR || level == AUBIO_LOG_DBG || level == AUBIO_LOG_WRN) {
     out = stderr;
@@ -44,7 +45,7 @@
 uint_t
 aubio_log(sint_t level, const char_t *fmt, ...)
 {
-  aubio_log_function_t fun = NULL;
+  aubio_log_function_t fun;
 
   va_list args;
   va_start(args, fmt);
@@ -65,7 +66,7 @@
 void
 aubio_log_reset(void)
 {
-  uint_t i = 0;
+  uint_t i;
   for (i = 0; i < AUBIO_LOG_LAST_LEVEL; i++) {
     aubio_log_set_level_function(i, aubio_default_log, NULL);
   }
@@ -85,7 +86,7 @@
 
 void
 aubio_log_set_function(aubio_log_function_t fun, void * data) {
-  uint_t i = 0;
+  uint_t i;
   for (i = 0; i < AUBIO_LOG_LAST_LEVEL; i++) {
     aubio_log_set_level_function(i, fun, data);
   }
--- a/src/utils/scale.c
+++ b/src/utils/scale.c
@@ -59,10 +59,10 @@
   if (inputrange == 0) {
     s->scaler = 0.0;
   } else {
-    s->scaler = outputrange/inputrange;
     if (inputrange < 0) {
       inputrange = inputrange * -1.0f;
     }
+    s->scaler = outputrange/inputrange;
   }
   return AUBIO_OK;
 }