shithub: aubio

Download patch

ref: 08d07ce66ec5cad6f812cec5a3cf374a5e0911e7
parent: 9279ba044c3eb637839277829d6337e530f71a1f
parent: 2244f004403844e28440c956a3a073691845a6d0
author: Paul Brossier <piem@piem.org>
date: Sat Jun 29 09:14:08 EDT 2019

Merge branch 'master' into feature/timestretch

--- a/.travis.yml
+++ b/.travis.yml
@@ -76,7 +76,7 @@
     - libsamplerate
     - rubberband
     - lcov
-    #update: true
+    update: true
 
 before_install:
    - |
--- a/doc/binaries.rst
+++ b/doc/binaries.rst
@@ -8,5 +8,8 @@
 and
 `windows <https://aubio.org/download#win>`_
 
+For Windows, aubio is also available from `vcpkg
+<https://vcpkg.readthedocs.io/en/latest/examples/installing-and-using-packages/>`_.
+
 To use aubio in a macOS or iOS application, see :ref:`xcode-frameworks-label`.
 
--- a/python/ext/aubio-docstrings.h
+++ b/python/ext/aubio-docstrings.h
@@ -1,7 +1,7 @@
 #define PYAUBIO_dct_doc \
     "dct(size=1024)\n"\
     "\n"\
-    "Compute Discrete Fourier Transorms of Type-II.\n"\
+    "Compute Discrete Fourier Transforms of Type-II.\n"\
     "\n"\
     "Parameters\n"\
     "----------\n"\
--- a/python/ext/py-fft.c
+++ b/python/ext/py-fft.c
@@ -3,7 +3,7 @@
 static char Py_fft_doc[] = ""
 "fft(size=1024)\n"
 "\n"
-"Compute Fast Fourier Transorms.\n"
+"Compute Fast Fourier Transforms.\n"
 "\n"
 "Parameters\n"
 "----------\n"
--- a/python/ext/py-filter.c
+++ b/python/ext/py-filter.c
@@ -156,8 +156,18 @@
 
   err = aubio_filter_set_c_weighting (self->o, samplerate);
   if (err > 0) {
-    PyErr_SetString (PyExc_ValueError,
-        "error when setting filter to C-weighting");
+    if (PyErr_Occurred() == NULL) {
+      PyErr_SetString (PyExc_ValueError,
+          "error when setting filter to C-weighting");
+    } else {
+      // change the RuntimeError into ValueError
+      PyObject *type, *value, *traceback;
+      PyErr_Fetch(&type, &value, &traceback);
+      Py_XDECREF(type);
+      type = PyExc_ValueError;
+      Py_XINCREF(type);
+      PyErr_Restore(type, value, traceback);
+    }
     return NULL;
   }
   Py_RETURN_NONE;
@@ -174,8 +184,18 @@
 
   err = aubio_filter_set_a_weighting (self->o, samplerate);
   if (err > 0) {
-    PyErr_SetString (PyExc_ValueError,
-        "error when setting filter to A-weighting");
+    if (PyErr_Occurred() == NULL) {
+      PyErr_SetString (PyExc_ValueError,
+          "error when setting filter to A-weighting");
+    } else {
+      // change the RuntimeError into ValueError
+      PyObject *type, *value, *traceback;
+      PyErr_Fetch(&type, &value, &traceback);
+      Py_XDECREF(type);
+      type = PyExc_ValueError;
+      Py_XINCREF(type);
+      PyErr_Restore(type, value, traceback);
+    }
     return NULL;
   }
   Py_RETURN_NONE;
@@ -192,8 +212,18 @@
 
   err = aubio_filter_set_biquad (self->o, b0, b1, b2, a1, a2);
   if (err > 0) {
-    PyErr_SetString (PyExc_ValueError,
-        "error when setting filter with biquad coefficients");
+    if (PyErr_Occurred() == NULL) {
+      PyErr_SetString (PyExc_ValueError,
+          "error when setting filter with biquad coefficients");
+    } else {
+      // change the RuntimeError into ValueError
+      PyObject *type, *value, *traceback;
+      PyErr_Fetch(&type, &value, &traceback);
+      Py_XDECREF(type);
+      type = PyExc_ValueError;
+      Py_XINCREF(type);
+      PyErr_Restore(type, value, traceback);
+    }
     return NULL;
   }
   Py_RETURN_NONE;
--- a/python/ext/py-filterbank.c
+++ b/python/ext/py-filterbank.c
@@ -326,7 +326,10 @@
       // change the RuntimeError into ValueError
       PyObject *type, *value, *traceback;
       PyErr_Fetch(&type, &value, &traceback);
-      PyErr_Restore(PyExc_ValueError, value, traceback);
+      Py_XDECREF(type);
+      type = PyExc_ValueError;
+      Py_XINCREF(type);
+      PyErr_Restore(type, value, traceback);
     }
     return NULL;
   }
@@ -351,7 +354,10 @@
       // change the RuntimeError into ValueError
       PyObject *type, *value, *traceback;
       PyErr_Fetch(&type, &value, &traceback);
-      PyErr_Restore(PyExc_ValueError, value, traceback);
+      Py_XDECREF(type);
+      type = PyExc_ValueError;
+      Py_XINCREF(type);
+      PyErr_Restore(type, value, traceback);
     }
     return NULL;
   }
@@ -380,7 +386,10 @@
       // change the RuntimeError into ValueError
       PyObject *type, *value, *traceback;
       PyErr_Fetch(&type, &value, &traceback);
-      PyErr_Restore(PyExc_ValueError, value, traceback);
+      Py_XDECREF(type);
+      type = PyExc_ValueError;
+      Py_XINCREF(type);
+      PyErr_Restore(type, value, traceback);
     }
     return NULL;
   }
@@ -409,7 +418,10 @@
       // change the RuntimeError into ValueError
       PyObject *type, *value, *traceback;
       PyErr_Fetch(&type, &value, &traceback);
-      PyErr_Restore(PyExc_ValueError, value, traceback);
+      Py_XDECREF(type);
+      type = PyExc_ValueError;
+      Py_XINCREF(type);
+      PyErr_Restore(type, value, traceback);
     }
     return NULL;
   }
@@ -463,7 +475,10 @@
       // change the RuntimeError into ValueError
       PyObject *type, *value, *traceback;
       PyErr_Fetch(&type, &value, &traceback);
-      PyErr_Restore(PyExc_ValueError, value, traceback);
+      Py_XDECREF(type);
+      type = PyExc_ValueError;
+      Py_XINCREF(type);
+      PyErr_Restore(type, value, traceback);
     }
     return NULL;
   }
@@ -493,7 +508,10 @@
       // change the RuntimeError into ValueError
       PyObject *type, *value, *traceback;
       PyErr_Fetch(&type, &value, &traceback);
-      PyErr_Restore(PyExc_ValueError, value, traceback);
+      Py_XDECREF(type);
+      type = PyExc_ValueError;
+      Py_XINCREF(type);
+      PyErr_Restore(type, value, traceback);
     }
     return NULL;
   }
--- a/python/ext/py-sink.c
+++ b/python/ext/py-sink.c
@@ -81,7 +81,7 @@
 "Close this sink now.\n"
 "\n"
 "By default, the sink will be closed before being deleted.\n"
-"Explicitely closing a sink can be useful to control the number\n"
+"Explicitly closing a sink can be useful to control the number\n"
 "of files simultaneously opened.\n"
 "";
 
--- a/python/lib/gen_code.py
+++ b/python/lib/gen_code.py
@@ -523,7 +523,10 @@
       // change the RuntimeError into ValueError
       PyObject *type, *value, *traceback;
       PyErr_Fetch(&type, &value, &traceback);
-      PyErr_Restore(PyExc_ValueError, value, traceback);
+      Py_XDECREF(type);
+      type = PyExc_ValueError;
+      Py_XINCREF(type);
+      PyErr_Restore(type, value, traceback);
     }}
     return NULL;
   }}
--- a/python/lib/gen_external.py
+++ b/python/lib/gen_external.py
@@ -121,23 +121,24 @@
     print("Running command: {:s}".format(" ".join(cpp_cmd)))
     proc = subprocess.Popen(cpp_cmd,
                             stderr=subprocess.PIPE,
-                            stdout=subprocess.PIPE)
+                            stdout=subprocess.PIPE,
+                            universal_newlines=True)
     assert proc, 'Proc was none'
     cpp_output = proc.stdout.read()
     err_output = proc.stderr.read()
     if err_output:
         print("Warning: preprocessor produced errors or warnings:\n%s" \
-                % err_output.decode('utf8'))
+                % err_output)
     if not cpp_output:
         raise_msg = "preprocessor output is empty! Running command " \
                 + "\"%s\" failed" % " ".join(cpp_cmd)
         if err_output:
-            raise_msg += " with stderr: \"%s\"" % err_output.decode('utf8')
+            raise_msg += " with stderr: \"%s\"" % err_output
         else:
             raise_msg += " with no stdout or stderr"
         raise Exception(raise_msg)
     if not isinstance(cpp_output, list):
-        cpp_output = [l.strip() for l in cpp_output.decode('utf8').split('\n')]
+        cpp_output = [l.strip() for l in cpp_output.split('\n')]
 
     return cpp_output
 
--- a/python/tests/test_hztomel.py
+++ b/python/tests/test_hztomel.py
@@ -4,6 +4,7 @@
 from numpy.testing import TestCase
 from numpy.testing import assert_equal, assert_almost_equal
 from _tools import assert_warns
+from utils import is32bit
 import numpy as np
 import aubio
 
@@ -10,7 +11,6 @@
 from aubio import hztomel, meltohz
 from aubio import hztomel_htk, meltohz_htk
 
-
 class aubio_hztomel_test_case(TestCase):
 
     def test_hztomel(self):
@@ -17,10 +17,15 @@
         assert_equal(hztomel(0.), 0.)
         assert_almost_equal(hztomel(400. / 3.), 2., decimal=5)
         assert_almost_equal(hztomel(1000. / 3), 5.)
-        assert_equal(hztomel(200.), 3.)
+        # on 32bit, some of these tests fails unless compiling with -ffloat-store
+        try:
+            assert_equal(hztomel(200.), 3.)
+        except AssertionError:
+            if not is32bit(): raise
+            assert_almost_equal(hztomel(200.), 3., decimal=5)
         assert_almost_equal(hztomel(1000.), 15)
-        assert_almost_equal(hztomel(6400), 42)
-        assert_almost_equal(hztomel(40960), 69)
+        assert_almost_equal(hztomel(6400), 42, decimal=5)
+        assert_almost_equal(hztomel(40960), 69, decimal=5)
 
         for m in np.linspace(0, 1000, 100):
             assert_almost_equal(hztomel(meltohz(m)) - m, 0, decimal=3)
@@ -28,7 +33,11 @@
     def test_meltohz(self):
         assert_equal(meltohz(0.), 0.)
         assert_almost_equal(meltohz(2), 400. / 3., decimal=4)
-        assert_equal(meltohz(3.), 200.)
+        try:
+            assert_equal(meltohz(3.), 200.)
+        except AssertionError:
+            if not is32bit(): raise
+            assert_almost_equal(meltohz(3.), 200., decimal=5)
         assert_almost_equal(meltohz(5), 1000. / 3., decimal=4)
         assert_almost_equal(meltohz(15), 1000., decimal=4)
         assert_almost_equal(meltohz(42), 6400., decimal=2)
--- a/python/tests/test_phasevoc.py
+++ b/python/tests/test_phasevoc.py
@@ -1,7 +1,7 @@
 #! /usr/bin/env python
 
 from numpy.testing import TestCase, assert_equal, assert_array_less
-from _tools import parametrize
+from _tools import parametrize, skipTest
 from aubio import fvec, cvec, pvoc, float_type
 import numpy as np
 
@@ -51,7 +51,7 @@
                 assert_equal (s.phas[s.phas > 0], +np.pi)
                 assert_equal (s.phas[s.phas < 0], -np.pi)
                 assert_equal (np.abs(s.phas[np.abs(s.phas) != np.pi]), 0)
-                self.skipTest('pvoc(fvec(%d)).phas != +0, ' % win_s \
+                skipTest('pvoc(fvec(%d)).phas != +0, ' % win_s \
                         + 'This is expected when using fftw3 on powerpc.')
             assert_equal ( r, 0.)
 
--- a/python/tests/utils.py
+++ b/python/tests/utils.py
@@ -3,10 +3,14 @@
 import os
 import re
 import glob
+import struct
 import numpy as np
 from tempfile import mkstemp
 
 DEFAULT_SOUND = '22050Hz_5s_brownnoise.wav'
+
+def is32bit():
+    return struct.calcsize("P") * 8 == 32
 
 def array_from_text_file(filename, dtype = 'float'):
     realpathname = os.path.join(os.path.dirname(__file__), filename)
--- a/scripts/get_waf.sh
+++ b/scripts/get_waf.sh
@@ -3,7 +3,7 @@
 set -e
 #set -x
 
-WAFVERSION=2.0.14
+WAFVERSION=2.0.17
 WAFTARBALL=waf-$WAFVERSION.tar.bz2
 WAFURL=https://waf.io/$WAFTARBALL
 WAFUPSTREAMKEY=https://gitlab.com/ita1024/waf/raw/master/utils/pubkey.asc