Skip to content

Commit

Permalink
fix situation where beats get detected multiple times
Browse files Browse the repository at this point in the history
This situation can occur if the detected tempo changes when iteratively
searching for the next beat in the given activation function +/- a certain
window. Require the next beat to be at least the last detected one plus the
minimum interval. Fixes #297.
  • Loading branch information
Sebastian Böck committed Jun 12, 2017
1 parent 2ea87c9 commit db4066b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Version 0.16.dev0
Bug fixes:

* Fix `TransitionModel` number of states when last state is unreachable (#287)
* Fix double beat detections in `BeatTrackingProcessor` (#298)

Other changes:

Expand Down
8 changes: 4 additions & 4 deletions madmom/features/beats.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ def process(self, activations, **kwargs):
positions = detect_beats(act, interval, self.look_aside)
# correct the beat positions
positions += start
# remove all positions < already detected beats + min_interval
next_pos = (detections[-1] + self.tempo_estimator.min_interval
if detections else 0)
positions = positions[positions >= next_pos]
# search the closest beat to the predicted beat position
pos = positions[(np.abs(positions - pos)).argmin()]
# append to the beats
Expand All @@ -534,10 +538,6 @@ def process(self, activations, **kwargs):
detections = np.array(detections) / float(self.fps)
# remove beats with negative times and return them
return detections[np.searchsorted(detections, 0):]
# only return beats with a bigger inter beat interval than that of the
# maximum allowed tempo
# return np.append(detections[0], detections[1:][np.diff(detections) >
# (60. / max_bpm)])

@staticmethod
def add_arguments(parser, look_aside=LOOK_ASIDE,
Expand Down

0 comments on commit db4066b

Please sign in to comment.