From: Paul Brossier Date: Tue, 17 Dec 2013 16:13:28 +0000 (-0500) Subject: src/fvec.h: clean up fvec api X-Git-Tag: 0.4.0~11 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=c34336ecfd4d5bd0740d7cddf0a76eeb7910f3ba;p=aubio.git src/fvec.h: clean up fvec api --- diff --git a/examples/aubionotes.c b/examples/aubionotes.c index fd8278e0..9b09d0b4 100644 --- a/examples/aubionotes.c +++ b/examples/aubionotes.c @@ -51,14 +51,14 @@ process_block(fvec_t *ibuf, fvec_t *obuf) { aubio_onset_do(o, ibuf, onset); aubio_pitch_do (pitch, ibuf, pitch_obuf); - smpl_t new_pitch = fvec_read_sample(pitch_obuf, 0); + smpl_t 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); - if (fvec_read_sample(onset, 0)) { + if (fvec_get_sample(onset, 0)) { /* test for silence */ if (curlevel == 1.) { if (median) isready = 0; diff --git a/examples/aubioonset.c b/examples/aubioonset.c index a5861713..0a3094cf 100644 --- a/examples/aubioonset.c +++ b/examples/aubioonset.c @@ -33,7 +33,7 @@ void process_block(fvec_t *ibuf, fvec_t *obuf) { fvec_zeros(obuf); aubio_onset_do (o, ibuf, onset); - is_onset = fvec_read_sample(onset, 0); + is_onset = fvec_get_sample(onset, 0); if ( is_onset ) { aubio_wavetable_play ( wavetable ); } else { diff --git a/examples/aubiopitch.c b/examples/aubiopitch.c index b86045e7..5c046f91 100644 --- a/examples/aubiopitch.c +++ b/examples/aubiopitch.c @@ -32,7 +32,7 @@ void process_block(fvec_t * ibuf, fvec_t * obuf) { fvec_zeros(obuf); aubio_pitch_do (o, ibuf, pitch); - smpl_t freq = fvec_read_sample(pitch, 0); + smpl_t freq = fvec_get_sample(pitch, 0); aubio_wavetable_set_amp ( wavetable, aubio_level_lin (ibuf) ); aubio_wavetable_set_freq ( wavetable, freq ); @@ -44,7 +44,7 @@ process_block(fvec_t * ibuf, fvec_t * obuf) { void process_print (void) { - smpl_t pitch_found = fvec_read_sample(pitch, 0); + smpl_t pitch_found = fvec_get_sample(pitch, 0); outmsg("%f %f\n",(blocks) *hop_size/(float)samplerate, pitch_found); } @@ -69,6 +69,7 @@ int main(int argc, char **argv) { aubio_pitch_set_silence (o, silence_threshold); if (pitch_unit != NULL) aubio_pitch_set_unit (o, pitch_unit); + pitch = new_fvec (1); wavetable = new_aubio_wavetable (samplerate, hop_size); diff --git a/examples/aubiotrack.c b/examples/aubiotrack.c index 83bd214d..5e1be664 100644 --- a/examples/aubiotrack.c +++ b/examples/aubiotrack.c @@ -28,13 +28,11 @@ aubio_tempo_t * tempo; aubio_wavetable_t *wavetable; fvec_t * tempo_out; smpl_t is_beat = 0; -smpl_t is_onset = 0; uint_t is_silence = 0.; void process_block(fvec_t * ibuf, fvec_t *obuf) { aubio_tempo_do (tempo, ibuf, tempo_out); - is_beat = fvec_read_sample (tempo_out, 0); - is_onset = fvec_read_sample (tempo_out, 1); + is_beat = fvec_get_sample (tempo_out, 0); if (silence_threshold != -90.) is_silence = aubio_silence_detection(ibuf, silence_threshold); fvec_zeros (obuf); @@ -53,8 +51,6 @@ void process_print (void) { if ( is_beat && !is_silence ) { outmsg("%f\n", aubio_tempo_get_last_s(tempo) ); } - //if ( is_onset ) - // outmsg(" \t \t%f\n",(blocks)*hop_size/(float)samplerate); } int main(int argc, char **argv) { diff --git a/examples/jackio.c b/examples/jackio.c index f4dd554e..475471fd 100644 --- a/examples/jackio.c +++ b/examples/jackio.c @@ -252,9 +252,9 @@ static int block_process(aubio_jack_t *dev, unsigned int j; /*frames*/ for (j=0;j<(unsigned)nframes;j++) { /* put synthnew in output */ - output[0][j] = fvec_read_sample(dev->obuf, dev->pos); + output[0][j] = fvec_get_sample(dev->obuf, dev->pos); /* write input to datanew */ - fvec_write_sample(dev->ibuf, input[0][j], dev->pos); + fvec_set_sample(dev->ibuf, input[0][j], dev->pos); /*time for fft*/ if (dev->pos == (int)(dev->hop_size) - 1) { /* block loop */ diff --git a/src/fvec.c b/src/fvec.c index 80a50e33..d0bfbfcd 100644 --- a/src/fvec.c +++ b/src/fvec.c @@ -36,11 +36,11 @@ void del_fvec(fvec_t *s) { AUBIO_FREE(s); } -void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position) { +void fvec_set_sample(fvec_t *s, smpl_t data, uint_t position) { s->data[position] = data; } -smpl_t fvec_read_sample(fvec_t *s, uint_t position) { +smpl_t fvec_get_sample(fvec_t *s, uint_t position) { return s->data[position]; } @@ -58,7 +58,7 @@ void fvec_print(fvec_t *s) { AUBIO_MSG("\n"); } -void fvec_set(fvec_t *s, smpl_t val) { +void fvec_set_all (fvec_t *s, smpl_t val) { uint_t j; for (j=0; j< s->length; j++) { s->data[j] = val; @@ -69,12 +69,12 @@ void fvec_zeros(fvec_t *s) { #if HAVE_MEMCPY_HACKS memset(s->data, 0, s->length * sizeof(smpl_t)); #else - fvec_set(s, 0.); + fvec_set_all (s, 0.); #endif } void fvec_ones(fvec_t *s) { - fvec_set(s, 1.); + fvec_set_all (s, 1.); } void fvec_rev(fvec_t *s) { diff --git a/src/fvec.h b/src/fvec.h index 7c539d6f..a2834dcc 100644 --- a/src/fvec.h +++ b/src/fvec.h @@ -75,12 +75,14 @@ typedef struct { */ fvec_t * new_fvec(uint_t length); + /** fvec_t buffer deletion function \param s buffer to delete as returned by new_fvec() */ void del_fvec(fvec_t *s); + /** read sample value in a buffer Note that this function is not used in the aubio library, since the same @@ -91,7 +93,8 @@ void del_fvec(fvec_t *s); \param position sample position to read from */ -smpl_t fvec_read_sample(fvec_t *s, uint_t position); +smpl_t fvec_get_sample(fvec_t *s, uint_t position); + /** write sample value in a buffer Note that this function is not used in the aubio library, since the same @@ -103,7 +106,7 @@ smpl_t fvec_read_sample(fvec_t *s, uint_t position); \param position sample position to write to */ -void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position); +void fvec_set_sample(fvec_t *s, smpl_t data, uint_t position); /** read data from a buffer @@ -129,7 +132,7 @@ void fvec_print(fvec_t *s); \param val value to set elements to */ -void fvec_set(fvec_t *s, smpl_t val); +void fvec_set_all (fvec_t *s, smpl_t val); /** set all elements to zero diff --git a/tests/src/spectral/test-phasevoc-jack.c b/tests/src/spectral/test-phasevoc-jack.c index 3528e139..fd0dd823 100644 --- a/tests/src/spectral/test-phasevoc-jack.c +++ b/tests/src/spectral/test-phasevoc-jack.c @@ -74,9 +74,9 @@ int aubio_process(float **input, float **output, int nframes) { for (j=0;j<(unsigned)nframes;j++) { for (i=0;i