// add a widget to both the ML and Juce worlds. The widget is retained by the Juce Component. // void MLWidgetContainer::addWidget(MLWidget* pW, const MLSymbol name) { MLSymbol newName; if (name) { if(mWidgets.find(name) != mWidgets.end()) { debug() << "MLWidgetContainer::addWidget: name " << name << " already taken! \n"; debug() << mWidgets.size() << " widgets:\n"; dumpWidgets(); theSymbolTable().dump(); theSymbolTable().audit(); } else { newName = name; } } else // get name for anon widgets { newName = mWidgetNamer.nextName(); } if(newName) { mWidgets[newName] = pW; pW->setWidgetName(newName); } pW->setContainer(this); // add parent JUCE component getComponent()->addChildComponent(pW->getComponent()); }
void MLPluginProcessor::prepareToPlay (double sr, int maxFramesPerBlock) { MLProc::err prepareErr; MLProc::err r = preflight(); if (!mpPluginDoc.get()) return; if (r == MLProc::OK) { // get the Juce process lock // TODO ??? const ScopedLock sl (getCallbackLock()); unsigned inChans = getNumInputChannels(); unsigned outChans = getNumOutputChannels(); mEngine.setInputChannels(inChans); mEngine.setOutputChannels(outChans); unsigned bufSize = 0; unsigned chunkSize = 0; // choose new buffer size and vector size. { // bufSize is the smallest power of two greater than maxFramesPerBlock. int maxFramesBits = bitsToContain(maxFramesPerBlock); bufSize = 1 << maxFramesBits; // vector size is desired processing block size, set this to default size of signal. chunkSize = min((int)bufSize, (int)kMLProcessChunkSize); } // dsp engine has one chunkSize of latency in order to run constant block size. setLatencySamples(chunkSize); // debug() << "MLPluginProcessor: prepareToPlay: rate " << sr << ", buffer size " << bufSize << ", vector size " << vecSize << ". \n"; // build: turn XML description into graph of processors if (mEngine.getGraphStatus() != MLProc::OK) { bool makeSignalInputs = inChans > 0; r = mEngine.buildGraphAndInputs(&*mpPluginDoc, makeSignalInputs, wantsMIDI()); // debug() << getNumParameters() << " parameters in description.\n"; } else { // debug() << "MLPluginProcessor graph OK.\n"; } #ifdef DEBUG theSymbolTable().audit(); //theSymbolTable().dump(); #endif // compile: schedule graph of processors , setup connections, allocate buffers if (mEngine.getCompileStatus() != MLProc::OK) { mEngine.compileEngine(); } else { debug() << "compile OK.\n"; } // prepare to play: resize and clear processors prepareErr = mEngine.prepareEngine(sr, bufSize, chunkSize); if (prepareErr != MLProc::OK) { debug() << "MLPluginProcessor: prepareToPlay error: \n"; } // mEngine.dump(); // after prepare to play, set state from saved blob if one exists const unsigned blobSize = mSavedParamBlob.getSize(); if (blobSize > 0) { setStateFromBlob (mSavedParamBlob.getData(), blobSize); mSavedParamBlob.setSize(0); } else { mEngine.clear(); if (!mHasParametersSet) { loadDefaultPreset(); } } if(!mInitialized) { initializeProcessor(); mInitialized = true; } mEngine.setEnabled(prepareErr == MLProc::OK); } }
// return a reference to the symbol's string in the table. const std::string& MLSymbol::getString() const { return theSymbolTable().getSymbolByID(mID); }
MLSymbol::MLSymbol(const std::string& str) { mID = theSymbolTable().getSymbolID(str.c_str()); }
MLSymbol::MLSymbol(const char *sym) { mID = theSymbolTable().getSymbolID(sym); }
MLSymbol::MLSymbol(const char *sym, int maxLen) { int len = processSymbolText(sym, maxLen); mID = theSymbolTable().getSymbolID(sym, len); }
MLSymbol::MLSymbol(const std::string& str) { int len = processSymbolText(str.c_str()); mID = theSymbolTable().getSymbolID(str.c_str(), len); }