Example #1
0
MLProcPtr MLProcFactory::create(const ml::Symbol className, MLDSPContext* context)
{
	MLProcCreateFnT fn;
	MLProcPtr resultProc;
	
	// get named entry from registry
	FnRegistryT::const_iterator regEntry = procRegistry.find(className);
	
	if (regEntry != procRegistry.end()) 
	{
		// get creator fn from entry
		fn = regEntry->second;
		// call creator fn returning new MLProc subclass instance
		resultProc = fn();
		resultProc->setContext(context);
		
		// give root context pointer to new containers
		if(resultProc->isContainer())
		{
			MLProcContainer& resultContainer = static_cast<MLProcContainer&>(*resultProc);
			resultContainer.setRootContext(context->getRootContext());
		}
	}
	else
	{
		// TODO anything? 
		debug() << "MLProcFactory::create: class " << className << " not found!!";
	}
	
	return resultProc;
}
Example #2
0
MLProcContainer* MLMultProxy::getCopyAsContainer(int c)
{
	MLProcPtr p = mCopies[c];
	if (p->isContainer())
	{
		return static_cast<MLProcContainer*>(&(*p));
	}
	else
	{
		debug() << "MLMultProxy::getCopyAsContainer: error, copy " << c << " of template " << mTemplate->getName() << "is not container!\n";
		return 0;
	}
}
Example #3
0
// make a new instance of a named subclass of MLProc. 
//
MLProcPtr MLMultiContainer::newProc(const MLSymbol className, const MLSymbol procName) 
{
	MLProcPtr pNew;
	
	// call factory to get instance of processor class
	// sets context of new proc to this.
	pNew = theProcFactory.create(className, this);	
	if (!pNew)
	{
		debug() << "MLMultiContainer: newProc: couldn't create!\n";
	}
	else
	{
		pNew->setName(procName);
		pNew->setContext(this);
	}
	return pNew;
}
Example #4
0
MLProc::err MLMultiContainer::buildProc(juce::XmlElement* parent)
{
	err e = OK;
	const int copies = (int)mCopies.size();	
	const MLSymbol className(parent->getStringAttribute("class").toUTF8());
	const MLSymbol procName(parent->getStringAttribute("name").toUTF8());
	// debug() << "MLMultiContainer::buildProc (class=" << className << ", name=" << procName << ")\n";

	for(int i=0; i<copies; i++)
	{
		// add the specified proc to all subcontainers. 
		MLProcContainer* pCopy = getCopyAsContainer(i);
        if(pCopy != nullptr)
        {
            e = pCopy->addProc(className, procName);
            if (e == MLProc::OK)
            {
                MLPath procPath(procName);
                pCopy->setProcParams(procPath, parent);
                pCopy->setCopyIndex(i + 1);
                MLProcPtr p = pCopy->getProc(procPath);	
                if(p)
                {	
                    p->setup();
                    if (p->isContainer())
                    {	
                        MLProcContainer* pc = static_cast<MLProcContainer*>(&(*p));
                        pc->buildGraph(parent);
                    }
                }		
                else
                {
                    debug() << "MLMultiContainer::buildProc: getProc failed for new proc!\n";
                }
            }
        }
        else
        {
            debug() << "MLMultiContainer: null copy in buildProc ()!\n";
        }
	}
	return e;
}
Example #5
0
MLProcPtr MLProcFactory::create(const MLSymbol className, MLDSPContext* context)
{
	MLProcCreateFnT fn;
    MLProcPtr resultProc;
	
	// get named entry from registry
    FnRegistryT::const_iterator regEntry = procRegistry.find(className);
	
    if (regEntry != procRegistry.end()) 
    {
		// get creator fn from entry
		fn = regEntry->second;
		// call creator fn returning new MLProc subclass instance
        resultProc = fn();
		resultProc->setContext(context);
    }
	else
	{
		 // TODO anything? 
		debug() << "MLProcFactory::create: class " << className << " not found!!";
	}

    return resultProc;
}