Here is something I quickly wrote, maybe you'll find it useful:
Code:
desc:Transient Detector (NOT AN FX!!!)
@init
db = 8.685889638;
idb = 0.115129254;
@slider
rel = 30/srate; // env detector drop in db per sample
tblock = 10/1000 * srate; // block length in spls
trigFactdB = 3; // rms energy rise in db for positive transient
//reset stuff
env = 0;
env_sum = 0;
env_sum_old = 1000000000;
pos = 0;
t = 0;
@sample
in = max( log( abs(spl0) ) * db , -150); // get input, convert -> db, max to above -150 to prevent -inf#
env = in > env ? in : max(env - rel, in); // do envelope
// rms block measurement / compare
env_sum += env;
(pos+=1) >= tblock ?
(
pos = 0;
env_sum /= tblock;
t = env_sum > env_sum_old+trigFactdB;
env_sum_old = env_sum;
env_sum = 0;
);
spl1 = spl0 = t; // t = 1 == transient; t = 0 == no transient :)
Anyway, this is basically integrating over the envelope in chunks of size tblock and if the rms energy from on block to the next rises over trigFactdB a transient is detected and thus t = 1.
Just do a rising edge detect on t to get the transient on set.
Note this is doing this in chunks of tblock length so t will be delayed by tblock AND only updated every tblock samples. Dunno what you need it for but you can easily make the RMS block measurement/compare a running sum RMS and compare each sample and use lookahead to get the most accurate edge of t.
Anyway hope this helps.