DroneBoxPatch()
  : mRamp(0.1)
  , mPrevCoarsePitch(-1.)
  , mPrevFinePitch(-1.)
  , mPrevDecay(-1.)
  {
    registerParameter(PARAMETER_A, "Coarse Pitch", "Coarse Pitch");
    registerParameter(PARAMETER_B, "Fine Pitch", "Fine Pitch");
    registerParameter(PARAMETER_C, "Decay", "Decay");
    registerParameter(PARAMETER_D, "Mix", "Mix");

    mOldValues[0] = 0.f; 
    mOldValues[1] = 0.f;
    mOldValues[2] = 0.f;
    mOldValues[3] = 0.f;
    
    for (int c=0;c<NUM_COMBS;c++)
    {
      AudioBuffer* buffer = createMemoryBuffer(2, BUF_SIZE);
      mCombs[c].setBuffer(buffer->getSamples(0), buffer->getSamples(1));
      mCombs[c].setSampleRate(getSampleRate());
      mCombs[c].clearBuffer();
    }
    
    mDCBlockerL.setSampleRate(getSampleRate());
    mDCBlockerR.setSampleRate(getSampleRate());
  }
  void processAudio(AudioBuffer &buffer)
  {
    const int size = buffer.getSize();
    const float coarsePitch = getRampedParameterValue(PARAMETER_A);
    const float finePitch = getRampedParameterValue(PARAMETER_B);
    const float decay = getRampedParameterValue(PARAMETER_C);
    const float mix = getRampedParameterValue(PARAMETER_D);
    
    if (coarsePitch != mPrevCoarsePitch || finePitch != mPrevFinePitch || decay != mPrevDecay)
    {
      const float freq = midi2CPS(MIN_PITCH + floorf(mPrevCoarsePitch * PITCH_RANGE) + finePitch);
      
      for (int c = 0; c < NUM_COMBS; c++) 
      {
        mCombs[c].setFreqCPS(freq * FREQ_RATIOS[c]);
        mCombs[c].setDecayTimeMs(MIN_DECAY + (decay * DECAY_RANGE));
      }
      
      mPrevCoarsePitch = coarsePitch;
      mPrevFinePitch = finePitch;
      mPrevDecay = decay;
    }
        
    float* bufL = buffer.getSamples(0);
    float* bufR = buffer.getSamples(1);

    for(int i = 0; i < size; i++)
    {
      float ipsL = bufL[i];
      float ipsR = bufR[i];
      float opsL = 0.f;
      float opsR = 0.f;
            
      const float smoothMix = mMixSmoother.process(mix);
      const float invSmoothMix = 1.f-smoothMix;
      
      for (int c = 0; c < NUM_COMBS; c++) 
      {
         mCombs[c].process(ipsL, ipsR, &opsL, &opsR);
      }
      
      bufL[i] = mDCBlockerL.process( ((opsL * 0.1f) * smoothMix) + (ipsL * invSmoothMix) );
      bufR[i] = mDCBlockerR.process( ((opsR * 0.1f) * smoothMix) + (ipsR * invSmoothMix) );
    }
  }  
Beispiel #3
0
 void processAudio(AudioBuffer &buffer)
  {
    const int size = buffer.getSize();
    const float coarsePitch = getRampedParameterValue(PARAMETER_A);
    const float finePitch = getRampedParameterValue(PARAMETER_B);
    const float decay = getRampedParameterValue(PARAMETER_C);
    const float mix = getRampedParameterValue(PARAMETER_D);
    
    if (coarsePitch != mPrevCoarsePitch || finePitch != mPrevFinePitch || decay != mPrevDecay)
    {
      const float freq = midi2CPS(MIN_PITCH + floor(mPrevCoarsePitch * PITCH_RANGE) + finePitch);
      
      for (int c = 0; c < NUM_COMBS; c++) 
      {
        mCombs[c].setFreqCPS(freq * FREQ_RATIOS[c]);
        mCombs[c].setDecayTimeMs(MIN_DECAY + (decay * DECAY_RANGE));
      }
      
      mPrevCoarsePitch = coarsePitch;
      mPrevFinePitch = finePitch;
      mPrevDecay = decay;
    }
      
	  for(int ch = 0; ch<buffer.getChannels(); ++ch)
	  {   
	    float* buf = buffer.getSamples(ch);
	    
	    for(int i = 0; i < size; i++)
	    {
	      float ips = buf[i];
	      float ops = 0.;
	      const float smoothMix = mMixSmoother.process(mix);
	      
	      for (int c = 0; c < NUM_COMBS; c++) 
	      {
		ops += mCombs[c].process(ips);
	      }
	      
	      buf[i] = mDCBlocker.process( ((ops * 0.1) * smoothMix) + (ips * (1.-smoothMix)) );
	    }
	  }
    
   
  }