Onset Detection Peak Picking I have a guitar music signal and I want to detect the onset points via energy.

This is the signal example:



This is the energy plot:



My question is what would be the best method defining the threshold and consequently finding the peaks. I reckon I will have to set a window length and a window step (I am thinking 1000 and 100 samples respectively on a 44.1KHz sampling rate) and then every loop defining a new threshold (adaptive/local threshold). Every loop I would have to find the window average and compare it to the threshold. I have these questions:

1) Does window length = 1000 samples and window step = 100 seems reasonable?

2) How the threshold would be defined each loop and in relation to what?

3) If a window is above length which samples in it would I consider peaks? I think it would be somewhere in the middle but what range around it? 

Maybe, window middle - window step &lt; peak samples &lt; window middle + window step  ?

Thank you for your help.
compute RMS from audio signal to get power
do AGC (automatic gain control)
perform "discrete differentiation" (the simplest is 1st order: $y[i] = x[i] - x[i-1]$)
if the value is greater than certain threshold, it means we have an onset. You have to determinate the threshold experimentally or use adaptive algorithm. Obviously you also need some kind of lowpass filter to filter the noise.


You may want to swap steps 2 and 3.

If you can use software libraries, check out aubio.

Possible duplicate of https://stackoverflow.com/questions/294468/note-onset-detection