// Construct from components Foam::sixDOFqODE::sixDOFqODE(const IOobject& io) : IOdictionary(io), mass_(lookup("mass")), momentOfInertia_(lookup("momentOfInertia")), Xequilibrium_(lookup("equilibriumPosition")), linSpringCoeffs_(lookup("linearSpring")), linDampingCoeffs_(lookup("linearDamping")), Xrel_(lookup("Xrel")), U_(lookup("U")), Uaverage_(U_), rotation_ ( vector(lookup("rotationVector")), dimensionedScalar(lookup("rotationAngle")).value() ), omega_(lookup("omega")), omegaAverage_(omega_), omegaAverageAbsolute_(omega_), force_(lookup("force")), moment_(lookup("moment")), forceRelative_(lookup("forceRelative")), momentRelative_(lookup("momentRelative")), coeffs_(13, 0.0) { setCoeffs(); }
void processAudio(AudioBuffer &buffer){ setCoeffs(getLpFreq(), 0.8f); float delayTime = getParameterValue(PARAMETER_A); // get delay time value float feedback = getParameterValue(PARAMETER_B); // get feedback value float wetDry = getParameterValue(PARAMETER_D); // get gain value float delaySamples = delayTime * (DELAY_BUFFER_LENGTH-1); int size = buffer.getSize(); for (int ch = 0; ch<buffer.getChannels(); ++ch) { float* buf = buffer.getSamples(ch); process(size, buf, outBuf); // low pass filter for delay buffer for(int i = 0; i < size; i++){ outBuf[i] = outBuf[i] + feedback * delayBuffer.read(delaySamples); buf[i] = (1.f - wetDry) * buf[i] + wetDry * outBuf[i]; //crossfade for wet/dry balance delayBuffer.write(buf[i]); } } }
void processAudio(AudioBuffer &buffer){ float y[getBlockSize()]; setCoeffs(getLpFreq(), 0.8f); float delayTime = getParameterValue(PARAMETER_A); // get delay time value float feedback = getParameterValue(PARAMETER_B); // get feedback value float wetDry = getParameterValue(PARAMETER_D); // get gain value if(abs(time - delayTime) < 0.01) delayTime = time; else time = delayTime; float delaySamples = delayTime * (delayBuffer.getSize()-1); int size = buffer.getSize(); float* x = buffer.getSamples(0); process(size, x, y); // low pass filter for delay buffer for(int n = 0; n < size; n++){ //linear interpolation for delayBuffer index dSamples = olddelaySamples + (delaySamples - olddelaySamples) * n / size; y[n] = y[n] + feedback * delayBuffer.read(dSamples); x[n] = (1.f - wetDry) * x[n] + wetDry * y[n]; //crossfade for wet/dry balance delayBuffer.write(x[n]); } olddelaySamples = delaySamples; }
LpfDelayPatch() : x1(0.0f), x2(0.0f), y1(0.0f), y2(0.0f) { registerParameter(PARAMETER_A, "Delay"); registerParameter(PARAMETER_B, "Feedback"); registerParameter(PARAMETER_C, "Fc"); registerParameter(PARAMETER_D, "Dry/Wet"); setCoeffs(getLpFreq()/getSampleRate(), 0.6f); outBuf = new float[getBlockSize()]; }
LpfDelayPatch() : x1(0.0f), x2(0.0f), y1(0.0f), y2(0.0f), olddelaySamples(0.0f) { AudioBuffer* buffer = createMemoryBuffer(1, REQUEST_BUFFER_SIZE); delayBuffer.initialise(buffer->getSamples(0), buffer->getSize()); registerParameter(PARAMETER_A, "Delay", "Delay time"); registerParameter(PARAMETER_B, "Feedback", "Delay loop feedback"); registerParameter(PARAMETER_C, "Fc", "Filter cutoff frequency"); registerParameter(PARAMETER_D, "Dry/Wet", "Dry/wet mix"); setCoeffs(getLpFreq()/getSampleRate(), 0.6f); }
LpfDelayPhaserPatch() : x1(0.0f), x2(0.0f), y1(0.0f), y2(0.0f), _lfoPhase( 0.f ), depth( 1.f ), feedback( .7f ),_zm1( 0.f ) { registerParameter(PARAMETER_A, "Delay"); registerParameter(PARAMETER_B, "Feedback"); registerParameter(PARAMETER_C, "Fc"); registerParameter(PARAMETER_D, "Dry/Wet"); setCoeffs(getLpFreq()/getSampleRate(), 0.6f) ; Range( 440.f, 1600.f ); Rate( .5f ); outBuf = new float[getBlockSize()]; }
void processAudio(AudioBuffer &buffer){ int size = buffer.getSize(); float w, z; //implement with less arrays? setCoeffs(getLpFreq(), 0.8f); rate = 0.01f, depth = 0.3f; float delayTime = getParameterValue(PARAMETER_A); // get delay time value float feedback = getParameterValue(PARAMETER_B); // get feedback value float wetDry = getParameterValue(PARAMETER_D); // get gain value float delaySamples = delayTime * (DELAY_BUFFER_LENGTH-1); for (int ch = 0; ch<buffer.getChannels(); ++ch) { float* buf = buffer.getSamples(ch); process(size, buf, outBuf); // low pass filter for delay buffer float d = _dmin + (_dmax-_dmin) * ((sin( _lfoPhase ) + 1.f)/2.f); _lfoPhase += rate; if( _lfoPhase >= M_PI * 2.f ) _lfoPhase -= M_PI * 2.f; //update filter coeffs for( int i=0; i<6; i++ ) _alps[i].Delay( d ); for (int i = 0; i < size; i++){ outBuf[i] = outBuf[i] + feedback * delayBuffer.read(delaySamples); buf[i] = (1.f - wetDry) * buf[i] + wetDry * outBuf[i]; //crossfade for wet/dry balance delayBuffer.write(buf[i]); //calculate output z = _alps[0].Update(_alps[1].Update(_alps[2].Update(_alps[3].Update(_alps[4].Update(_alps[5].Update(buf[i] + _zm1 * (feedback*0.1))))))); _zm1 = z; buf[i] = buf[i] + z * depth; } } }