Skip to content

Commit

Permalink
Merge pull request #18 from qyou/fix-dup-symbol-error
Browse files Browse the repository at this point in the history
fix bug: fix the duplicate symbol error
  • Loading branch information
vBaiCai authored Apr 23, 2020
2 parents 818a271 + 0320594 commit d870dfa
Show file tree
Hide file tree
Showing 6 changed files with 1,347 additions and 1,160 deletions.
59 changes: 31 additions & 28 deletions pypesq/dsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Version 2.0 - October 2005.
DEFINITIONS:
------------
For the purposes of this Intellectual Property Rights Notice
the terms Perceptual Evaluation of Speech Quality Algorithm
and PESQ Algorithm refer to the objective speech quality
the terms 'Perceptual Evaluation of Speech Quality Algorithm'
and 'PESQ Algorithm' refer to the objective speech quality
measurement algorithm defined in ITU-T Recommendation P.862;
the term PESQ Software refers to the C-code component of P.862.
the term 'PESQ Software' refers to the C-code component of P.862.
These definitions also apply to those parts of ITU-T Recommendation
P.862.2 and its associated source code that are common with P.862.

Expand Down Expand Up @@ -101,40 +101,43 @@ AGREEMENT. PESQ PATENT-ONLY LICENSE AGREEMENTS MAY BE OBTAINED FROM OPTICOM.
Further information is also available from www.pesq.org

*****************************************************************************/
#ifndef _DSP_H_H
#define _DSP_H_H

#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif

#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif

#ifndef DSP_INCLUDED
#define DSP_INCLUDED
void *safe_malloc (unsigned long);
void safe_free (void *);

void IIRFilt(
float * h, unsigned long Nsos, float * z,
float * x, unsigned long Nx, float * y );

unsigned long nextpow2(unsigned long X);
int ispow2(unsigned long X);
int intlog2(unsigned long X);
void FFTInit(unsigned long N);
void FFTFree(void);
void RealFFT(float * x, unsigned long N);
void RealIFFT(float * x, unsigned long N);
unsigned long FFTNXCorr(
float * x1, unsigned long n1, float * x2, unsigned long n2, float * y );
void IIRsos(
float * x, unsigned long Nx,
#define DSP_INCLUDED
void *safe_malloc(unsigned long);
void safe_free(void *);

void IIRFilt(
float *h, unsigned long Nsos, float *z,
float *x, unsigned long Nx, float *y);

unsigned long nextpow2(unsigned long X);
int ispow2(unsigned long X);
int intlog2(unsigned long X);
void FFTInit(unsigned long N);
void FFTFree(void);
void RealFFT(float *x, unsigned long N);
void RealIFFT(float *x, unsigned long N);
unsigned long FFTNXCorr(
float *x1, unsigned long n1, float *x2, unsigned long n2, float *y);
void IIRsos(
float *x, unsigned long Nx,
float b0, float b1, float b2, float a1, float a2,
float * tz1, float * tz2 );
void IIRFilt(
float * h, unsigned long Nsos, float * z,
float * x, unsigned long Nx, float * y );
float *tz1, float *tz2);
void IIRFilt(
float *h, unsigned long Nsos, float *z,
float *x, unsigned long Nx, float *y);
#endif

#endif // _DSP_H_H
/* END OF FILE */
34 changes: 17 additions & 17 deletions pypesq/pesq.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,56 @@
#include "pesq.h"
#include "dsp.h"

static char module_docstring[] =
static char module_docstring[] =
"This module provides an interface for calculate PESQ.";
static char pesq_docstring[] =
static char pesq_docstring[] =
"Compute PESQ.";
static PyObject *_pesq(PyObject *self, PyObject *arg);

#if PY_MAJOR_VERSION >= 3
static PyMethodDef module_methods[] = {
{"_pesq", _pesq, METH_VARARGS, pesq_docstring},
{NULL, NULL, 0, NULL}
};
{NULL, NULL, 0, NULL}};

static struct PyModuleDef pesqmodule = {
PyModuleDef_HEAD_INIT,
"pesq_core",
module_docstring,
-1,
module_methods
};
module_methods};

PyMODINIT_FUNC PyInit_pesq_core(void){
import_array(); //essential for numpy
PyMODINIT_FUNC PyInit_pesq_core(void)
{
import_array(); //essential for numpy
return PyModule_Create(&pesqmodule);
};

#else
#else
static PyMethodDef PesqCoreMethods[] = {
{"_pesq", _pesq, METH_VARARGS, module_docstring},
{NULL, NULL, 0, NULL}
};
{NULL, NULL, 0, NULL}};

PyMODINIT_FUNC
initpesq_core(void){
initpesq_core(void)
{
PyObject *m;
import_array(); //essential for numpy
import_array(); //essential for numpy

m = Py_InitModule("pesq_core", PesqCoreMethods);
if (m == NULL)
return;

}
#endif

static PyObject *_pesq(PyObject *self, PyObject *args){
static PyObject *_pesq(PyObject *self, PyObject *args)
{

PyArrayObject *ref, *deg;
long fs;

if(!PyArg_ParseTuple(args, "O!O!l", &PyArray_Type, &ref,
&PyArray_Type, &deg, &fs)){
if (!PyArg_ParseTuple(args, "O!O!l", &PyArray_Type, &ref,
&PyArray_Type, &deg, &fs))
{
return NULL;
}

Expand Down
Loading

0 comments on commit d870dfa

Please sign in to comment.