ref: 5d10ac1882948152e9628c6fea144137274d607c
parent: b0ab6ef84ecb8153d792ce649c27d9e74ad965da
author: Paul Brossier <[email protected]>
date: Tue Dec 17 06:11:35 EST 2013
src/cvec.h: clean up cvec api
--- a/src/cvec.c
+++ b/src/cvec.c
@@ -38,22 +38,27 @@
AUBIO_FREE(s);
}
-void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position) {
+void cvec_norm_set_sample (cvec_t *s, smpl_t data, uint_t position) {
s->norm[position] = data;
}
-void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position) {
+
+void cvec_phas_set_sample (cvec_t *s, smpl_t data, uint_t position) {
s->phas[position] = data;
}
-smpl_t cvec_read_norm(cvec_t *s, uint_t position) {
+
+smpl_t cvec_norm_get_sample (cvec_t *s, uint_t position) {
return s->norm[position];
}
-smpl_t cvec_read_phas(cvec_t *s, uint_t position) {
+
+smpl_t cvec_phas_get_sample (cvec_t *s, uint_t position) {
return s->phas[position];
}
-smpl_t * cvec_get_norm(cvec_t *s) {
+
+smpl_t * cvec_norm_get_data (cvec_t *s) {
return s->norm;
}
-smpl_t * cvec_get_phas(cvec_t *s) {
+
+smpl_t * cvec_phas_get_data (cvec_t *s) {
return s->phas;
}
@@ -91,7 +96,7 @@
#endif
}
-void cvec_set_all_norm(cvec_t *s, smpl_t val) {
+void cvec_norm_set_all (cvec_t *s, smpl_t val) {
uint_t j;
for (j=0; j< s->length; j++) {
s->norm[j] = val;
@@ -98,19 +103,19 @@
}
}
-void cvec_zeros_norm(cvec_t *s) {
+void cvec_norm_zeros(cvec_t *s) {
#if HAVE_MEMCPY_HACKS
memset(s->norm, 0, s->length * sizeof(smpl_t));
#else
- cvec_set_all_norm(s, 0.);
+ cvec_norm_set_all (s, 0.);
#endif
}
-void cvec_ones_norm(cvec_t *s) {
- cvec_set_all_norm(s, 1.);
+void cvec_norm_ones(cvec_t *s) {
+ cvec_norm_set_all (s, 1.);
}
-void cvec_set_all_phas(cvec_t *s, smpl_t val) {
+void cvec_phas_set_all (cvec_t *s, smpl_t val) {
uint_t j;
for (j=0; j< s->length; j++) {
s->phas[j] = val;
@@ -117,19 +122,19 @@
}
}
-void cvec_zeros_phas(cvec_t *s) {
+void cvec_phas_zeros(cvec_t *s) {
#if HAVE_MEMCPY_HACKS
memset(s->phas, 0, s->length * sizeof(smpl_t));
#else
- cvec_set_all_phas(s, 0.);
+ cvec_phas_set_all (s, 0.);
#endif
}
-void cvec_ones_phas(cvec_t *s) {
- cvec_set_all_phas(s, 1.);
+void cvec_phas_ones(cvec_t *s) {
+ cvec_phas_set_all (s, 1.);
}
void cvec_zeros(cvec_t *s) {
- cvec_zeros_norm(s);
- cvec_zeros_phas(s);
+ cvec_norm_zeros(s);
+ cvec_phas_zeros(s);
}
--- a/src/cvec.h
+++ b/src/cvec.h
@@ -27,17 +27,17 @@
/** \file
- Vector of complex-valued data
+ Vector of complex-valued data, stored in polar coordinates
This file specifies the ::cvec_t buffer type, which is used throughout aubio
to store complex data. Complex values are stored in terms of ::cvec_t.phas
- and norm, within size/2+1 long vectors of ::smpl_t.
+ and norm, within 2 vectors of ::smpl_t of size (size/2+1) each.
\example test-cvec.c
*/
-/** Buffer for complex data
+/** Vector of real-valued phase and spectrum data
\code
@@ -78,6 +78,7 @@
*/
cvec_t * new_cvec(uint_t length);
+
/** cvec_t buffer deletion function
\param s buffer to delete as returned by new_cvec()
@@ -84,72 +85,84 @@
*/
void del_cvec(cvec_t *s);
+
/** write norm value in a complex buffer
- Note that this function is not used in the aubio library, since the same
- result can be obtained by assigning vec->norm[position]. Its purpose
- is to access these values from wrappers, as created by swig.
+ This is equivalent to:
+ \code
+ s->norm[position] = val;
+ \endcode
\param s vector to write to
- \param data norm value to write in s->norm[position]
+ \param val norm value to write in s->norm[position]
\param position sample position to write to
*/
-void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position);
+void cvec_norm_set_sample (cvec_t *s, smpl_t val, uint_t position);
+
/** write phase value in a complex buffer
- Note that this function is not used in the aubio library, since the same
- result can be obtained by assigning vec->phas[position]. Its purpose
- is to access these values from wrappers, as created by swig.
+ This is equivalent to:
+ \code
+ s->phas[position] = val;
+ \endcode
\param s vector to write to
- \param data phase value to write in s->phas[position]
+ \param val phase value to write in s->phas[position]
\param position sample position to write to
*/
-void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position);
+void cvec_phas_set_sample (cvec_t *s, smpl_t val, uint_t position);
+
/** read norm value from a complex buffer
- Note that this function is not used in the aubio library, since the same
- result can be obtained with vec->norm[position]. Its purpose is to
- access these values from wrappers, as created by swig.
+ This is equivalent to:
+ \code
+ smpl_t foo = s->norm[position];
+ \endcode
\param s vector to read from
\param position sample position to read from
*/
-smpl_t cvec_read_norm(cvec_t *s, uint_t position);
+smpl_t cvec_norm_get_sample (cvec_t *s, uint_t position);
+
/** read phase value from a complex buffer
- Note that this function is not used in the aubio library, since the same
- result can be obtained with vec->phas[position]. Its purpose is to
- access these values from wrappers, as created by swig.
+ This is equivalent to:
+ \code
+ smpl_t foo = s->phas[position];
+ \endcode
\param s vector to read from
\param position sample position to read from
+ \returns the value of the sample at position
*/
-smpl_t cvec_read_phas(cvec_t *s, uint_t position);
+smpl_t cvec_phas_get_sample (cvec_t *s, uint_t position);
+
/** read norm data from a complex buffer
- Note that this function is not used in the aubio library, since the same
- result can be obtained with vec->norm. Its purpose is to access these values
- from wrappers, as created by swig.
+ \code
+ smpl_t *data = s->norm;
+ \endcode
\param s vector to read from
*/
-smpl_t * cvec_get_norm(cvec_t *s);
+smpl_t * cvec_norm_get_data (cvec_t *s);
+
/** read phase data from a complex buffer
- Note that this function is not used in the aubio library, since the same
- result can be obtained with vec->phas. Its purpose is to access these values
- from wrappers, as created by swig.
+ This is equivalent to:
+ \code
+ smpl_t *data = s->phas;
+ \endcode
\param s vector to read from
*/
-smpl_t * cvec_get_phas(cvec_t *s);
+smpl_t * cvec_phas_get_data (cvec_t *s);
/** print out cvec data
@@ -172,7 +185,7 @@
\param val value to set elements to
*/
-void cvec_set_all_norm(cvec_t *s, smpl_t val);
+void cvec_norm_set_all (cvec_t *s, smpl_t val);
/** set all norm elements to zero
@@ -179,7 +192,7 @@
\param s vector to modify
*/
-void cvec_zeros_norm(cvec_t *s);
+void cvec_norm_zeros(cvec_t *s);
/** set all norm elements to one
@@ -186,7 +199,7 @@
\param s vector to modify
*/
-void cvec_ones_norm(cvec_t *s);
+void cvec_norm_ones(cvec_t *s);
/** set all phase elements to a given value
@@ -194,7 +207,7 @@
\param val value to set elements to
*/
-void cvec_set_all_phas(cvec_t *s, smpl_t val);
+void cvec_phas_set_all (cvec_t *s, smpl_t val);
/** set all phase elements to zero
@@ -201,7 +214,7 @@
\param s vector to modify
*/
-void cvec_zeros_phas(cvec_t *s);
+void cvec_phas_zeros(cvec_t *s);
/** set all phase elements to one
@@ -208,7 +221,7 @@
\param s vector to modify
*/
-void cvec_ones_phas(cvec_t *s);
+void cvec_phas_ones(cvec_t *s);
/** set all norm and phas elements to zero
--- a/tests/src/spectral/test-mfcc.c
+++ b/tests/src/spectral/test-mfcc.c
@@ -12,11 +12,11 @@
// create mfcc object
aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coefs, samplerate);
- cvec_set_all_norm (in, 1.);
+ cvec_norm_set_all (in, 1.);
aubio_mfcc_do (o, in, out);
fvec_print (out);
- cvec_set_all_norm (in, .5);
+ cvec_norm_set_all (in, .5);
aubio_mfcc_do (o, in, out);
fvec_print (out);
--- a/tests/src/test-cvec.c
+++ b/tests/src/test-cvec.c
@@ -19,7 +19,7 @@
}
// set all vector elements to `0`
- cvec_zeros_norm(complex_vector);
+ cvec_norm_zeros(complex_vector);
for ( i = 0; i < complex_vector->length; i++ ) {
assert( complex_vector->norm[i] == 0. );
// assert( complex_vector->phas[i] == 0 );
@@ -27,7 +27,7 @@
cvec_print(complex_vector);
// set all vector elements to `1`
- cvec_ones_norm(complex_vector);
+ cvec_norm_ones(complex_vector);
for ( i = 0; i < complex_vector->length; i++ ) {
assert( complex_vector->norm[i] == 1. );
// assert( complex_vector->phas[i] == 0 );
@@ -35,10 +35,10 @@
cvec_print(complex_vector);
cvec_zeros(complex_vector);
- cvec_zeros_phas(complex_vector);
- cvec_zeros_norm(complex_vector);
- cvec_ones_norm(complex_vector);
- cvec_ones_phas(complex_vector);
+ cvec_phas_zeros(complex_vector);
+ cvec_norm_zeros(complex_vector);
+ cvec_norm_ones(complex_vector);
+ cvec_phas_ones(complex_vector);
cvec_copy(complex_vector, complex_vector);
// destroy it