Mercurial > hg > piper-cpp
comparison vamp-client/qt/PiperAutoPlugin.h @ 210:df65480a08de
Merge branch 'master' into dev/rename-pluginstub
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Thu, 09 Feb 2017 14:22:31 +0000 |
parents | c67a0a945b6b |
children | 3db4c7998faf |
comparison
equal
deleted
inserted
replaced
208:c67a0a945b6b | 210:df65480a08de |
---|---|
44 | 44 |
45 namespace piper_vamp { | 45 namespace piper_vamp { |
46 namespace client { | 46 namespace client { |
47 | 47 |
48 /** | 48 /** |
49 * This "plugin" make the Piper client abstraction behave like a local | 49 * AutoPlugin presents a Piper feature extractor in the form of a Vamp |
50 * Vamp plugin, with its own server that lasts only for the lifetime | 50 * plugin, managing its own single-use server instance. That is, the |
51 * of this plugin and serves only it. | 51 * distinguishing quality of AutoPlugin (in comparison with |
52 * PluginStub) is that it runs and terminates its own Piper server, | |
53 * whose lifetime matches that of the plugin. | |
54 * | |
55 * Example usage: | |
56 * | |
57 * Vamp::Plugin *plugin = | |
58 * new AutoPlugin("piper-server-name.exe", | |
59 * "vamp-example-plugins:zerocrossing", | |
60 * 44100.0f, | |
61 * Vamp::HostExt::PluginLoader::ADAPT_ALL_SAFE, | |
62 * nullptr); | |
63 * plugin->initialise(...); | |
64 * plugin->process(...); <-- in the normal way for a Vamp plugin | |
65 * delete plugin; <-- causes the server to exit | |
66 * | |
67 * AutoPlugin makes use of the Loader and PluginClient interfaces, | |
68 * providing them its own transport layer object for its single server. | |
52 * | 69 * |
53 * Note that any method may throw ServerCrashed, RequestTimedOut or | 70 * Note that any method may throw ServerCrashed, RequestTimedOut or |
54 * ProtocolError exceptions. | 71 * ProtocolError exceptions. |
55 */ | 72 */ |
56 class PiperAutoPlugin : public Vamp::Plugin | 73 class PiperAutoPlugin : public Vamp::Plugin |
57 { | 74 { |
58 public: | 75 public: |
76 /** | |
77 * Construct a PiperAutoPlugin that runs an instance of the Piper | |
78 * server with the given server name (executable path), requesting | |
79 * the given plugin key from the server. | |
80 * | |
81 * \param adapterFlags a bitwise OR of the values in the | |
82 * Vamp::HostExt::PluginLoader::AdapterFlags enumeration | |
83 * | |
84 * \param logger an optional callback for log messages. Pass a | |
85 * null pointer to use cerr instead. | |
86 */ | |
59 PiperAutoPlugin(std::string serverName, | 87 PiperAutoPlugin(std::string serverName, |
60 std::string pluginKey, | 88 std::string pluginKey, |
61 float inputSampleRate, | 89 float inputSampleRate, |
62 int adapterFlags, | 90 int adapterFlags, |
63 LogCallback *logger) : // logger may be nullptr for cerr | 91 LogCallback *logger) : // logger may be nullptr for cerr |
79 } | 107 } |
80 } | 108 } |
81 | 109 |
82 virtual ~PiperAutoPlugin() { | 110 virtual ~PiperAutoPlugin() { |
83 delete m_plugin; | 111 delete m_plugin; |
112 // The transport is a plain data member and will be deleted | |
113 // here, which will have the effect of terminating the server | |
84 } | 114 } |
85 | 115 |
86 bool isOK() const { | 116 bool isOK() const { |
87 return (m_plugin != nullptr); | 117 return (m_plugin != nullptr); |
88 } | 118 } |