All pastes #293586 Raw Edit

tsmithe

public c v1 · immutable
#293586 ·published 2006-12-27 19:08 UTC
rendered paste body
#ifndef PYFOOID_H#define PYFOOID_H#include <fooid.h>#include <Python.h>#ifndef PyMODINIT_FUNC	/* declarations for DLL import/export */#define PyMODINIT_FUNC void#endif/*The following is from libfooid's common.hCopyright (C) 2006 Gian-Carlo Pascutto, Hogeschool GentIt is licenced under the GPLv2 or BSD licence.As it is available under the BSD licence, I will take advantage of thatand declare it GPLv2.*/#define FRAME_LEN                8192#define SPEC_LEN       (FRAME_LEN / 2)#define MAX_BARK                   17typedef struct t_fingerprint t_fingerprint;/* fingerprint storage */struct t_fingerprint{    /* fingerprint version */    short version;    /* length in centiseconds */    int length;    /* average line fit, times 1000 */    short avg_fit;    /* average dominant line, times 100 */            short avg_dom;        /* spectral fits, 4 bits times 16 bands = 32 times 87 frames        -> 348 bytes */    unsigned char r[348];    /* spectral doms, 6 bits times 87 frames = 65.25 */    unsigned char dom[66];        };/* processing storage */struct t_fooid{    /*  spectral stuff */    float window[SPEC_LEN];    int line_to_cb[SPEC_LEN];    int cb_start[MAX_BARK];    int cb_size[MAX_BARK];    int max_sfb;        /*  settings stuff */    int channels;    int samplerate;        /* buffer stuff */    float *samples;    float *sbuffer;        int soundfound;            /* resampling stuff */    float resample_ratio;        void *resample_h;    int outpos;            /* actual fingerprint */    struct t_fingerprint fp;    };/* End common.h section */typedef struct {	PyObject_HEAD	struct t_fooid * fooid; 	} fooid_fooidObject;typedef struct {	PyObject_HEAD	unsigned char * buff;	} fooid_buffObject;static PyTypeObject fooid_buffType = {	PyObject_HEAD_INIT(NULL)	0,                         /*ob_size*/	"fooid.buff",              /*tp_name*/	sizeof(fooid_buffObject),  /*tp_basicsize*/	0,                         /*tp_itemsize*/	0,                         /*tp_dealloc*/	0,                         /*tp_print*/	0,                         /*tp_getattr*/	0,                         /*tp_setattr*/	0,                         /*tp_compare*/	0,                         /*tp_repr*/	0,                         /*tp_as_number*/	0,                         /*tp_as_sequence*/	0,                         /*tp_as_mapping*/	0,                         /*tp_hash */	0,                         /*tp_call*/	0,                         /*tp_str*/	0,                         /*tp_getattro*/	0,                         /*tp_setattro*/	0,                         /*tp_as_buffer*/	Py_TPFLAGS_DEFAULT,        /*tp_flags*/	"fooid objects",           /*tp_doc */	};PyMODINIT_FUNC initfooid(void);static void	fooid_dealloc(fooid_fooidObject * self);static PyObject *	fooid_new(PyTypeObject * type, PyObject * args, PyObject * kwds);static PyObject *		fooid_fp_init(PyObject * self, PyObject * args);static PyObject *	fooid_fp_free(PyObject * self, PyObject * args);static PyObject *	fooid_fp_feed_short(PyObject * self, PyObject * args);static PyObject *	fooid_fp_feed_float(PyObject * self, PyObject * args);static PyObject *	fooid_fp_getsize(PyObject * self, PyObject * args);static PyObject *	fooid_fp_getversion(PyObject * self, PyObject * args);static PyObject *	fooid_fp_calculate(PyObject * self, PyObject * args);static PyMethodDef fooidMethods[] = {	{"fp_init",  fooid_fp_init, METH_VARARGS,	"Initialise libfooid."},	{"fp_free",  fooid_fp_free, METH_VARARGS,	"Free a fingerprinter handle."},	{"fp_feed_short", fooid_fp_feed_short, METH_VARARGS,	"Feed a buffer of samples to the fingerprinting generator."},	{"fp_feed_float", fooid_fp_feed_float, METH_VARARGS,	"As for fp_feed_short, but for 32-bit IEEE floats."},	{"fp_getsize", fooid_fp_getsize, METH_VARARGS,	"Returns the size of the fingerprint that this library will generate."},	{"fp_getversion", fooid_fp_getversion, METH_VARARGS,	"Returns the fingerprint version number that this library will generate."},	{"fp_calculate", fooid_fp_calculate, METH_VARARGS,	"Calculate the fingerprint."},	{NULL, NULL, 0, NULL}        /* Sentinel */	};static PyMemberDef fooidMembers[] = {    {"fooid", T_OBJECT_EX, offsetof(fooid, fooid), 0,     "fooid"},    {NULL}  /* Sentinel */};static PyTypeObject fooid_fooidType = {	PyObject_HEAD_INIT(NULL)	0,                         /*ob_size*/	"fooid.fooid",             /*tp_name*/	sizeof(fooid_fooidObject), /*tp_basicsize*/	0,                         /*tp_itemsize*/	(destructor)fooid_dealloc, /*tp_dealloc*/	0,                         /*tp_print*/	0,                         /*tp_getattr*/	0,                         /*tp_setattr*/	0,                         /*tp_compare*/	0,                         /*tp_repr*/	0,                         /*tp_as_number*/	0,                         /*tp_as_sequence*/	0,                         /*tp_as_mapping*/	0,                         /*tp_hash */	0,                         /*tp_call*/	0,                         /*tp_str*/	0,                         /*tp_getattro*/	0,                         /*tp_setattro*/	0,                         /*tp_as_buffer*/	Py_TPFLAGS_DEFAULT,        /*tp_flags*/	"fooid objects",           /*tp_doc */	0,		           /* tp_traverse */	0,		           /* tp_clear */	0,		           /* tp_richcompare */	0,		           /* tp_weaklistoffset */	0,		           /* tp_iter */	0,		           /* tp_iternext */	fooidMethods,              /* tp_methods */	fooidMembers,              /* tp_members (fooidMembers)*/	0,                         /* tp_getset */	0,                         /* tp_base */	0,                         /* tp_dict */	0,                         /* tp_descr_get */	0,                         /* tp_descr_set */	0,                         /* tp_dictoffset */	(initproc)initfooid,       /* tp_init */	0,                         /* tp_alloc */	fooid_new,     		   /* tp_new */	};#endif