src/fvec.h: clean up fvec api
authorPaul Brossier <piem@piem.org>
Tue, 17 Dec 2013 16:13:28 +0000 (11:13 -0500)
committerPaul Brossier <piem@piem.org>
Tue, 17 Dec 2013 16:13:28 +0000 (11:13 -0500)
examples/aubionotes.c
examples/aubioonset.c
examples/aubiopitch.c
examples/aubiotrack.c
examples/jackio.c
src/fvec.c
src/fvec.h
tests/src/spectral/test-phasevoc-jack.c
tests/src/spectral/test-phasevoc.c

index fd8278e..9b09d0b 100644 (file)
@@ -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;
index a586171..0a3094c 100644 (file)
@@ -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 {
index b86045e..5c046f9 100644 (file)
@@ -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);
index 83bd214..5e1be66 100644 (file)
@@ -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) {
index f4dd554..475471f 100644 (file)
@@ -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 */
index 80a50e3..d0bfbfc 100644 (file)
@@ -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) {
index 7c539d6..a2834dc 100644 (file)
@@ -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 
 
index 3528e13..fd0dd82 100644 (file)
@@ -74,9 +74,9 @@ int aubio_process(float **input, float **output, int nframes) {
   for (j=0;j<(unsigned)nframes;j++) {
     for (i=0;i<channels;i++) {
       /* write input to datanew */
-      fvec_write_sample(in[i], input[i][j], pos);
+      fvec_set_sample(in[i], input[i][j], pos);
       /* put synthnew in output */
-      output[i][j] = fvec_read_sample(out[i], pos);
+      output[i][j] = fvec_get_sample(out[i], pos);
     }
     /*time for fft*/
     if (pos == hop_s-1) {
index 56cd4e4..d4edb23 100644 (file)
@@ -14,7 +14,7 @@ int main ()
   aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s);
 
   // fill input with some data
-  fvec_set (in, 1.);
+  fvec_set_all (in, 1.);
   fvec_print (in);
 
   while ( n-- ) {