ref: ee8a57c3905c9ce6bc5286dd0238d4fbc0c5b459
parent: 155cc10b5cde76184291c01fe8723328f0e36430
author: Paul Brossier <[email protected]>
date: Fri Mar 10 12:17:33 EST 2017
src/mathutils.h: add fvec_push
--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -289,6 +289,14 @@
}
}
+void fvec_push(fvec_t *in, smpl_t new_elem) {
+ uint_t i;
+ for (i = 0; i < in->length - 1; i++) {
+ in->data[i] = in->data[i + 1];
+ }
+ in->data[in->length - 1] = new_elem;
+}
+
smpl_t
aubio_level_lin (const fvec_t * f)
{
--- a/src/mathutils.h
+++ b/src/mathutils.h
@@ -117,6 +117,17 @@
*/
void fvec_ishift (fvec_t * v);
+/** push a new element to the end of a vector, erasing the first element and
+ * sliding all others
+
+ \param in vector to push to
+ \param new_elem new_element to add at the end of the vector
+
+ In numpy words, this is equivalent to: in = np.concatenate([in, [new_elem]])[1:]
+
+*/
+void fvec_push(fvec_t *in, smpl_t new_elem);
+
/** compute the sum of all elements of a vector
\param v vector to compute the sum of