ref: c9ca26089538e7f8f94b2112b41bc51d4698da98
parent: 3aac1946f105ec900381341ff90fe6f9fb853d80
parent: ad3770fa5f1372e5908805f6024ef3c4541d13ed
author: Paul Brossier <piem@piem.org>
date: Sat Sep 15 13:34:21 EDT 2018
Merge branch 'master' into feature/fastmfcc
--- a/examples/utils.h
+++ b/examples/utils.h
@@ -66,7 +66,7 @@
void send_noteon (smpl_t pitch, smpl_t velo);
/** common process function */
-typedef int (*aubio_process_func_t) (fvec_t * input, fvec_t * output);
+typedef void (*aubio_process_func_t) (fvec_t * input, fvec_t * output);
void process_block (fvec_t *ibuf, fvec_t *obuf);
void process_print (void);
--- a/python/ext/aubiomodule.c
+++ b/python/ext/aubiomodule.c
@@ -242,6 +242,8 @@
{"silence_detection", Py_aubio_silence_detection, METH_VARARGS, Py_aubio_silence_detection_doc},
{"level_detection", Py_aubio_level_detection, METH_VARARGS, Py_aubio_level_detection_doc},
{"window", Py_aubio_window, METH_VARARGS, Py_aubio_window_doc},
+ {"shift", Py_aubio_shift, METH_VARARGS, Py_aubio_shift_doc},
+ {"ishift", Py_aubio_ishift, METH_VARARGS, Py_aubio_ishift_doc},
{NULL, NULL, 0, NULL} /* Sentinel */
};
--- a/python/ext/py-musicutils.c
+++ b/python/ext/py-musicutils.c
@@ -133,3 +133,51 @@
return level_detection;
}
+
+PyObject *
+Py_aubio_shift(PyObject *self, PyObject *args)
+{
+ PyObject *input;
+ fvec_t vec;
+
+ if (!PyArg_ParseTuple (args, "O:shift", &input)) {
+ return NULL;
+ }
+
+ if (input == NULL) {
+ return NULL;
+ }
+
+ if (!PyAubio_ArrayToCFvec(input, &vec)) {
+ return NULL;
+ }
+
+ fvec_shift(&vec);
+
+ //Py_RETURN_NONE;
+ return (PyObject *) PyAubio_CFvecToArray(&vec);
+}
+
+PyObject *
+Py_aubio_ishift(PyObject *self, PyObject *args)
+{
+ PyObject *input;
+ fvec_t vec;
+
+ if (!PyArg_ParseTuple (args, "O:shift", &input)) {
+ return NULL;
+ }
+
+ if (input == NULL) {
+ return NULL;
+ }
+
+ if (!PyAubio_ArrayToCFvec(input, &vec)) {
+ return NULL;
+ }
+
+ fvec_ishift(&vec);
+
+ //Py_RETURN_NONE;
+ return (PyObject *) PyAubio_CFvecToArray(&vec);
+}
--- a/python/ext/py-musicutils.h
+++ b/python/ext/py-musicutils.h
@@ -71,4 +71,34 @@
PyObject * Py_aubio_level_detection(PyObject *self, PyObject *args);
+static char Py_aubio_shift_doc[] = ""
+"Swap left and right partitions of a vector\n"
+"\n"
+"Returns the swapped vector. The input vector is also modified.\n"
+"\n"
+"For a vector of length N, the partition is split at index N - N//2.\n"
+"\n"
+"Example\n"
+"-------\n"
+"\n"
+">>> import numpy\n"
+">>> shift(numpy.arange(3, dtype=aubio.float_type))\n"
+"array([2., 0., 1.], dtype=" AUBIO_NPY_SMPL_STR ")";
+PyObject * Py_aubio_shift(PyObject *self, PyObject *args);
+
+static char Py_aubio_ishift_doc[] = ""
+"Swap right and left partitions of a vector\n"
+"\n"
+"Returns the swapped vector. The input vector is also modified.\n"
+"\n"
+"Unlike with shift(), the partition is split at index N//2.\n"
+"\n"
+"Example\n"
+"-------\n"
+"\n"
+">>> import numpy\n"
+">>> ishift(numpy.arange(3, dtype=aubio.float_type))\n"
+"array([1., 2., 0.], dtype=" AUBIO_NPY_SMPL_STR ")";
+PyObject * Py_aubio_ishift(PyObject *self, PyObject *args);
+
#endif /* PY_AUBIO_MUSICUTILS_H */
--- a/python/tests/test_dct.py
+++ b/python/tests/test_dct.py
@@ -31,7 +31,7 @@
a_dct = aubio.dct(8)
a_in = np.arange(8).astype(aubio.float_type)
a_expected = aubio.fvec(precomputed_arange)
- assert_almost_equal(a_dct(a_in), a_expected, decimal=6)
+ assert_almost_equal(a_dct(a_in), a_expected, decimal=5)
def test_some_ones(self):
""" test that dct(somevector) is computed correctly """
--- /dev/null
+++ b/python/tests/test_fvec_shift.py
@@ -1,0 +1,35 @@
+#! /usr/bin/env python
+
+import numpy as np
+from numpy.testing import TestCase, assert_equal
+import aubio
+
+class aubio_shift_test_case(TestCase):
+
+ def run_shift_ishift(self, n):
+ ramp = np.arange(n, dtype=aubio.float_type)
+ # construct expected output
+ # even length: [5. 6. 7. 8. 9. 0. 1. 2. 3. 4.]
+ # odd length: [4. 5. 6. 0. 1. 2. 3.]
+ half = n - n//2
+ expected = np.concatenate([np.arange(half, n), np.arange(half)])
+ # shift in place, returns modified copy
+ assert_equal(aubio.shift(ramp), expected)
+ # check input was changed as expected
+ assert_equal(ramp, expected)
+ # construct expected output
+ expected = np.arange(n)
+ # revert shift in place, returns modifed copy
+ assert_equal(aubio.ishift(ramp), expected)
+ # check input was shifted back
+ assert_equal(ramp, expected)
+
+ def test_can_shift_fvec(self):
+ self.run_shift_ishift(10)
+
+ def test_can_shift_fvec_odd(self):
+ self.run_shift_ishift(7)
+
+from unittest import main
+if __name__ == '__main__':
+ main()
--- a/scripts/get_waf.sh
+++ b/scripts/get_waf.sh
@@ -3,7 +3,7 @@
set -e
set -x
-WAFVERSION=2.0.1
+WAFVERSION=2.0.11
WAFTARBALL=waf-$WAFVERSION.tar.bz2
WAFURL=https://waf.io/$WAFTARBALL
--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -143,8 +143,10 @@
s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1);
strncpy(s->path, path, strnlen(path, PATH_MAX) + 1);
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58,0,0)
// register all formats and codecs
av_register_all();
+#endif
if (aubio_source_avcodec_has_network_url(s)) {
avformat_network_init();
--- a/src/spectral/dct.c
+++ b/src/spectral/dct.c
@@ -40,13 +40,13 @@
typedef void (*del_aubio_dct_t)(aubio_dct_t * s);
#if defined(HAVE_ACCELERATE)
-typedef struct _aubio_dct_opt_t aubio_dct_accelerate_t;
+typedef struct _aubio_dct_accelerate_t aubio_dct_accelerate_t;
extern aubio_dct_accelerate_t * new_aubio_dct_accelerate (uint_t size);
extern void aubio_dct_accelerate_do(aubio_dct_accelerate_t *s, const fvec_t *input, fvec_t *output);
extern void aubio_dct_accelerate_rdo(aubio_dct_accelerate_t *s, const fvec_t *input, fvec_t *output);
extern void del_aubio_dct_accelerate (aubio_dct_accelerate_t *s);
#elif defined(HAVE_FFTW3)
-typedef struct _aubio_dct_opt_t aubio_dct_fftw_t;
+typedef struct _aubio_dct_fftw_t aubio_dct_fftw_t;
extern aubio_dct_fftw_t * new_aubio_dct_fftw (uint_t size);
extern void aubio_dct_fftw_do(aubio_dct_fftw_t *s, const fvec_t *input, fvec_t *output);
extern void aubio_dct_fftw_rdo(aubio_dct_fftw_t *s, const fvec_t *input, fvec_t *output);
@@ -83,12 +83,18 @@
aubio_dct_t * s = AUBIO_NEW(aubio_dct_t);
if ((sint_t)size <= 0) goto beach;
#if defined(HAVE_ACCELERATE)
- // TODO check
// vDSP supports sizes = f * 2 ** n, where n >= 4 and f in [1, 3, 5, 15]
// see https://developer.apple.com/documentation/accelerate/1449930-vdsp_dct_createsetup
- if (aubio_is_power_of_two(size/16) != 1
- || (size/16 != 3 && size/16 != 5 && size/16 != 15)) {
- goto plain;
+ {
+ uint_t radix = size;
+ uint_t order = 0;
+ while ((radix / 2) * 2 == radix) {
+ radix /= 2;
+ order++;
+ }
+ if (order < 4 || (radix != 1 && radix != 3 && radix != 5 && radix != 15)) {
+ goto plain;
+ }
}
s->dct = (void *)new_aubio_dct_accelerate (size);
if (s->dct) {