void MLProcMatrix::process(const int frames) { const int inputs = min(kMLMatrixMaxIns, getNumInputs()); const int outputs = min(kMLMatrixMaxOuts, getNumOutputs()); if((inputs != mInputs) || (outputs != mOutputs)) { resize(); } if (mParamsChanged) { calcCoeffs(); } // TODO optimize, calc constants for (int j=1; j <= outputs; ++j) { MLSignal& y = getOutput(j); y.clear(); for (int i=1; i <= inputs; ++i) { const MLSignal& x = getInput(i); if (mGain[i][j] > 0.) { for (int n=0; n < frames; ++n) { y[n] += x[n]; } } } } }
void MLProcBiquad::process(const int frames) { const MLSignal& x = getInput(1); MLSignal& y = getOutput(); // const references are necessary to only read first sample // in case coefficients are constant. const MLSignal& A0 = mA0; const MLSignal& A1 = mA1; const MLSignal& A2 = mA2; const MLSignal& B1 = mB1; const MLSignal& B2 = mB2; calcCoeffs(frames); for (int n=0; n<frames; ++n) { float in, out; in = x[n]; out = A0[n]*in + A1[n]*mX1 + A2[n]*mX2 - B1[n]*mY1 - B2[n]*mY2; mX2 = mX1; mX1 = in; mY2 = mY1; mY1 = out; y[n] = out; } }
void myObj_mode(t_myObj *x, int input) { x->mode = CLAMP(input, 0, 1); myObj_clear(x); calcCoeffs(x); }
void myObj_cf(t_myObj *x, double input) { //myObj_clear(x); if(input>=33) { x->cfreq = input; x->cf = input * x->r_sr; // cf: normalized frequency } else { x->cfreq = 33; x->cf = 33 * x->r_sr; } calcCoeffs(x); }
std::pair<double, std::string> Integration::gauss(unsigned int n) { std::vector<double> points; getGaussPoints(n, points); std::vector< std::vector<double> > gaussMatrix; makeMatrix(points, gaussMatrix); std::vector<double> c; calcCoeffs(gaussMatrix, c); std::pair<double, std::string> g = calcGauss(points, c); return g; }
void myObj_poles(t_myObj *x, int input) { if(input>=2 && input<=20) { if(input%2==0) { // #poles must be even x->poles = input; } else { x->poles = --input; object_post((t_object *)x, "number of poles must be even\n\tsetting poles to %ld", x->poles); } myObj_clear(x); calcCoeffs(x); } else object_error((t_object *)x, "# poles out of range!"); }
void MLProcDCBlocker::process(const int frames) { const MLSignal& x = getInput(1); MLSignal& y = getOutput(); if (mParamsChanged) calcCoeffs(); for (int n = 0; n < frames; ++n) { y[n] = x[n] - xn1 + mR*yn1; xn1 = x[n]; yn1 = y[n]; } }
void MLProcHostPhasor::process(const int samples) { MLSignal& y = getOutput(); // coeffs if (mParamsChanged) { calcCoeffs(); } for (int n=0; n<samples; ++n) { // step output TODO proper ramp y[n] = mOmega; } }
void MprSimpleDtmfDetector::reset() { m_sampleCount = 0; m_currentDtmfDigit = -1; m_lastDtmfDigit = -1; m_sameDtmfDigitCount = 0; int i; for(i=0; i< ms_nFreqsToDetect; i++) { m_q1[i] = 0; m_q2[i] = 0; m_r[i] = 0; m_coefs[i] = 0; } // Now calculate new coefficients calcCoeffs(); }
void myObj_ripple(t_myObj *x, double input) { x->ripple = CLAMP(input, 0, 30); calcCoeffs(x); }