Analysing Attack Times

Python. I used the spectrogram to detect attack times in a single line melody by shaping signal’s power graph. It works better with only slow passages in which the notes are separable from each other. I wrote its algorithms by taking reference the signal’s total power. Basically, it reshapes the total power by a smoothing algorithm, and finds the attack times for each note based on a threshold value. One of the bottlenecks is that reshaping algorithm might fail for fast passages and/or deciding threshold value could be unclear. I will improve the reshaping strategy later on.

For demonstration, I used a simple piano segment. It is a 5 notes single melody line. Its STFT parameter and threshold can be changed. It gives the output the related attack times. For this simple melody line;

  1. 0.04 sec
  2. 0.85  sec
  3. 1.04 sec
  4. 1.55 sec
  5. 2.08 sec


[1] Mathematics of the Discrete Fourier Transform, Julius O. Smith III

[2] Scipy Signal Spectrogram Documentation