Changeset 5a7e2c3
- Timestamp:
- Jul 10, 2015, 1:51:25 AM (9 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 4615886a
- Parents:
- efa62ce
- Location:
- python
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
python/ext/aubiomodule.c
refa62ce r5a7e2c3 241 241 {"zero_crossing_rate", Py_zero_crossing_rate, METH_VARARGS, Py_zero_crossing_rate_doc}, 242 242 {"min_removal", Py_min_removal, METH_VARARGS, Py_min_removal_doc}, 243 {"level_lin", Py_aubio_level_lin, METH_VARARGS, Py_aubio_level_lin_doc}, 243 244 {"window", Py_aubio_window, METH_VARARGS, Py_aubio_window_doc}, 244 245 {NULL, NULL} /* Sentinel */ -
python/ext/py-musicutils.c
refa62ce r5a7e2c3 21 21 return (PyObject *) PyAubio_CFvecToArray(window); 22 22 } 23 24 PyObject * 25 Py_aubio_level_lin(PyObject *self, PyObject *args) 26 { 27 PyObject *input; 28 fvec_t *vec; 29 PyObject *level_lin; 30 31 if (!PyArg_ParseTuple (args, "O:level_lin", &input)) { 32 PyErr_SetString (PyExc_ValueError, "failed parsing arguments"); 33 return NULL; 34 } 35 36 if (input == NULL) { 37 return NULL; 38 } 39 40 vec = PyAubio_ArrayToCFvec (input); 41 if (vec == NULL) { 42 return NULL; 43 } 44 45 level_lin = Py_BuildValue("f", aubio_level_lin(vec)); 46 if (level_lin == NULL) { 47 PyErr_SetString (PyExc_ValueError, "failed computing level_lin"); 48 return NULL; 49 } 50 51 return level_lin; 52 } -
python/tests/test_musicutils.py
refa62ce r5a7e2c3 2 2 3 3 from numpy.testing import TestCase 4 from numpy.testing.utils import assert_almost_equal 5 from aubio import window 4 from numpy.testing.utils import assert_equal, assert_almost_equal 5 from numpy import cos, arange 6 from math import pi 7 8 from aubio import window, level_lin 9 10 from aubio import fvec 6 11 7 12 class aubio_window(TestCase): … … 27 32 28 33 def test_compute_hanning_1024(self): 29 from numpy import cos, arange30 from math import pi31 34 size = 1024 32 35 aubio_window = window("hanning", size) … … 34 37 assert_almost_equal(aubio_window, numpy_window) 35 38 39 class aubio_level_lin(TestCase): 40 def test_accept_fvec(self): 41 level_lin(fvec(1024)) 42 43 def test_fail_not_fvec(self): 44 try: 45 level_lin("default") 46 except ValueError, e: 47 pass 48 else: 49 self.fail('non-number input phase does not raise a TypeError') 50 51 def test_zeros_is_zeros(self): 52 assert_equal(level_lin(fvec(1024)), 0.) 53 54 def test_minus_ones_is_one(self): 55 from numpy import ones 56 assert_equal(level_lin(-ones(1024, dtype="float32")), 1.) 57 36 58 if __name__ == '__main__': 37 59 from unittest import main
Note: See TracChangeset
for help on using the changeset viewer.