@LucienR The problem is that [trigger] is sending bangs to the right and left inlets of [timer] almost instantaneously. Just curious, what values are you getting? I'd imagine they'd be pretty low.
I'm not too familiar with the second outlet of [fiddle~] but it sounds like it just outputs a bang when the amplitude level of an incoming signal exceeds an arbitrary threshold ($1, in your patch). Does it also report when volume has receded back below this threshold? In other words, you have setup your patch quite nicely to detect an attack event, but I'm not sure how you are getting duration.
Here's what I would do:
Maybe this is what [fiddle~] does, but in this diagram, I am taking the rms* of an incoming signal, converting it into decibels, and then checking with [> o.5] to see if these values go over a certain threshold. If yes, output 1, else 0. The [* 100] is just to scale up the values from [env~] and [dbtorms]to make them easier to read (they are really low).
*rms = root mean sqaure. I don't know the weird math behind it, but as I understand it, taking the rms means to take the average of an incoming signal over a short period of time rather than an instantaneous peak. In other words, rms does a good job at representing actual perceived volume level, which is very useful when grabbing real-time microphone input. It cuts down on weird triggering errors.