Mercurial > hg > vampy-host
changeset 1:cb0d3af1be4d
Update for current Vamp host sdk API
author | Chris Cannam |
---|---|
date | Mon, 29 Oct 2012 08:20:06 +0000 |
parents | 68f3f32565b4 |
children | e30eda0b5e2d |
files | Makefile pyRealTime.cpp pyRealTime.h vampyhost.cpp vampyhost.h vampyhost_test.py |
diffstat | 6 files changed, 41 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Mon Oct 22 16:10:46 2012 +0100 +++ b/Makefile Mon Oct 29 08:20:06 2012 +0000 @@ -1,7 +1,11 @@ -CFLAGS := -O2 -Wall -I/usr/include/python2.5 -I/usr/include/vamp-sdk/hostext/ -I/usr/include/vamp-sdk/ -I/Users/Shared/Development/vampy-host-experiments/ -CXXFLAGS := -O2 -Wall -I/usr/include/python2.5 -I/usr/include/vamp-sdk/hostext/ -I/usr/include/vamp-sdk/ -I/Users/Shared/Development/vampy-host-experiments/ -LDFLAGS := -dynamiclib -lpython2.5 /usr/lib/libvamp-hostsdk.a +PY_INCLUDE_PATH := /usr/include/python2.7 + +CFLAGS := -O2 -Wall -I$(PY_INCLUDE_PATH) -I. +CXXFLAGS := -O2 -Wall -I$(PY_INCLUDE_PATH) -I. + +LDFLAGS := -shared -lpython2.7 -lvamp-hostsdk +#LDFLAGS := -dynamiclib -lpython2.5 /usr/lib/libvamp-hostsdk.a all: pyRealTime.so vampyhost.so @@ -20,4 +24,3 @@ rm *.o rm *.so rm *.a -
--- a/pyRealTime.cpp Mon Oct 22 16:10:46 2012 +0100 +++ b/pyRealTime.cpp Mon Oct 29 08:20:06 2012 +0000 @@ -15,7 +15,7 @@ #include <Python.h> #include <pyRealTime.h> -#include "vamp-sdk/Plugin.h" +#include "vamp-hostsdk/Plugin.h" #include <string> using namespace std; @@ -186,7 +186,7 @@ PyObject_New(RealTimeObject, &RealTime_Type); if (result == NULL) return NULL; - result->rt = new RealTime::RealTime( + result->rt = new RealTime( *((RealTimeObject*)s)->rt + *((RealTimeObject*)w)->rt); return (PyObject*)result; } @@ -199,7 +199,7 @@ PyObject_New(RealTimeObject, &RealTime_Type); if (result == NULL) return NULL; - result->rt = new RealTime::RealTime( + result->rt = new RealTime( *((RealTimeObject*)s)->rt - *((RealTimeObject*)w)->rt); return (PyObject*)result; } @@ -305,7 +305,7 @@ if (self == NULL) return NULL; - self->rt = new RealTime::RealTime( + self->rt = new RealTime( RealTime::frame2RealTime(frame,sampleRate)); return (PyObject *) self; @@ -346,18 +346,18 @@ self->rt = NULL; if (sec == 0 && nsec == 0 && fmt == 0) - self->rt = new RealTime::RealTime(); + self->rt = new RealTime(); else if (fmt == 0) - self->rt = new RealTime::RealTime(sec,nsec); + self->rt = new RealTime(sec,nsec); else { if (!string(fmt).compare("float") || !string(fmt).compare("seconds")) - self->rt = new RealTime::RealTime( + self->rt = new RealTime( RealTime::fromSeconds((double) unary)); if (!string(fmt).compare("milliseconds")) { - self->rt = new RealTime::RealTime( + self->rt = new RealTime( RealTime::fromSeconds((double) unary / 1000.0)); } } @@ -408,7 +408,7 @@ PyObject_New(RealTimeObject, &RealTime_Type); if (self == NULL) return NULL; - self->rt = new RealTime::RealTime(*rt); + self->rt = new RealTime(*rt); return (PyObject*) self; //TODO: check if we need to INCREF here }
--- a/pyRealTime.h Mon Oct 22 16:10:46 2012 +0100 +++ b/pyRealTime.h Mon Oct 29 08:20:06 2012 +0000 @@ -2,19 +2,19 @@ #ifndef _PYREALTIME_H_ #define _PYREALTIME_H_ -#include "vamp-sdk/Plugin.h" +#include "vamp-hostsdk/Plugin.h" /* RealTime Type Object's structure */ /* Doc:: 10.2 Common Object Structures */ typedef struct { PyObject_HEAD /*PyObject *rt_attrs;*/ - Vamp::RealTime::RealTime *rt; + Vamp::RealTime *rt; } RealTimeObject; PyAPI_DATA(PyTypeObject) RealTime_Type; -#define PyRealTime_CheckExact(v) ((v)->ob_type == &RealTime_Type) +#define PyRealTime_CheckExact(v) ((v)->ob_type == &RealTime_Type) #define PyRealTime_Check(v) PyObject_TypeCheck(v, &RealTime_Type) /* pyRealTime C API functions */ @@ -30,8 +30,8 @@ PyAPI_FUNC(PyObject *) PyRealTime_FromRealTime(Vamp::RealTime *rt); -PyAPI_FUNC(Vamp::RealTime::RealTime *) -PyRealTime_AsPointer (PyObject *self); +PyAPI_FUNC(Vamp::RealTime *) +PyRealTime_AsPointer(PyObject *self); /* PyRealTime Module functions */
--- a/vampyhost.cpp Mon Oct 22 16:10:46 2012 +0100 +++ b/vampyhost.cpp Mon Oct 29 08:20:06 2012 +0000 @@ -6,11 +6,11 @@ #include <pyRealTime.h> //includes for vamp host -#include "vamp-sdk/Plugin.h" -#include "vamp-sdk/PluginHostAdapter.h" -#include "vamp-sdk/hostext/PluginChannelAdapter.h" -#include "vamp-sdk/hostext/PluginInputDomainAdapter.h" -#include "vamp-sdk/hostext/PluginLoader.h" +#include "vamp-hostsdk/Plugin.h" +#include "vamp-hostsdk/PluginHostAdapter.h" +#include "vamp-hostsdk/PluginChannelAdapter.h" +#include "vamp-hostsdk/PluginInputDomainAdapter.h" +#include "vamp-hostsdk/PluginLoader.h" //#include "vamp/vamp.h" #include <iostream>
--- a/vampyhost.h Mon Oct 22 16:10:46 2012 +0100 +++ b/vampyhost.h Mon Oct 29 08:20:06 2012 +0000 @@ -3,7 +3,7 @@ #ifndef _VAMPYHOST_H_ #define _VAMPYHOST_H_ -#include "vamp-sdk/Plugin.h" +#include "vamp-hostsdk/Plugin.h" #include <string> // structure of NumPy array intrface (just a hack, shouldn't be needed here...)
--- a/vampyhost_test.py Mon Oct 22 16:10:46 2012 +0100 +++ b/vampyhost_test.py Mon Oct 29 08:20:06 2012 +0000 @@ -1,10 +1,12 @@ import sys -sys.path.append('/Users/Shared/Development/python-extensions') -sys.path.append('/Users/Shared/Development/vampy-host-experiments/') +import os + +sys.path.append(os.getcwd()) + #from melscale import melscale #from melscale import initialize -import wave +import wave from wave import * from pylab import * # from melscale import * @@ -13,22 +15,22 @@ from time import * from vampyhost import * -import vampyhost +import vampyhost import vampyhost as vh #import pyRealTime #from pyRealTime import * #deal with an audio file -wavfile='/Users/Shared/multitrack (small)/mix.wav' +wavfile='test.wav' wavobj = wave.open(wavfile,'r') samplerate = wavobj.getframerate() print "samplerate: ",samplerate print "number of samples (frames): ",wavobj.getnframes() #total number of samples 4647744 channels = wavobj.getnchannels(); -print "channels: ",channels -print "sample-width: ",wavobj.getsampwidth() +print "channels: ",channels +print "sample-width: ",wavobj.getsampwidth() print "position: ",wavobj.tell() wavobj.setpos(1000000) @@ -56,10 +58,10 @@ self.timestamp self.values self.label - + pluginlist = vh.enumeratePlugins() for i,n in enumerate(pluginlist) : print i,":",n -pluginKey=pluginlist[12]; +pluginKey=pluginlist[0]; # try the first plugin listed retval = vh.getLibraryPath(pluginKey) print pluginKey @@ -86,7 +88,7 @@ #print output[1].label print "_______________OUTPUT TYPE_________:",type(out) -in_audio = frombuffer(audio,int16,-1,0) +in_audio = frombuffer(audio,int16,-1,0) out_audio = frombuffer(out,float32,-1,0) subplot(211) plot(in_audio) @@ -104,7 +106,7 @@ #output is a list of list of features vh.unloadPlugin(handle); -vh.unloadPlugin(handle); # test if it chrashes... +vh.unloadPlugin(handle); # test if it chrashes... print vh.getOutputList(handle) @@ -115,4 +117,4 @@ #oneSamplePerStep, FixedSamplerate : can return numpy array #variableSamplerate : list of featres only -#print dir(vampyhost) \ No newline at end of file +#print dir(vampyhost)