fazekasgy@37: /* fazekasgy@37: fazekasgy@37: * Vampy : This plugin is a wrapper around the Vamp plugin API. fazekasgy@37: * It allows for writing Vamp plugins in Python. fazekasgy@37: fazekasgy@37: * Centre for Digital Music, Queen Mary University of London. fazekasgy@37: * Copyright (C) 2008-2009 Gyorgy Fazekas, QMUL. (See Vamp sources fazekasgy@37: * for licence information.) fazekasgy@37: fazekasgy@37: */ fazekasgy@37: fazekasgy@37: /* fazekasgy@37: NOTES: There are two ways to implement the Vamp::Feature wrapper. fazekasgy@37: 1) We could keep a Vamp::Feature in the object and fazekasgy@37: convert the values on the fly as they are inserted. fazekasgy@37: However, this requires a way to convert back to Python for fazekasgy@37: this object to be fully usable in python code. These conversions fazekasgy@37: are otherwise unnecessary. fazekasgy@37: fazekasgy@37: 2) Keep the python attribute objects in a dict as it is normally fazekasgy@37: done in python classes, and convert when the object is returned. fazekasgy@37: This way the object is usable by the interpreter until it is returned fazekasgy@37: to the C++ plugin wrapper. fazekasgy@37: This is different form the Vampy:PyRealTime implementation where the fazekasgy@37: two-way conversion makes more sense (in fact required). Note: For fazekasgy@37: a host implementation option 1) will be required. fazekasgy@37: fazekasgy@37: */ fazekasgy@37: fazekasgy@37: #ifndef _PYFEATURE_H_ fazekasgy@37: #define _PYFEATURE_H_ fazekasgy@37: fazekasgy@37: #include "vamp-sdk/Plugin.h" fazekasgy@37: // #include "PyTypeInterface.h" fazekasgy@37: fazekasgy@37: fazekasgy@37: typedef struct { fazekasgy@37: PyObject_HEAD fazekasgy@37: PyObject *dict; fazekasgy@37: // Vamp::Plugin::Feature *feature; fazekasgy@37: /// pointer to type interface required: PyTypeInterface ti; fazekasgy@37: } FeatureObject; fazekasgy@37: Chris@79: extern PyTypeObject Feature_Type; fazekasgy@37: fazekasgy@37: #define PyFeature_CheckExact(v) ((v)->ob_type == &Feature_Type) fazekasgy@37: #define PyFeature_Check(v) PyObject_TypeCheck(v, &Feature_Type) fazekasgy@37: fazekasgy@37: ///fast macro version as per API convention fazekasgy@37: #define PyFeature_AS_DICT(v) ((const FeatureObject* const) (v))->dict fazekasgy@37: // #define PyFeature_AS_FEATURE(v) ((const FeatureObject* const) (v))->feature fazekasgy@37: fazekasgy@37: fazekasgy@37: /* PyFeature C++ API */ fazekasgy@37: fazekasgy@37: /* Not required here: fazekasgy@37: we will never have to pass a feature back from the wrapper */ fazekasgy@37: // PyAPI_FUNC(PyObject *) fazekasgy@37: // PyFeature_FromFeature(Vamp::Plugin::Feature&); fazekasgy@37: fazekasgy@37: // PyAPI_FUNC(const Vamp::Plugin::Feature*) fazekasgy@37: // PyFeature_AsFeature (PyObject *self); fazekasgy@37: fazekasgy@37: fazekasgy@37: fazekasgy@37: #endif