MLProc::err MLProcParamToSignal::resize() { int vecSize = getContextVectorSize(); MLSampleRate rate = getContextSampleRate(); mChangeList.setDims(vecSize); mChangeList.setSampleRate(rate); mChangeList.setGlideTime(mGlide); // TODO return OK; }
// set up coefficient signals MLProc::err MLProcBiquad::resize() { MLProc::err e = OK; int b = getContextVectorSize(); mA0.setDims(b); mA1.setDims(b); mA2.setDims(b); mB1.setDims(b); mB2.setDims(b); // TODO check return e; }
// MLProc::prepareToProcess() is called after all connections in DSP graph are made. // This is where sample rates and block sizes propagate through the graph, and // are checked for consistency. // Setup internal buffers and data to prepare for processing any attached input signals. // MLProcs have no concept of enabled -- it's up to the enclosing container to disable // itself if things go wrong here. // MLProc::err MLProc::prepareToProcess() { MLProc::err e = OK; // debug() << "preparing " << getClassName() << " \"" << getName() << "\" : " ; int ins = getNumInputs(); int outs = getNumOutputs(); float rate = getContextSampleRate(); int blockSize = getContextVectorSize(); // debug() << ins << " ins, " << outs << " outs, rate " << rate << ", blockSize " << blockSize << "\n"; // All inputs must have a signal connected. // So connect unconnected inputs to null input signal. for (int i=0; i<ins; i++) { if (!mInputs[i]) { mInputs[i] = &getContext()->getNullInput(); } } // set size and rate of output signals // TODO it looks like this allocation may be redundant because outputs are allocated in compile() already!? for (int i=1; i<=outs; ++i) { MLSignal& out = getOutput(i); if (&out) { out.setRate(rate); MLSample* outData = out.setDims(blockSize, getOutputFrameSize(i)); if (!outData) { e = memErr; goto bail; } } else { debug() << "MLProc::prepareToProcess: null output " << i << " for " << getName() << "! \n"; } //debug() << " out " << i << ": " << (void *)(MLSignal*)(&out) << ", " << out.getSize() << " samples.\n"; } e = resize(); // recalc params for new sample rate mParamsChanged = true; bail: return e; }
void MLProcDelayOutput::doParams() { // first get delay input. That's the MLProcDelayInput object with // the same name as us before the underscore. This is fairly brittle and // hackish. We don't have something like string parameters, so this // is the best I could come up with. MLProcContainer* myContainer = static_cast<MLProcContainer*>(getContext()); const std::string myName = getName().getString(); int dPos = myName.find('_'); MLPath delayName (myName.substr(0, dPos)); MLProcPtr myInputProc = myContainer->getProc(delayName); if (myInputProc) { //debug() << "MLProcDelayOutput " << getName() << " doParams found delay proc " << delayName << "!\n"; mpDelayInputProc = static_cast<MLProcDelayInput*>(&(*myInputProc)); if(mpDelayInputProc) { // must be power of two size MLSignal& buffer = mpDelayInputProc->getBuffer(); mLengthMask = buffer.getWidth() - 1; //debug() << "MLProcDelayOutput::doParams found buffer, length mask " << std::hex << mLengthMask << std::dec << "\n"; } } else { debug() << "MLProcDelayOutput::doParams: couldn't find delay proc " << delayName << "\n"; } if(getParam("backwards")) { mVectorDelay = getContextVectorSize(); } else { mVectorDelay = 0; } //debug() << "MLProcDelayOutput: vector delay " << mVectorDelay << "\n"; mParamsChanged = false; }