return result;
}
+static char Py_unwrap2pi_doc[] = "unwrap phase value to [-pi, pi]";
+
+static PyObject *
+Py_unwrap2pi (PyObject * self, PyObject * args)
+{
+ smpl_t input;
+ smpl_t output;
+
+ if (!PyArg_ParseTuple (args, "|f", &input)) {
+ return NULL;
+ }
+
+ output = aubio_unwrap2pi (input);
+
+ return (PyObject *)PyFloat_FromDouble (output);
+}
+
static char Py_bintomidi_doc[] = "convert bin to midi";
static PyObject *
}
static PyMethodDef aubio_methods[] = {
+ {"unwrap2pi", Py_unwrap2pi, METH_VARARGS, Py_unwrap2pi_doc},
{"bintomidi", Py_bintomidi, METH_VARARGS, Py_bintomidi_doc},
{"miditobin", Py_miditobin, METH_VARARGS, Py_miditobin_doc},
{"bintofreq", Py_bintofreq, METH_VARARGS, Py_bintofreq_doc},
from numpy.testing import TestCase, run_module_suite
from numpy.testing import assert_equal, assert_almost_equal
from aubio import bintomidi, miditobin, freqtobin, bintofreq, freqtomidi, miditofreq
+from aubio import unwrap2pi
class aubio_mathutils(TestCase):
+ def test_unwrap2pi(self):
+ a = [ x/100. for x in range(-600,600,100) ]
+ b = [ unwrap2pi(x) for x in a ]
+ #print b
+
def test_miditobin(self):
a = [ miditobin(a, 44100, 512) for a in range(128) ]
def test_miditofreq(self):
freqs = [ miditofreq(a) for a in range(128) ]
midis = [ freqtomidi(a) for a in freqs ]
- print midis
if __name__ == '__main__':
from unittest import main