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) ); } }
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)) ); } } }