Mercurial > hg > piper-cpp
comparison vamp-client/PiperVampPlugin.h @ 287:09753ad777db
Add support for ProgramParameters. In theory this means we can select a program and then re-query the plugin's parameters and get the right values back, just as would happen if we were working with the remote extractor directly as a local Vamp plugin.
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 07 Apr 2020 15:56:02 +0100 |
parents | 4b581a498981 |
children | 26027c3a99a0 |
comparison
equal
deleted
inserted
replaced
286:b3b2e092bd61 | 287:09753ad777db |
---|---|
39 #include <vamp-hostsdk/Plugin.h> | 39 #include <vamp-hostsdk/Plugin.h> |
40 #include <vamp-hostsdk/PluginLoader.h> | 40 #include <vamp-hostsdk/PluginLoader.h> |
41 | 41 |
42 #include "vamp-support/PluginStaticData.h" | 42 #include "vamp-support/PluginStaticData.h" |
43 #include "vamp-support/PluginConfiguration.h" | 43 #include "vamp-support/PluginConfiguration.h" |
44 #include "vamp-support/PluginProgramParameters.h" | |
44 | 45 |
45 #include "PluginClient.h" | 46 #include "PluginClient.h" |
46 | 47 |
47 #include <cstdint> | 48 #include <cstdint> |
48 #include <iostream> | 49 #include <iostream> |
105 PiperVampPlugin(PluginClient *client, | 106 PiperVampPlugin(PluginClient *client, |
106 std::string pluginKey, | 107 std::string pluginKey, |
107 float inputSampleRate, | 108 float inputSampleRate, |
108 int adapterFlags, | 109 int adapterFlags, |
109 PluginStaticData psd, | 110 PluginStaticData psd, |
110 PluginConfiguration defaultConfig) : | 111 PluginConfiguration defaultConfig, |
112 PluginProgramParameters programParameters) : | |
111 Plugin(inputSampleRate), | 113 Plugin(inputSampleRate), |
112 m_client(client), | 114 m_client(client), |
113 m_key(pluginKey), | 115 m_key(pluginKey), |
114 m_adapterFlags(adapterFlags), | 116 m_adapterFlags(adapterFlags), |
115 m_state(Loaded), | 117 m_state(Loaded), |
116 m_psd(psd), | 118 m_psd(psd), |
117 m_defaultConfig(defaultConfig), | 119 m_defaultConfig(defaultConfig), |
118 m_config(defaultConfig) | 120 m_config(defaultConfig), |
121 m_programParameters(programParameters) | |
119 { } | 122 { } |
120 | 123 |
121 virtual ~PiperVampPlugin() { | 124 virtual ~PiperVampPlugin() { |
122 if (m_state != Finished && m_state != Failed) { | 125 if (m_state != Finished && m_state != Failed) { |
123 try { | 126 try { |
191 if (m_state != Loaded) { | 194 if (m_state != Loaded) { |
192 m_state = Failed; | 195 m_state = Failed; |
193 throw std::logic_error("Can't select program after plugin initialised"); | 196 throw std::logic_error("Can't select program after plugin initialised"); |
194 } | 197 } |
195 m_config.currentProgram = program; | 198 m_config.currentProgram = program; |
199 | |
200 const auto &pp = m_programParameters.programParameters; | |
201 if (pp.find(program) != pp.end()) { | |
202 for (auto param: pp.at(program)) { | |
203 m_config.parameterValues[param.first] = param.second; | |
204 } | |
205 } | |
196 } | 206 } |
197 | 207 |
198 bool initialise(size_t inputChannels, | 208 bool initialise(size_t inputChannels, |
199 size_t stepSize, | 209 size_t stepSize, |
200 size_t blockSize) override { | 210 size_t blockSize) override { |
201 | 211 |
202 if (m_state == Failed) { | 212 if (m_state == Failed) { |
203 throw std::logic_error("Plugin is in failed state"); | 213 throw std::logic_error("Plugin is in failed state"); |
204 } | 214 } |
205 | 215 |
410 State m_state; | 420 State m_state; |
411 PluginStaticData m_psd; | 421 PluginStaticData m_psd; |
412 OutputList m_outputs; | 422 OutputList m_outputs; |
413 PluginConfiguration m_defaultConfig; | 423 PluginConfiguration m_defaultConfig; |
414 PluginConfiguration m_config; | 424 PluginConfiguration m_config; |
425 PluginProgramParameters m_programParameters; | |
415 }; | 426 }; |
416 | 427 |
417 } | 428 } |
418 } | 429 } |
419 | 430 |