it should be possible to do something like that.
the first thing to accomplish is getting some sort of triggering based on input threshold. so maybe make a simple noise gate first:
if audio_in < value -> then audio_out = 0; else audio_out = audio_in;
you can then play around with the value to see where a good trigger level is.
the next thing to accomplish is varying the amplitude with time. so set up a variable which is a counter. this will count the amount of times you have fallen through the ISR (put this in the ISR loop). you can multiply your input value by this counter to create an envelope.
here is some pseudocode
at beginning
unsigned int env = 0;
byte trig = 0;
int threshold = some value;
byte decay = 0;
in ISR()
// check if doing envelope or not
if (trig = 0) {
if (audio_in > threshold) { // if not check if trigger threshold has been reached
trig = 1;
}
audio_out = 0;
}
else {
if (decay = 0) { // if not decaying, upcount your envelope
env++;
if (env > 0xfffe) {
decay = 1;
}
else { // otherwise downcount
env--;
if (env == 0) {
decay = 0;
trig = 0;
}
}
audio_out = audio_in * env; // multiply audio by envelope - be sure to use special math functions here
}
after you have something like this working, you can change how the env value gets incremented and decremented for seperate attack and decay values. be sure to look at some of the examples of doing the special math multiplies, these take way less time.