Пример #1
0
int main (void)
{
  fprintf(stdout, "### testing normal logging\n");
  AUBIO_ERR("testing normal AUBIO_LOG_ERR\n");
  AUBIO_WRN("testing normal AUBIO_LOG_WRN\n");
  AUBIO_MSG("testing normal AUBIO_LOG_MSG\n");
  AUBIO_DBG("testing normal AUBIO_LOG_DBG\n");

  fprintf(stdout, "### testing with one custom function\n");
  aubio_log_set_function(logging, (void *)hdr);
  AUBIO_ERR("testing recustom AUBIO_LOG_ERR\n");
  AUBIO_WRN("testing recustom AUBIO_LOG_WRN\n");
  AUBIO_MSG("testing recustom AUBIO_LOG_MSG\n");
  AUBIO_DBG("testing recustom AUBIO_LOG_DBG\n");

  fprintf(stdout, "### testing resetted logging\n");
  aubio_log_reset();
  AUBIO_ERR("testing uncustom AUBIO_LOG_ERR\n");
  AUBIO_WRN("testing uncustom AUBIO_LOG_WRN\n");
  AUBIO_MSG("testing uncustom AUBIO_LOG_MSG\n");
  AUBIO_DBG("testing uncustom AUBIO_LOG_DBG\n");

  fprintf(stdout, "### testing per level customization\n");
  aubio_log_set_level_function(AUBIO_LOG_ERR, logging, (void *)hdr2);
  aubio_log_set_level_function(AUBIO_LOG_WRN, logging, NULL);
  aubio_log_set_level_function(AUBIO_LOG_MSG, logging, (void *)hdr);
  AUBIO_ERR("testing custom AUBIO_LOG_ERR\n");
  AUBIO_WRN("testing custom AUBIO_LOG_WRN with data=NULL\n");
  AUBIO_MSG("testing custom AUBIO_LOG_MSG\n");
  AUBIO_DBG("testing uncustomized AUBIO_LOG_DBG\n");

  return 0;
}
Пример #2
0
void aubio_setup (void)
{
  post(aubio_version);
  // register custom log function for errors and warnings
  aubio_log_set_level_function(AUBIO_LOG_ERR, aubio_custom_log, NULL);
  aubio_log_set_level_function(AUBIO_LOG_WRN, aubio_custom_log, NULL);
  aubioonset_tilde_setup();
  aubiotempo_tilde_setup();
  aubiotss_tilde_setup();
  aubioquiet_tilde_setup();
  aubiopitch_tilde_setup();
  aubiozcr_tilde_setup();
  aubio_class = class_new(gensym("aubio"), (t_newmethod)aubio_new, 0,
      sizeof(t_aubio), 0, 0);
}
Пример #3
0
static PyObject *
initaubio (void)
{
    PyObject *m = NULL;
    int err;

    // fvec is defined in __init__.py
    if (   (PyType_Ready (&Py_cvecType) < 0)
            || (PyType_Ready (&Py_filterType) < 0)
            || (PyType_Ready (&Py_filterbankType) < 0)
            || (PyType_Ready (&Py_fftType) < 0)
            || (PyType_Ready (&Py_pvocType) < 0)
            || (PyType_Ready (&Py_sourceType) < 0)
            || (PyType_Ready (&Py_sinkType) < 0)
            // generated objects
            || (generated_types_ready() < 0 )
       ) {
        return m;
    }

#if PY_MAJOR_VERSION >= 3
    m = PyModule_Create(&moduledef);
#else
    m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc);
#endif

    if (m == NULL) {
        return m;
    }

    err = _import_array ();
    if (err != 0) {
        fprintf (stderr,
                 "Unable to import Numpy array from aubio module (error %d)\n", err);
    }

    Py_INCREF (&Py_cvecType);
    PyModule_AddObject (m, "cvec", (PyObject *) & Py_cvecType);
    Py_INCREF (&Py_filterType);
    PyModule_AddObject (m, "digital_filter", (PyObject *) & Py_filterType);
    Py_INCREF (&Py_filterbankType);
    PyModule_AddObject (m, "filterbank", (PyObject *) & Py_filterbankType);
    Py_INCREF (&Py_fftType);
    PyModule_AddObject (m, "fft", (PyObject *) & Py_fftType);
    Py_INCREF (&Py_pvocType);
    PyModule_AddObject (m, "pvoc", (PyObject *) & Py_pvocType);
    Py_INCREF (&Py_sourceType);
    PyModule_AddObject (m, "source", (PyObject *) & Py_sourceType);
    Py_INCREF (&Py_sinkType);
    PyModule_AddObject (m, "sink", (PyObject *) & Py_sinkType);

    PyModule_AddStringConstant(m, "float_type", AUBIO_NPY_SMPL_STR);
    PyModule_AddStringConstant(m, "__version__", DEFINEDSTRING(AUBIO_VERSION));

    // add generated objects
    add_generated_objects(m);

    // add ufunc
    add_ufuncs(m);

    aubio_log_set_level_function(AUBIO_LOG_ERR, aubio_log_function, NULL);
    aubio_log_set_level_function(AUBIO_LOG_WRN, aubio_log_function, NULL);
    return m;
}