Mercurial > hg > vamp-plugin-sdk
diff host/vamp-simple-host.cpp @ 190:1982246a3902
* Provide PluginWrapper method for getting hold of a nested wrapper
directly (a bit gross, but useful)
* Use the above to enable the simple host to adjust timestamps
appropriately when printing out results from input domain adapter
wrapped plugins
author | cannam |
---|---|
date | Wed, 17 Sep 2008 13:16:09 +0000 |
parents | 31eda4b11f2b |
children |
line wrap: on
line diff
--- a/host/vamp-simple-host.cpp Wed Sep 17 11:00:51 2008 +0000 +++ b/host/vamp-simple-host.cpp Wed Sep 17 13:16:09 2008 +0000 @@ -36,7 +36,6 @@ */ #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/vamp.h" @@ -59,8 +58,10 @@ using Vamp::PluginHostAdapter; using Vamp::RealTime; using Vamp::HostExt::PluginLoader; +using Vamp::HostExt::PluginWrapper; +using Vamp::HostExt::PluginInputDomainAdapter; -#define HOST_VERSION "1.1" +#define HOST_VERSION "1.3" enum Verbosity { PluginIds, @@ -328,6 +329,10 @@ int returnValue = 1; int progress = 0; + RealTime rt; + PluginWrapper *wrapper = 0; + RealTime adjustment = RealTime::zeroTime; + if (outputs.empty()) { cerr << "ERROR: Plugin has no outputs!" << endl; goto done; @@ -365,6 +370,13 @@ goto done; } + wrapper = dynamic_cast<PluginWrapper *>(plugin); + if (wrapper) { + PluginInputDomainAdapter *ida = + wrapper->getWrapper<PluginInputDomainAdapter>(); + if (ida) adjustment = ida->getTimestampAdjustment(); + } + for (size_t i = 0; i < sfinfo.frames; i += stepSize) { int count; @@ -391,9 +403,11 @@ } } + rt = RealTime::frame2RealTime(i, sfinfo.samplerate); + printFeatures - (i, sfinfo.samplerate, outputNo, plugin->process - (plugbuf, RealTime::frame2RealTime(i, sfinfo.samplerate)), + (RealTime::realTime2Frame(rt + adjustment, sfinfo.samplerate), + sfinfo.samplerate, outputNo, plugin->process(plugbuf, rt), out, useFrames); int pp = progress; @@ -404,7 +418,10 @@ } if (out) cerr << "\rDone" << endl; - printFeatures(sfinfo.frames, sfinfo.samplerate, outputNo, + rt = RealTime::frame2RealTime(sfinfo.frames, sfinfo.samplerate); + + printFeatures(RealTime::realTime2Frame(rt + adjustment, sfinfo.samplerate), + sfinfo.samplerate, outputNo, plugin->getRemainingFeatures(), out, useFrames); returnValue = 0;