void processAudio(AudioBuffer &buffer){

    double rate = getSampleRate();
    

    unsigned int sampleDelay = getSampleDelay(getRampedParameterValue(PARAMETER_A), rate);
    sampleDelay = min(sampleDelay, bufferSize);
    float feedback = getRampedParameterValue(PARAMETER_B);
    float bias = getBiasExponent(1 - getRampedParameterValue(PARAMETER_C));
    float dryWetMix = getRampedParameterValue(PARAMETER_D);
    

    int size = buffer.getSize();

 	for(int ch = 0; ch<buffer.getChannels(); ++ch)
 	{
	    float* buf = buffer.getSamples(ch);

	    for (int i=0; i<size; ++i)
	    {
	      float delaySample = circularBuffer[writeIdx];
	      float v = buf[i] + circularBuffer[writeIdx] * feedback;
	      v = applyBias(v, bias);
	      circularBuffer[writeIdx] = min(1, max(-1, v)); // Guard: hard range limits.
	      buf[i] = linearBlend(buf[i], delaySample, dryWetMix);

	      writeIdx = (++writeIdx) % sampleDelay;
	    }
		
  	}
  }
Example #2
0
void BiasedDelay::processChannelBlock(int size, float* buf, float* delayBuf, int delayBufIdx){
  unsigned int sampleDelay = getSampleDelay(getParameterValue(PARAMETER_TIME));
  float feedback = getParameterValue(PARAMETER_FEEDBACK);
  float bias = getBiasExponent(1 - getParameterValue(PARAMETER_BIAS));
  float dryWetMix = getParameterValue(PARAMETER_DRYWET);
  
  for (int i=0; i<size; i++)
  {
    float delaySample = delayBuf[delayBufIdx];
    float v = buf[i] + delaySample * feedback;
    v = applyBias(v, bias);
    delayBuf[delayBufIdx] = softLimit(v); // Guard: range limit.
    buf[i] = sigmoidXFade(buf[i], delaySample, dryWetMix);
    
    delayBufIdx = (++delayBufIdx) % sampleDelay;
  }
}