MCPcopy Create free account
hub / github.com/christophhart/HISE / addModule

Method addModule

hi_scripting/scripting/api/ScriptingApiObjects.cpp:5330–5384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5328}
5329
5330Processor* ApiHelpers::ModuleHandler::addModule(Chain* c, const String& type, const String& id, int index /*= -1*/)
5331{
5332 WARN_IF_AUDIO_THREAD(true, IllegalAudioThreadOps::HeapBlockAllocation);
5333
5334 for (int i = 0; i < c->getHandler()->getNumProcessors(); i++)
5335 {
5336 if (c->getHandler()->getProcessor(i)->getId() == id)
5337 {
5338 return c->getHandler()->getProcessor(i);
5339 }
5340 }
5341
5342 SuspendHelpers::ScopedTicket ticket(parent->getMainController());
5343
5344 parent->getMainController()->getJavascriptThreadPool().killVoicesAndExtendTimeOut(getScriptProcessor());
5345
5346 LockHelpers::freeToGo(parent->getMainController());
5347
5348 ScopedPointer<Processor> newProcessor = parent->getMainController()->createProcessor(c->getFactoryType(), type, id);
5349
5350 if (newProcessor == nullptr)
5351 throw String("Module with type " + type + " could not be generated.");
5352
5353 // Now we're safe...
5354 Processor* pFree = newProcessor.release();
5355
5356 auto addFunction = [c, index](Processor* p)
5357 {
5358 if (c == nullptr)
5359 {
5360 delete p; // Rather bad...
5361 jassertfalse;
5362 return SafeFunctionCall::OK;
5363 }
5364
5365 if (index >= 0 && index < c->getHandler()->getNumProcessors())
5366 {
5367 Processor* sibling = c->getHandler()->getProcessor(index);
5368 c->getHandler()->add(p, sibling);
5369 }
5370 else
5371 c->getHandler()->add(p, nullptr);
5372
5373 return SafeFunctionCall::OK;
5374 };
5375
5376
5377
5378
5379
5380 parent->getMainController()->getGlobalAsyncModuleHandler().addAsync(pFree, addFunction);
5381
5382 // will be owned by the job, then by the handler...
5383 return pFree;
5384}
5385
5386hise::Modulator* ApiHelpers::ModuleHandler::addAndConnectToGlobalModulator(Chain* c, Modulator* globalModulator, const String& modName, bool connectAsStaticMod/*=false*/)
5387{

Callers 3

addModulatorMethod · 0.45
addModulatorMethod · 0.45
addEffectMethod · 0.45

Calls 12

addAsyncMethod · 0.80
StringClass · 0.50
getNumProcessorsMethod · 0.45
getHandlerMethod · 0.45
getIdMethod · 0.45
getProcessorMethod · 0.45
getMainControllerMethod · 0.45
createProcessorMethod · 0.45
getFactoryTypeMethod · 0.45
releaseMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected