Changeset bc66f1d for python


Ignore:
Timestamp:
Nov 17, 2018, 2:31:36 AM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
Children:
2886984
Parents:
ff9c62a
Message:

[py] add meltohz and hztomel with minimal doc

Location:
python/ext
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • python/ext/aubiomodule.c

    rff9c62a rbc66f1d  
    373373  {"shift", Py_aubio_shift, METH_VARARGS, Py_aubio_shift_doc},
    374374  {"ishift", Py_aubio_ishift, METH_VARARGS, Py_aubio_ishift_doc},
     375  {"hztomel", Py_aubio_hztomel, METH_VARARGS|METH_KEYWORDS, Py_aubio_hztomel_doc},
     376  {"meltohz", Py_aubio_meltohz, METH_VARARGS|METH_KEYWORDS, Py_aubio_meltohz_doc},
     377  {"hztomel_htk", Py_aubio_hztomel_htk, METH_VARARGS, Py_aubio_hztomel_htk_doc},
     378  {"meltohz_htk", Py_aubio_meltohz_htk, METH_VARARGS, Py_aubio_meltohz_htk_doc},
    375379  {NULL, NULL, 0, NULL} /* Sentinel */
    376380};
  • python/ext/py-musicutils.c

    rff9c62a rbc66f1d  
    182182  return (PyObject *) PyAubio_CFvecToArray(&vec);
    183183}
     184
     185PyObject*
     186Py_aubio_hztomel(PyObject *self, PyObject *args, PyObject *kwds)
     187{
     188  smpl_t v;
     189  PyObject *htk = NULL;
     190  static char *kwlist[] = {"f", "htk", NULL};
     191  if (!PyArg_ParseTupleAndKeywords(args, kwds, AUBIO_NPY_SMPL_CHR "|O",
     192        kwlist, &v, &htk))
     193  {
     194    return NULL;
     195  }
     196  if (htk != NULL && PyObject_IsTrue(htk) == 1)
     197    return Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_hztomel_htk(v));
     198  else
     199    return Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_hztomel(v));
     200}
     201
     202PyObject*
     203Py_aubio_meltohz(PyObject *self, PyObject *args, PyObject *kwds)
     204{
     205  smpl_t v;
     206  PyObject *htk = NULL;
     207  static char *kwlist[] = {"m", "htk", NULL};
     208  if (!PyArg_ParseTupleAndKeywords(args, kwds, AUBIO_NPY_SMPL_CHR "|O",
     209        kwlist, &v, &htk))
     210  {
     211    return NULL;
     212  }
     213  if (htk != NULL && PyObject_IsTrue(htk) == 1)
     214    return Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_meltohz_htk(v));
     215  else
     216    return Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_meltohz(v));
     217}
     218
     219PyObject*
     220Py_aubio_hztomel_htk(PyObject *self, PyObject *args)
     221{
     222  smpl_t v;
     223  if (!PyArg_ParseTuple(args, AUBIO_NPY_SMPL_CHR, &v)) {
     224    return NULL;
     225  }
     226  return Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_hztomel_htk(v));
     227}
     228
     229PyObject*
     230Py_aubio_meltohz_htk(PyObject *self, PyObject *args)
     231{
     232  smpl_t v;
     233  if (!PyArg_ParseTuple(args, AUBIO_NPY_SMPL_CHR, &v)) {
     234    return NULL;
     235  }
     236  return Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_meltohz_htk(v));
     237}
  • python/ext/py-musicutils.h

    rff9c62a rbc66f1d  
    301301PyObject * Py_aubio_ishift(PyObject *self, PyObject *args);
    302302
     303static char Py_aubio_hztomel_doc[] = ""
     304"hztomel(f, htk=False)\n"
     305"\n"
     306"Convert a scalar from frequency to mel scale.\n"
     307"\n"
     308"Parameters\n"
     309"----------\n"
     310"m : float\n"
     311"   input frequency, in Hz\n"
     312"htk : bool\n"
     313"   if `True`, use Htk mel scale instead of Slaney.\n"
     314"\n"
     315"Returns\n"
     316"-------\n"
     317"float\n"
     318"   output mel\n"
     319"\n"
     320"See Also\n"
     321"--------\n"
     322"meltohz\n"
     323"";
     324PyObject * Py_aubio_hztomel(PyObject *self, PyObject *args);
     325
     326static char Py_aubio_meltohz_doc[] = ""
     327"meltohz(m, htk=False)\n"
     328"\n"
     329"Convert a scalar from mel scale to frequency.\n"
     330"\n"
     331"Parameters\n"
     332"----------\n"
     333"m : float\n"
     334"   input mel\n"
     335"htk : bool\n"
     336"   if `True`, use Htk mel scale instead of Slaney.\n"
     337"\n"
     338"Returns\n"
     339"-------\n"
     340"float\n"
     341"   output frequency, in Hz\n"
     342"\n"
     343"See Also\n"
     344"--------\n"
     345"hztomel\n"
     346"";
     347PyObject * Py_aubio_meltohz(PyObject *self, PyObject *args);
     348
     349static char Py_aubio_hztomel_htk_doc[] = ""
     350"hztomel_htk(m)\n"
     351"\n"
     352"Same as `hztomel(m, htk=True)`\n"
     353"\n"
     354"See Also\n"
     355"--------\n"
     356"hztomel\n"
     357"";
     358PyObject * Py_aubio_hztomel_htk(PyObject *self, PyObject *args);
     359
     360static char Py_aubio_meltohz_htk_doc[] = ""
     361"meltohz_htk(m)\n"
     362"\n"
     363"Same as `meltohz(m, htk=True)`\n"
     364"\n"
     365"See Also\n"
     366"--------\n"
     367"meltohz\n"
     368"";
     369PyObject * Py_aubio_meltohz_htk(PyObject *self, PyObject *args);
     370
    303371#endif /* PY_AUBIO_MUSICUTILS_H */
Note: See TracChangeset for help on using the changeset viewer.