CPJKU / madmom

Python audio and music signal processing library
https://madmom.readthedocs.io
Other
1.35k stars 206 forks source link

Fix bad log densities #490

Open omareldeeb opened 2 years ago

omareldeeb commented 2 years ago

Changes proposed in this pull request

Please provide a detailed description of the changes proposed in this pull request. This can either be a textual description or a simple list.

In line 629 of beats_hmm.py, the sum of the beats and downbeats observation is used to calculate the log density for non-beat states. These, however, are not guaranteed to define a joint probability density function, which causes the sum to be potentially greater than 1 and the logarithm of a negative number to be used. Since beats are also downbeats, we can simply take the beat observation instead.

If the viterbi algorithm fails to decode a valid path (e.g. as a result of the above error), it returns an empty array, which is indexed in line 305 of downbeats.py, causing an IndexError. To avoid this, we can simply check if the array is empty in line 297.

This pull request fixes #488 #489 .

superbock commented 2 years ago

This is only partly correct. The output of RNNDownBeatProcessor is actually a probability density function. Thus the situation outlined in #489 should actually not happen — at least not with RNNDownBeatProcessor.

The proposed fix changes the behaviour of DBNDownBeatTrackingProcessor since it actually expects the input to be a probability density function (or at least look like one), i.e. it is designed to have lower beat activations at downbeat positions.