get_downbeats() seems to return incorrect values for me when used with compound meters (6/x, 9/x, 12/x).
I think the error comes from pretty_midi.py, line 716 (and also similarly line 720 for final_ts): beats[start_beat_idx:end_beat_idx:start_ts.numerator]
This line skips beats based on the numerator value. However, if the meter is compound, the skip should be start_ts.numerator // 3 I think.
This also led to me uncovering a 2nd bug in utilities.py, the qpm_to_bpm method:
Currently, compound meters are only handled correctly if they have an 8 in the denominator.
6/4, for example, would return a bpm equal to the quarter note, while the compound meter should have the bpm be equal to 3 quarter notes.
In the returns within the elif denominator in [8, 16, 32]: block, all returns are treated as if the denominator is 8. Thus, I think every return inside this block should be changed multiplied by an additional factor based on the denominator.
I think a fix would involve removing the special cases for 1, 2, and 4, and just adding them in as [1, 2, 4, 8, 16, 32]. This (with the additional factor) would then become: (note that I am unsure how the else block where I've put !!!!!!!!!! should be handled)
get_downbeats() seems to return incorrect values for me when used with compound meters (6/x, 9/x, 12/x).
I think the error comes from pretty_midi.py, line 716 (and also similarly line 720 for final_ts):
beats[start_beat_idx:end_beat_idx:start_ts.numerator]
This line skips beats based on the numerator value. However, if the meter is compound, the skip should be
start_ts.numerator // 3
I think.This also led to me uncovering a 2nd bug in utilities.py, the qpm_to_bpm method:
Currently, compound meters are only handled correctly if they have an 8 in the denominator.
6/4, for example, would return a bpm equal to the quarter note, while the compound meter should have the bpm be equal to 3 quarter notes.
In the returns within the
elif denominator in [8, 16, 32]:
block, all returns are treated as if the denominator is 8. Thus, I think every return inside this block should be changed multiplied by an additional factor based on the denominator.I think a fix would involve removing the special cases for 1, 2, and 4, and just adding them in as [1, 2, 4, 8, 16, 32]. This (with the additional factor) would then become: (note that I am unsure how the else block where I've put !!!!!!!!!! should be handled)