shithub: aubio

Download patch

ref: 3cd9fdd51a15939108873471e1235f2d2060dba9
parent: 861784391049edd6b39db2a8479ec7e49c8e7794
author: Paul Brossier <piem@piem.org>
date: Thu Oct 17 09:09:20 EDT 2013

src/fmat.h: fmat_get_channel to write to an fvec_t

--- a/src/fmat.c
+++ b/src/fmat.c
@@ -54,8 +54,10 @@
 void fmat_put_channel(fmat_t *s, smpl_t * data, uint_t channel) {
   s->data[channel] = data;
 }
-smpl_t * fmat_get_channel(fmat_t *s, uint_t channel) {
-  return s->data[channel];
+void fmat_get_channel(fmat_t *s, uint_t channel, fvec_t *output) {
+  output->data = s->data[channel];
+  output->length = s->length;
+  return;
 }
 
 smpl_t ** fmat_get_data(fmat_t *s) {
--- a/src/fmat.h
+++ b/src/fmat.h
@@ -91,7 +91,7 @@
   \param channel channel to read from
 
 */
-smpl_t * fmat_get_channel(fmat_t *s, uint_t channel);
+void fmat_get_channel (fmat_t *s, uint_t channel, fvec_t *output);
 /** write channel vector into a buffer
 
   Note that this function is not used in the aubio library, since the same
--- a/tests/src/test-fmat.c
+++ b/tests/src/test-fmat.c
@@ -17,6 +17,10 @@
       mat->data[i][j] = i * 1. + j *.1;
     }
   }
+  fvec_t channel_onstack;
+  fvec_t *channel = &channel_onstack;
+  fmat_get_channel(mat, 1, channel);
+  fvec_print (channel);
   // print out matrix
   fmat_print(mat);
   // destroy it