dynamic tempo sometimes way off?

60 views
Skip to first unread message

mcskwayrd

unread,
Aug 7, 2024, 11:08:09 AM8/7/24
to librosa
Hi. I have a file of myself playing guitar with a tempo varying from 109 to 112 bpm
When I look at the onset graphs and beat detection (bottom graph, below), everything seems regular, but notice that the dynamic tempo estimation sometimes "shoots" very high or very low (first graph, below) despite no noticeable changes in the features (or my playing). 

Why is this, and how to prevent "wild" values from occurring? 


Here's the tempogram I'm getting, and the beat tracking outputs...  I don't observe any sudden changes , say at the 13 second mark where the tempo estimate jumps way up. 
I'm also a little confusd about the utility of the "lognorm prior" since it seems to arrive at a value much lower that what I can clearly hear if I tap a metronome. 

Any help would be appreciated!  Thanks.

Screenshot 2024-08-07 at 10.03.22 AM.png

Screenshot 2024-08-07 at 10.05.25 AM.png

mcskwayrd

unread,
Aug 7, 2024, 11:59:14 AM8/7/24
to librosa
some of this might just be powers of two, i.e. that sometimes it estimates "eighth notes" or "half notes" instead of "quarter notes" - some of those jumps are factors of 2. 

mcskwayrd

unread,
Aug 7, 2024, 12:45:07 PM8/7/24
to librosa
Related though:  How do we get better tempo resolution?   I'm seeing at best +/- 6 BPM between the various values outputted by the dynamic tempo tracking. 
 I've tried adjusting the input spectrogram's STFT win_length, and the  tightntess parameter, but so far nothing has any effect on BPM resolution. 
e.g. values I see are 
104.17,
 110.29,
 117.19,
I expect to see in-between values like 109, 111, 112, 113,... not just  those three quantized numbers (104.17, 110.29, 117.19) over & over. 

Brian McFee

unread,
Aug 9, 2024, 2:20:53 PM8/9/24
to librosa
Working backwards here:
  • Tempo resolution is dictated by the frame rate of the underlying STFT, which is in turn governed by the hop length and sampling rate parameters.  (Smaller hop = higher frame rate = higher resolution.)  The frame length for the STFT has no real bearing on this, except insofar as it affects the calculation of the onset envelope.
  • Your intuition about "octave" errors (half / double-time) is correct.  The default settings for the beat tracker are meant to work across a wide range of inputs, and therefore have a pretty relaxes prior distribution on what tempo to expect.  If you know that your tempo will be closer to a given value (eg 110 in your case), you can do two things: 1) set start_bpm=110 (or whatever value you expect), and 2) increase the "tightness" parameter (say to 400 or so).  The first gives you a better starting point for your track (though it won't matter much I expect); the latter makes it less likely to stray from that value.
  • If your tempo is only varying from 109-112, you probably don't need a dynamic tempo beat tracker.  You can use a static tempo value and the tracker will accommodate small variations automatically.  The dynamic tempo estimation mode is really more for long-term drift or sudden changes (half/double-time).  That said, if you want a "smoother" looking tempogram that is less likely to have sudden jumps, you can increase the "win_length" parameter in tempogram; the default is 384 frames (around 9 seconds at sr=22050, hop_length=512), but using a longer window will force the autocorrelation to integrate over a longer timespan with more overlap from one tempogram frame to the next.
I hope that helps!

chanaka karunaratne

unread,
Aug 9, 2024, 2:21:15 PM8/9/24
to mcskwayrd, librosa

Try with mfcc conversion


--
You received this message because you are subscribed to the Google Groups "librosa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to librosa+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/librosa/538d4cbf-493a-4863-a61c-e61dfbbf7a5an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages