ref: d4791e577c6be4a777f0f5067a80eaf7be855422
parent: 89e9e713046f25b3fa8a7db3bb488ce43943652e
parent: 4fe62ba2966e3d5bc55fa10ec9decfc5d702cce3
author: Paul Brossier <[email protected]>
date: Thu Jan 2 14:47:22 EST 2014
Merge branch 'develop' of aubio.org:/git/aubio/aubio into develop
--- a/examples/aubiomfcc.c
+++ b/examples/aubiomfcc.c
@@ -29,8 +29,8 @@
uint_t n_filters = 40;
uint_t n_coefs = 13;
-static void
-process_block(fvec_t *ibuf, fvec_t *obuf) {
+void process_block (fvec_t *ibuf, fvec_t *obuf)
+{
fvec_zeros(obuf);
//compute mag spectrum
aubio_pvoc_do (pv, ibuf, fftgrain);
@@ -38,7 +38,8 @@
aubio_mfcc_do(mfcc, fftgrain, mfcc_out);
}
-static void process_print (void) {
+void process_print (void)
+{
/* output times in seconds and extracted mfccs */
outmsg("%f\t",blocks*hop_size/(float)samplerate);
fvec_print(mfcc_out);
--- a/examples/aubionotes.c
+++ b/examples/aubionotes.c
@@ -45,19 +45,20 @@
void note_append (fvec_t * note_buffer, smpl_t curnote);
uint_t get_note (fvec_t * note_buffer, fvec_t * note_buffer2);
-static void
-process_block(fvec_t *ibuf, fvec_t *obuf) {
+void process_block (fvec_t *ibuf, fvec_t *obuf)
+{
+ smpl_t new_pitch, curlevel;
fvec_zeros(obuf);
aubio_onset_do(o, ibuf, onset);
aubio_pitch_do (pitch, ibuf, pitch_obuf);
- smpl_t new_pitch = fvec_get_sample(pitch_obuf, 0);
+ new_pitch = fvec_get_sample(pitch_obuf, 0);
if(median){
note_append(note_buffer, new_pitch);
}
/* curlevel is negatif or 1 if silence */
- smpl_t curlevel = aubio_level_detection(ibuf, silence_threshold);
+ curlevel = aubio_level_detection(ibuf, silence_threshold);
if (fvec_get_sample(onset, 0)) {
/* test for silence */
if (curlevel == 1.) {
@@ -94,8 +95,8 @@
}
}
-static void
-process_print (void) {
+void process_print (void)
+{
//if (verbose) outmsg("%f\n",pitch_obuf->data[0]);
}
--- a/examples/aubioonset.c
+++ b/examples/aubioonset.c
@@ -29,11 +29,12 @@
fvec_t *onset;
smpl_t is_onset;
-void
-process_block(fvec_t *ibuf, fvec_t *obuf) {
- fvec_zeros(obuf);
+void process_block(fvec_t *ibuf, fvec_t *obuf)
+{
aubio_onset_do (o, ibuf, onset);
is_onset = fvec_get_sample(onset, 0);
+ if ( !usejack && ! sink_uri ) return;
+ fvec_zeros(obuf);
if ( is_onset ) {
aubio_wavetable_play ( wavetable );
} else {
@@ -45,8 +46,7 @@
aubio_wavetable_do (wavetable, obuf, obuf);
}
-void
-process_print (void)
+void process_print (void)
{
if ( is_onset ) {
outmsg ("%f\n", aubio_onset_get_last_s (o) );
--- a/examples/aubiopitch.c
+++ b/examples/aubiopitch.c
@@ -28,14 +28,15 @@
aubio_wavetable_t *wavetable;
fvec_t *pitch;
-void
-process_block(fvec_t * ibuf, fvec_t * obuf) {
- fvec_zeros(obuf);
+void process_block(fvec_t * ibuf, fvec_t * obuf)
+{
+ smpl_t freq;
aubio_pitch_do (o, ibuf, pitch);
- smpl_t freq = fvec_get_sample(pitch, 0);
+ if ( !usejack && ! sink_uri ) return;
+ fvec_zeros(obuf);
+ freq = fvec_get_sample(pitch, 0);
aubio_wavetable_set_amp ( wavetable, aubio_level_lin (ibuf) );
aubio_wavetable_set_freq ( wavetable, freq );
-
if (mix_input)
aubio_wavetable_do (wavetable, ibuf, obuf);
else
@@ -42,8 +43,8 @@
aubio_wavetable_do (wavetable, obuf, obuf);
}
-void
-process_print (void) {
+void process_print (void)
+{
smpl_t pitch_found = fvec_get_sample(pitch, 0);
outmsg("%f %f\n",(blocks)
*hop_size/(float)samplerate, pitch_found);
--- a/examples/aubioquiet.c
+++ b/examples/aubioquiet.c
@@ -36,7 +36,7 @@
}
}
-static void process_print (void) {
+void process_print (void) {
int curblocks = (blocks - 4) > 0 ? blocks - 4 : 0;
if (issilence == -1) {
outmsg("NOISY: %f\n",curblocks*hop_size/(float)samplerate);
--- a/examples/aubiotrack.c
+++ b/examples/aubiotrack.c
@@ -35,6 +35,7 @@
is_beat = fvec_get_sample (tempo_out, 0);
if (silence_threshold != -90.)
is_silence = aubio_silence_detection(ibuf, silence_threshold);
+ if ( !usejack && ! sink_uri ) return;
fvec_zeros (obuf);
if ( is_beat && !is_silence ) {
aubio_wavetable_play ( wavetable );
--- a/examples/parse_args.h
+++ b/examples/parse_args.h
@@ -47,6 +47,7 @@
extern void examples_common_del (void);
extern void examples_common_process (aubio_process_func_t process_func,
aubio_print_func_t print);
+int parse_args (int argc, char **argv);
// internal stuff
extern int blocks;
@@ -56,8 +57,9 @@
const char *prog_name;
-void
-usage (FILE * stream, int exit_code)
+void usage (FILE * stream, int exit_code);
+
+void usage (FILE * stream, int exit_code)
{
fprintf (stream, "usage: %s [ options ] \n", prog_name);
fprintf (stream,
--- a/examples/utils.c
+++ b/examples/utils.c
@@ -72,8 +72,12 @@
aubio_jack_t *jack_setup;
#endif
-void
-examples_common_init (int argc, char **argv)
+void examples_common_init (int argc, char **argv);
+void examples_common_del (void);
+void examples_common_process (aubio_process_func_t process_func,
+ aubio_print_func_t print);
+
+void examples_common_init (int argc, char **argv)
{
/* parse command line arguments */
@@ -115,8 +119,7 @@
}
-void
-examples_common_del (void)
+void examples_common_del (void)
{
del_fvec (ibuf);
del_fvec (obuf);
@@ -125,8 +128,7 @@
fflush(stdout);
}
-void
-examples_common_process (aubio_process_func_t process_func,
+void examples_common_process (aubio_process_func_t process_func,
aubio_print_func_t print)
{
@@ -145,9 +147,9 @@
#endif
} else {
- /* phasevoc */
- blocks = 0;
+
uint_t total_read = 0;
+ blocks = 0;
do {
aubio_source_do (this_source, ibuf, &read);
--- a/examples/utils.h
+++ b/examples/utils.h
@@ -41,7 +41,7 @@
#ifdef HAVE_DEBUG
#define debug(...) fprintf (stderr, format , **args)
#else
-#define debug(...) ()
+#define debug(...)
#endif
#define verbmsg(format, args...) if (verbose) fprintf(stderr, format , ##args)
#define errmsg(format, args...) fprintf(stderr, format , ##args)
@@ -53,3 +53,6 @@
/** common process function */
typedef int (*aubio_process_func_t) (fvec_t * input, fvec_t * output);
+
+void process_block (fvec_t *ibuf, fvec_t *obuf);
+void process_print (void);
--- a/src/aubio_priv.h
+++ b/src/aubio_priv.h
@@ -33,9 +33,7 @@
*
*/
-#if 1 //HAVE_CONFIG_H
#include "config.h"
-#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
@@ -46,23 +44,23 @@
#endif
/* must be included before fftw3.h */
-#if HAVE_COMPLEX_H
+#ifdef HAVE_COMPLEX_H
#include <complex.h>
#endif
-#if HAVE_FFTW3 || HAVE_FFTW3F
+#if defined(HAVE_FFTW3) || defined(HAVE_FFTW3F)
#include <fftw3.h>
#endif
-#if HAVE_MATH_H
+#ifdef HAVE_MATH_H
#include <math.h>
#endif
-#if HAVE_STRING_H
+#ifdef HAVE_STRING_H
#include <string.h>
#endif
-#if HAVE_LIMITS_H
+#ifdef HAVE_LIMITS_H
#include <limits.h> // for CHAR_BIT, in C99 standard
#endif
--- 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/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -61,6 +61,7 @@
// hack to create or re-create the context the first time _do or _do_multi is called
void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi);
+void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples);
aubio_source_avcodec_t * new_aubio_source_avcodec(char_t * path, uint_t samplerate, uint_t hop_size) {
aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t);
@@ -278,7 +279,7 @@
(uint8_t **)&output, out_linesize, max_out_samples,
(uint8_t **)avFrame->data, in_linesize, in_samples);
if (out_samples <= 0) {
- AUBIO_ERR("No sample found while converting frame (%s)\n", s->path);
+ //AUBIO_ERR("No sample found while converting frame (%s)\n", s->path);
goto beach;
}
--- a/src/io/source_sndfile.c
+++ b/src/io/source_sndfile.c
@@ -63,6 +63,7 @@
aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplerate, uint_t hop_size) {
aubio_source_sndfile_t * s = AUBIO_NEW(aubio_source_sndfile_t);
+ SF_INFO sfinfo;
if (path == NULL) {
AUBIO_ERR("Aborted opening null path\n");
@@ -82,7 +83,6 @@
s->path = path;
// try opening the file, getting the info in sfinfo
- SF_INFO sfinfo;
AUBIO_MEMSET(&sfinfo, 0, sizeof (sfinfo));
s->handle = sf_open (s->path, SFM_READ, &sfinfo);
--- 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;
@@ -36,9 +37,10 @@
AUBIO_FREE(s);
}
-void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t position) {
+void lvec_set_sample(lvec_t *s, lsmp_t data, uint_t position) {
s->data[position] = data;
}
+
lsmp_t lvec_get_sample(lvec_t *s, uint_t position) {
return s->data[position];
}
--- 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;
@@ -416,10 +417,10 @@
}
smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) {
- smpl_t s0, s1, s2;
+ smpl_t s0, s1, s2; uint_t x0, x2;
if (pos == 0 || pos == x->length - 1) return pos;
- uint_t x0 = (pos < 1) ? pos : pos - 1;
- uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
+ x0 = (pos < 1) ? pos : pos - 1;
+ x2 = (pos + 1 < x->length) ? pos + 1 : pos;
if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2;
if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0;
s0 = x->data[x0];
@@ -447,9 +448,10 @@
smpl_t
aubio_freqtomidi (smpl_t freq)
{
+ smpl_t midi;
if (freq < 2. || freq > 100000.) return 0.; // avoid nans and infs
/* log(freq/A-2)/log(2) */
- smpl_t midi = freq / 6.875;
+ midi = freq / 6.875;
midi = LOG (midi) / 0.69314718055995;
midi *= 12;
midi -= 3;
@@ -459,8 +461,9 @@
smpl_t
aubio_miditofreq (smpl_t midi)
{
+ smpl_t freq;
if (midi > 140.) return 0.; // avoid infs
- smpl_t freq = (midi + 3.) / 12.;
+ freq = (midi + 3.) / 12.;
freq = EXP (freq * 0.69314718055995);
freq *= 6.875;
return freq;
--- a/src/onset/peakpicker.c
+++ b/src/onset/peakpicker.c
@@ -165,7 +165,7 @@
}
aubio_peakpicker_t *
-new_aubio_peakpicker ()
+new_aubio_peakpicker (void)
{
aubio_peakpicker_t *t = AUBIO_NEW (aubio_peakpicker_t);
t->threshold = 0.1; /* 0.0668; 0.33; 0.082; 0.033; */
--- 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/spectral/filterbank_mel.c
+++ b/src/spectral/filterbank_mel.c
@@ -24,6 +24,7 @@
#include "fvec.h"
#include "cvec.h"
#include "spectral/filterbank.h"
+#include "spectral/filterbank_mel.h"
#include "mathutils.h"
uint_t
@@ -33,10 +34,14 @@
fmat_t *filters = aubio_filterbank_get_coeffs (fb);
uint_t n_filters = filters->height, win_s = filters->length;
+ fvec_t *lower_freqs, *upper_freqs, *center_freqs;
+ fvec_t *triangle_heights, *fft_freqs;
uint_t fn; /* filter counter */
uint_t bin; /* bin counter */
+ smpl_t riseInc, downInc;
+
/* freqs define the bands of triangular overlapping windows.
throw a warning if filterbank object fb is too short. */
if (freqs->length - 2 > n_filters) {
@@ -55,15 +60,15 @@
}
/* convenience reference to lower/center/upper frequency for each triangle */
- fvec_t *lower_freqs = new_fvec (n_filters);
- fvec_t *upper_freqs = new_fvec (n_filters);
- fvec_t *center_freqs = new_fvec (n_filters);
+ lower_freqs = new_fvec (n_filters);
+ upper_freqs = new_fvec (n_filters);
+ center_freqs = new_fvec (n_filters);
/* height of each triangle */
- fvec_t *triangle_heights = new_fvec (n_filters);
+ triangle_heights = new_fvec (n_filters);
/* lookup table of each bin frequency in hz */
- fvec_t *fft_freqs = new_fvec (win_s);
+ fft_freqs = new_fvec (win_s);
/* fill up the lower/center/upper */
for (fn = 0; fn < n_filters; fn++) {
@@ -111,7 +116,7 @@
}
/* compute positive slope step size */
- smpl_t riseInc =
+ riseInc =
triangle_heights->data[fn] /
(center_freqs->data[fn] - lower_freqs->data[fn]);
@@ -127,7 +132,7 @@
}
/* compute negative slope step size */
- smpl_t downInc =
+ downInc =
triangle_heights->data[fn] /
(upper_freqs->data[fn] - center_freqs->data[fn]);
@@ -175,6 +180,8 @@
uint_t fn; /* filter counter */
+ smpl_t lastlinearCF;
+
/* buffers to compute filter frequencies */
fvec_t *freqs = new_fvec (n_filters + 2);
@@ -182,7 +189,7 @@
for (fn = 0; fn < linearFilters; fn++) {
freqs->data[fn] = lowestFrequency + fn * linearSpacing;
}
- smpl_t lastlinearCF = freqs->data[fn - 1];
+ lastlinearCF = freqs->data[fn - 1];
/* second step: fill all the log filter frequencies */
for (fn = 0; fn < logFilters + 2; fn++) {
--- a/src/spectral/mfcc.c
+++ b/src/spectral/mfcc.c
@@ -51,6 +51,7 @@
/* allocate space for mfcc object */
aubio_mfcc_t *mfcc = AUBIO_NEW (aubio_mfcc_t);
+ smpl_t scaling;
uint_t i, j;
@@ -70,7 +71,7 @@
/* compute DCT transform dct_coeffs[i][j] as
cos ( j * (i+.5) * PI / n_filters ) */
- smpl_t scaling = 1. / SQRT (n_filters / 2.);
+ scaling = 1. / SQRT (n_filters / 2.);
for (i = 0; i < n_filters; i++) {
for (j = 0; j < n_coefs; j++) {
mfcc->dct_coeffs->data[i][j] =
--- a/src/spectral/ooura_fft8g.c
+++ b/src/spectral/ooura_fft8g.c
@@ -1,8 +1,28 @@
-// 2 modifications made for aubio:
+// modifications made for aubio:
// - replace all 'double' with 'smpl_t'
// - include "aubio_priv.h" (for config.h and types.h)
+// - add missing prototypes
#include "aubio_priv.h"
+
+void cdft(int n, int isgn, smpl_t *a, int *ip, smpl_t *w);
+void rdft(int n, int isgn, smpl_t *a, int *ip, smpl_t *w);
+void ddct(int n, int isgn, smpl_t *a, int *ip, smpl_t *w);
+void ddst(int n, int isgn, smpl_t *a, int *ip, smpl_t *w);
+void dfct(int n, smpl_t *a, smpl_t *t, int *ip, smpl_t *w);
+void 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 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);
+void cft1st(int n, smpl_t *a, smpl_t *w);
+void cftmdl(int n, int l, 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);
+void dstsub(int n, smpl_t *a, int nc, smpl_t *c);
/*
Fast Fourier/Cosine/Sine Transform
--- a/src/spectral/phasevoc.c
+++ b/src/spectral/phasevoc.c
@@ -119,6 +119,7 @@
static void aubio_pvoc_swapbuffers(smpl_t * data, smpl_t * dataold,
const smpl_t * datanew, uint_t win_s, uint_t hop_s)
{
+#if !HAVE_MEMCPY_HACKS
uint_t i;
for (i = 0; i < win_s - hop_s; i++)
data[i] = dataold[i];
@@ -126,6 +127,14 @@
data[win_s - hop_s + i] = datanew[i];
for (i = 0; i < win_s - hop_s; i++)
dataold[i] = data[i + hop_s];
+#else
+ memcpy(data, dataold, (win_s - hop_s) * sizeof(smpl_t));
+ data += win_s - hop_s;
+ memcpy(data, datanew, hop_s * sizeof(smpl_t));
+ data -= win_s - hop_s;
+ data += hop_s;
+ memcpy(dataold, data, (win_s - hop_s) * sizeof(smpl_t));
+#endif
}
static void aubio_pvoc_addsynth(const smpl_t * synth, smpl_t * synthold,
--- a/src/spectral/statistics.c
+++ b/src/spectral/statistics.c
@@ -22,6 +22,27 @@
#include "cvec.h"
#include "spectral/specdesc.h"
+void aubio_specdesc_centroid (aubio_specdesc_t * o, cvec_t * spec,
+ fvec_t * desc);
+void aubio_specdesc_spread (aubio_specdesc_t * o, cvec_t * spec,
+ fvec_t * desc);
+void aubio_specdesc_skewness (aubio_specdesc_t * o, cvec_t * spec,
+ fvec_t * desc);
+void aubio_specdesc_kurtosis (aubio_specdesc_t * o, cvec_t * spec,
+ fvec_t * desc);
+void aubio_specdesc_slope (aubio_specdesc_t * o, cvec_t * spec,
+ fvec_t * desc);
+void aubio_specdesc_decrease (aubio_specdesc_t * o, cvec_t * spec,
+ fvec_t * desc);
+void aubio_specdesc_rolloff (aubio_specdesc_t * o, cvec_t * spec,
+ fvec_t * desc);
+
+
+smpl_t cvec_sum (cvec_t * s);
+smpl_t cvec_mean (cvec_t * s);
+smpl_t cvec_centroid (cvec_t * s);
+smpl_t cvec_moment (cvec_t * s, uint_t moment);
+
smpl_t
cvec_sum (cvec_t * s)
{
--- 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/tempo/tempo.c
+++ b/src/tempo/tempo.c
@@ -28,6 +28,27 @@
#include "mathutils.h"
#include "tempo/tempo.h"
+// TODO implement get/set_delay
+
+/** set current delay
+
+ \param o beat tracking object
+
+ \return current delay, in samples
+
+ */
+uint_t aubio_tempo_get_delay(aubio_tempo_t * o);
+
+/** set current delay
+
+ \param o beat tracking object
+ \param delay delay to set tempo to, in samples
+
+ \return `0` if successful, non-zero otherwise
+
+ */
+uint_t aubio_tempo_set_delay(aubio_tempo_t * o, uint_t delay);
+
/* structure to store object state */
struct _aubio_tempo_t {
aubio_specdesc_t * od; /** onset detection */
--- 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/biquad.c
+++ b/src/temporal/biquad.c
@@ -22,6 +22,7 @@
#include "fvec.h"
#include "lvec.h"
#include "temporal/filter.h"
+#include "temporal/biquad.h"
uint_t
aubio_filter_set_biquad (aubio_filter_t * f, lsmp_t b0, lsmp_t b1, lsmp_t b2,
--- 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);
--- a/tests/src/onset/test-peakpicker.c
+++ b/tests/src/onset/test-peakpicker.c
@@ -2,7 +2,7 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t win_s = 1024; // window size
fvec_t * in = new_fvec (win_s); // input buffer
--- a/tests/src/pitch/test-pitch.c
+++ b/tests/src/pitch/test-pitch.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
// 1. allocate some memory
uint_t n = 0; // frame counter
--- a/tests/src/pitch/test-pitchfcomb.c
+++ b/tests/src/pitch/test-pitchfcomb.c
@@ -5,7 +5,7 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t i = 0;
uint_t win_s = 1024; // window size
--- a/tests/src/pitch/test-pitchmcomb.c
+++ b/tests/src/pitch/test-pitchmcomb.c
@@ -5,7 +5,7 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t n = 10; // compute n times
uint_t win_s = 1024; // window size
--- a/tests/src/pitch/test-pitchschmitt.c
+++ b/tests/src/pitch/test-pitchschmitt.c
@@ -5,7 +5,7 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t n = 10; // compute n times
uint_t win_s = 1024; // window size
--- a/tests/src/pitch/test-pitchspecacf.c
+++ b/tests/src/pitch/test-pitchspecacf.c
@@ -5,7 +5,7 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t n = 10; // compute n times
uint_t win_s = 1024; // window size
--- a/tests/src/pitch/test-pitchyin.c
+++ b/tests/src/pitch/test-pitchyin.c
@@ -5,7 +5,7 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t n = 10; // compute n times
uint_t win_s = 1024; // window size
--- a/tests/src/pitch/test-pitchyinfft.c
+++ b/tests/src/pitch/test-pitchyinfft.c
@@ -5,7 +5,7 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t n = 10; // compute n times
uint_t win_s = 1024; // window size
--- a/tests/src/spectral/test-fft.c
+++ b/tests/src/spectral/test-fft.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t win_s = 8; // window size
fvec_t * in = new_fvec (win_s); // input buffer
--- a/tests/src/spectral/test-filterbank.c
+++ b/tests/src/spectral/test-filterbank.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t win_s = 1024; // window size
uint_t n_filters = 13; // number of filters
--- a/tests/src/spectral/test-filterbank_mel.c
+++ b/tests/src/spectral/test-filterbank_mel.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t samplerate = 16000; // samplerate of signal to filter
uint_t win_s = 512; // fft size
--- a/tests/src/spectral/test-mfcc.c
+++ b/tests/src/spectral/test-mfcc.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t win_s = 512; // fft size
uint_t n_filters = 40; // number of filters
--- a/tests/src/spectral/test-phasevoc.c
+++ b/tests/src/spectral/test-phasevoc.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t n = 6; // compute n times
uint_t win_s = 32; // window size
--- a/tests/src/spectral/test-specdesc.c
+++ b/tests/src/spectral/test-specdesc.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t win_s = 1024; // window size
cvec_t *in = new_cvec (win_s); // input buffer
--- a/tests/src/spectral/test-tss.c
+++ b/tests/src/spectral/test-tss.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t n = 10; // compute n times
uint_t win_s = 1024; // window size
--- a/tests/src/tempo/test-beattracking.c
+++ b/tests/src/tempo/test-beattracking.c
@@ -3,7 +3,7 @@
#include <aubio.h>
#include <stdio.h>
-int main ()
+int main (void)
{
uint_t i = 0;
uint_t win_s = 1024; // window size
--- a/tests/src/temporal/test-a_weighting.c
+++ b/tests/src/temporal/test-a_weighting.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
aubio_filter_t * f;
--- a/tests/src/temporal/test-biquad.c
+++ b/tests/src/temporal/test-biquad.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t win_s = 64; // window size
--- a/tests/src/temporal/test-c_weighting.c
+++ b/tests/src/temporal/test-c_weighting.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
aubio_filter_t * f;
--- a/tests/src/temporal/test-filter.c
+++ b/tests/src/temporal/test-filter.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t win_s = 16; // window size
uint_t impulse_at = win_s / 2;
--- a/tests/src/temporal/test-resampler.c
+++ b/tests/src/temporal/test-resampler.c
@@ -1,6 +1,6 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t win_s = 1024; // window size
smpl_t ratio = 0.5;
--- a/tests/src/test-cvec.c
+++ b/tests/src/test-cvec.c
@@ -1,7 +1,7 @@
#include <aubio.h>
#include "utils_tests.h"
-int main ()
+int main (void)
{
uint_t i, window_size = 16; // window size
utils_init_random();
--- a/tests/src/test-delnull.c
+++ b/tests/src/test-delnull.c
@@ -4,7 +4,7 @@
// Because aubio does not check for double free, this program will crash.
// Programs that call these functions should check for null pointers.
-int main ()
+int main (void)
{
del_fvec(NULL);
del_lvec(NULL);
--- a/tests/src/test-fmat.c
+++ b/tests/src/test-fmat.c
@@ -4,7 +4,7 @@
// create a new matrix and fill it with i * 1. + j * .1, where i is the row,
// and j the column.
-int main ()
+int main (void)
{
uint_t height = 3, length = 9, i, j;
// create fmat_t object
--- a/tests/src/test-fvec.c
+++ b/tests/src/test-fvec.c
@@ -1,7 +1,7 @@
#include <aubio.h>
#include <assert.h>
-int main ()
+int main (void)
{
uint_t vec_size = 10, i;
fvec_t * vec = new_fvec (vec_size);
--- a/tests/src/test-lvec.c
+++ b/tests/src/test-lvec.c
@@ -1,9 +1,17 @@
#include <aubio.h>
+#include "utils_tests.h"
-int main()
+int main (void)
{
- uint_t win_s = 1024; // window size
+ uint_t win_s = 32; // window size
lvec_t * sp = new_lvec (win_s); // input buffer
+ lvec_set_sample (sp, 2./3., 0);
+ PRINT_MSG("%lf\n", lvec_get_sample (sp, 0));
+ lvec_print (sp);
+ lvec_ones (sp);
+ lvec_print (sp);
+ lvec_set_all (sp, 3./5.);
+ lvec_print (sp);
del_lvec(sp);
return 0;
}
--- a/tests/src/test-mathutils-window.c
+++ b/tests/src/test-mathutils-window.c
@@ -2,7 +2,7 @@
#include <math.h>
#include <stdio.h>
-int main ()
+int main (void)
{
uint_t length = 0;
uint_t n_length = 4, n_types = 10, i, t;
--- a/tests/src/test-mathutils.c
+++ b/tests/src/test-mathutils.c
@@ -3,7 +3,12 @@
#define AUBIO_UNSTABLE 1
#include <aubio.h>
-int test_next_power_of_two()
+int test_next_power_of_two (void);
+int test_miditofreq (void);
+int test_freqtomidi (void);
+int test_aubio_window (void);
+
+int test_next_power_of_two (void)
{
uint_t a, b;
a = 15; b = aubio_next_power_of_two(a); assert(b == 16);
@@ -24,7 +29,7 @@
return 0;
}
-int test_miditofreq()
+int test_miditofreq (void)
{
smpl_t a, b;
fprintf(stdout, "b = aubio_miditofreq(a): [");
@@ -55,7 +60,7 @@
return 0;
}
-int test_freqtomidi()
+int test_freqtomidi (void)
{
smpl_t midi, freq;
fprintf(stdout, "b = aubio_freqtomidi(a): [");
@@ -87,7 +92,7 @@
return 0;
}
-int test_aubio_window()
+int test_aubio_window (void)
{
uint_t window_size = 16;
fvec_t * window = new_aubio_window("default", window_size);
@@ -107,7 +112,7 @@
return 0;
}
-int main ()
+int main (void)
{
test_next_power_of_two();
test_miditofreq();
--- a/tests/src/utils/test-hist.c
+++ b/tests/src/utils/test-hist.c
@@ -2,7 +2,7 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t length;
for (length = 1; length < 10; length ++ ) {
--- a/tests/src/utils/test-parameter.c
+++ b/tests/src/utils/test-parameter.c
@@ -1,6 +1,8 @@
#include <aubio.h>
#include "utils_tests.h"
+void get_some_steps ( aubio_parameter_t * param );
+
void get_some_steps ( aubio_parameter_t * param )
{
uint_t i = 0;
@@ -20,7 +22,7 @@
}
-int main ()
+int main (void)
{
smpl_t max_value = 100.;
smpl_t min_value = 0.;
--- a/tests/src/utils/test-scale.c
+++ b/tests/src/utils/test-scale.c
@@ -2,7 +2,7 @@
#include <aubio.h>
-int main ()
+int main (void)
{
uint_t n = 0;
uint_t win_s = 1024; // window size
--- a/tests/utils_tests.h
+++ b/tests/utils_tests.h
@@ -26,7 +26,9 @@
}
#endif
-void utils_init_random () {
+void utils_init_random (void);
+
+void utils_init_random (void) {
time_t now = time(0);
struct tm *tm_struct = localtime(&now);
int seed = tm_struct->tm_sec;
--- a/wscript
+++ b/wscript
@@ -85,13 +85,16 @@
ctx.load('waf_unit_test')
ctx.load('gnu_dirs')
- ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
-
target_platform = Options.platform
if ctx.options.target_platform:
target_platform = ctx.options.target_platform
ctx.env['DEST_OS'] = target_platform
+ if 'CL.exe' not in ctx.env.CC[0]:
+ ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
+ else:
+ ctx.env.CFLAGS += ['-Wall']
+
if target_platform not in ['win32', 'win64']:
ctx.env.CFLAGS += ['-fPIC']
else:
@@ -151,7 +154,8 @@
if ctx.check_cc(fragment = check_c99_varargs,
type='cstlib',
- msg = 'Checking for C99 __VA_ARGS__ macro'):
+ msg = 'Checking for C99 __VA_ARGS__ macro',
+ mandatory = False):
ctx.define('HAVE_C99_VARARGS_MACROS', 1)
# double precision mode