Mercurial > hg > piper-vamp-js
comparison VamPipePluginLibrary.cpp @ 82:5bd5d48a1c21
Introduce "raw" process call in which the input is not serialised
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 09 Sep 2016 15:41:35 +0100 |
parents | 5e6ff69b4209 |
children | 171f92179c3e |
comparison
equal
deleted
inserted
replaced
81:5e6ff69b4209 | 82:5bd5d48a1c21 |
---|---|
191 | 191 |
192 return response; | 192 return response; |
193 } | 193 } |
194 | 194 |
195 string | 195 string |
196 VamPipePluginLibrary::processImpl(int pluginHandle, | |
197 const float *const *inputBuffers, | |
198 int sec, | |
199 int nsec) | |
200 { | |
201 RequestOrResponse response; | |
202 response.direction = RequestOrResponse::Response; | |
203 response.type = RRType::Process; | |
204 | |
205 try { | |
206 if (!m_mapper.isConfigured(pluginHandle)) { | |
207 throw runtime_error("plugin has not been configured"); | |
208 } | |
209 | |
210 Vamp::Plugin *plugin = m_mapper.handleToPlugin(pluginHandle); | |
211 Vamp::RealTime timestamp(sec, nsec); | |
212 | |
213 response.processResponse.features = plugin->process(inputBuffers, timestamp); | |
214 response.success = true; | |
215 | |
216 return writeResponse(response); | |
217 | |
218 } catch (const std::exception &e) { | |
219 return VampJson::fromException(e, RRType::Process).dump(); | |
220 } | |
221 | |
222 m_useBase64 = true; //!!! todo: return something raw as well! | |
223 } | |
224 | |
225 string | |
196 VamPipePluginLibrary::requestJsonImpl(string req) | 226 VamPipePluginLibrary::requestJsonImpl(string req) |
197 { | 227 { |
198 RequestOrResponse request; | 228 RequestOrResponse request; |
199 | 229 |
200 try { | 230 try { |
201 request = readRequest(req); | 231 request = readRequest(req); |
202 } catch (const std::exception &e) { | 232 } catch (const std::exception &e) { |
203 std::cerr << "FAILURE" << std::endl; | |
204 return VampJson::fromException(e, RRType::NotValid).dump(); | 233 return VampJson::fromException(e, RRType::NotValid).dump(); |
205 } | 234 } |
206 | 235 |
207 RequestOrResponse response; | 236 RequestOrResponse response; |
208 response.direction = RequestOrResponse::Response; | 237 response.direction = RequestOrResponse::Response; |
252 | 281 |
253 int channels = int(preq.inputBuffers.size()); | 282 int channels = int(preq.inputBuffers.size()); |
254 if (channels != m_mapper.getChannelCount(h)) { | 283 if (channels != m_mapper.getChannelCount(h)) { |
255 throw runtime_error("wrong number of channels supplied to process"); | 284 throw runtime_error("wrong number of channels supplied to process"); |
256 } | 285 } |
257 | 286 |
258 const float **fbuffers = new const float *[channels]; | 287 const float **fbuffers = new const float *[channels]; |
259 for (int i = 0; i < channels; ++i) { | 288 for (int i = 0; i < channels; ++i) { |
260 if (int(preq.inputBuffers[i].size()) != m_mapper.getBlockSize(h)) { | 289 if (int(preq.inputBuffers[i].size()) != m_mapper.getBlockSize(h)) { |
261 delete[] fbuffers; | 290 delete[] fbuffers; |
262 throw runtime_error("wrong block size supplied to process"); | 291 throw runtime_error("wrong block size supplied to process"); |