MCPcopy Create free account
hub / github.com/Yaafe/Yaafe / initStep

Method initStep

src_cpp/yaafe-core/Engine.cpp:257–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255 }
256
257 inline bool Engine::initStep(ProcessFlow::Node& node) {
258 if (node.v.m_id == "Input") {
259 node.v.m_component = NULL;
260 StreamInfo outStreamInfo;
261 outStreamInfo.size = 1;
262 outStreamInfo.sampleStep = 1;
263 outStreamInfo.frameLength = 1;
264 // get samplerate
265 ParameterMap::const_iterator it = node.v.m_params.find("SampleRate");
266 if (it==node.v.m_params.end()) {
267 cerr << "WARNING: no SampleRate parameter specified for input !" << endl;
268 outStreamInfo.sampleRate = 44100;
269 } else {
270 outStreamInfo.sampleRate = atof(it->second.c_str());
271 }
272 node.v.m_output.add(new OutputBuffer(outStreamInfo));
273 return true;
274 }
275 Ports<StreamInfo> inStreamInfo;
276 for (ProcessFlow::LinkListCIt it=node.sources().begin();it!=node.sources().end();it++)
277 {
278 const ProcessFlow::Link* l = *it;
279 const Ports<OutputBuffer*>& outInfo = l->source->v.m_output;
280 // if (outInfo.size()!=1) {
281 // cerr << "ERROR: node " << node.v.m_id << " has multiple output stream info !" << endl;
282 // return false;
283 // }
284 inStreamInfo.add(l->targetInputPort, outInfo[l->sourceOutputPort].data->info());
285 }
286 if (node.v.m_id == "Output") {
287 node.v.m_component = NULL;
288 } else {
289 node.v.m_component = node.v.m_pool->get(node.v.m_id,node.v.m_params,inStreamInfo);
290 if (!node.v.m_component) {
291 cerr << "ERROR: cannot initialize component " << node.v.m_id << " !" << endl;
292 return false;
293 }
294 }
295 for (int i=0;i<node.sources().size();i++)
296 {
297 const ProcessFlow::Link* l = node.sources()[i];
298 InputBuffer* source = new InputBuffer(l->source->v.m_output[l->sourceOutputPort].data->info());
299 l->source->v.m_output[l->sourceOutputPort].data->bindInputBuffer(source);
300 node.v.m_input.add(l->targetInputPort, source);
301 }
302 if (node.v.m_id != "Output") {
303 node.v.m_output = node.v.m_component->getOutStreamInfo().map(buildOutputBufferFromInfo);
304 }
305 return true;
306 }
307
308 inline bool Engine::resetStep(ProcessFlow::Node& step) {
309 for (int i=0;i<step.v.m_input.size();++i)

Callers

nothing calls this directly

Calls 5

addMethod · 0.80
bindInputBufferMethod · 0.80
mapMethod · 0.80
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected