From 3cd9fdd51a15939108873471e1235f2d2060dba9 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Thu, 17 Oct 2013 13:09:20 +0200 Subject: [PATCH] src/fmat.h: fmat_get_channel to write to an fvec_t --- src/fmat.c | 6 ++++-- src/fmat.h | 2 +- tests/src/test-fmat.c | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/fmat.c b/src/fmat.c index a92b8c6e..a6d8931a 100644 --- a/src/fmat.c +++ b/src/fmat.c @@ -54,8 +54,10 @@ smpl_t fmat_read_sample(fmat_t *s, uint_t channel, uint_t position) { 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) { diff --git a/src/fmat.h b/src/fmat.h index 4c52a844..9fbb198a 100644 --- a/src/fmat.h +++ b/src/fmat.h @@ -91,7 +91,7 @@ void fmat_write_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position) \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 diff --git a/tests/src/test-fmat.c b/tests/src/test-fmat.c index edb3fcf4..3de04613 100644 --- a/tests/src/test-fmat.c +++ b/tests/src/test-fmat.c @@ -17,6 +17,10 @@ int main () 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 -- 2.11.0