#ifndef __EnvelopeTestPatch_hpp__
#define __EnvelopeTestPatch_hpp__
#include "Patch.h"
#include "AdsrEnvelope.h"
class EnvelopeTestPatch : public Patch {
public:
LinearAdsrEnvelope env;
FloatArray envBuffer;
EnvelopeTestPatch():
env(getSampleRate())
{
registerParameter(PARAMETER_A, "Attack");
registerParameter(PARAMETER_B, "Decay");
registerParameter(PARAMETER_C, "Sustain");
registerParameter(PARAMETER_D, "Release");
envBuffer = FloatArray::create(getBlockSize());
}
~EnvelopeTestPatch(){
FloatArray::destroy(envBuffer);
}
void processAudio(AudioBuffer &buffer){
env.setAttack(getParameterValue(PARAMETER_A)*4);
env.setDecay(getParameterValue(PARAMETER_B)*4);
env.setSustain(getParameterValue(PARAMETER_C));
env.setRelease(getParameterValue(PARAMETER_D)*4);
FloatArray fa=buffer.getSamples(0);
fa.noise();
static int lastButton = GREEN_BUTTON; int button;
if(isButtonPressed(GREEN_BUTTON))
button = GREEN_BUTTON;
else
button = RED_BUTTON;
bool gate = (button == RED_BUTTON);
env.gate(gate);
env.process(fa, fa);
fa.multiply(0.2);
}
};
#endif