Skip to content

Commit

Permalink
fix downbeat output bug; closes #127
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Böck committed Apr 8, 2016
1 parent 88c1f77 commit 8c7214f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Release Notes
Version 0.14.dev
----------------

Bug fixes:

* Fix downbeat output bug (#128)

API relevant changes:

* Refactored the `ml.rnn` to `ml.nn` and converted the models to pickles (#110)
Expand Down
2 changes: 1 addition & 1 deletion madmom/features/beats.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ def process(self, activations):
beat_numbers[beat_positions])).T
# return the downbeats or beats and their beat number
if self.downbeats:
return beats[beats[:, 1] == 1][0, :]
return beats[beats[:, 1] == 1][:, 0]
else:
return beats

Expand Down
6 changes: 6 additions & 0 deletions tests/test_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def setUp(self):
ACTIVATIONS_PATH)
self.result = np.loadtxt("%s/sample.gmm_pattern_tracker.txt" %
DETECTIONS_PATH)
self.downbeat_result = self.result[self.result[:, 1] == 1][:, 0]

def test_help(self):
_, ret_code = run_program([self.bin, '-h'])
Expand Down Expand Up @@ -295,6 +296,11 @@ def test_run(self):
result = np.fromstring(data, sep='\n').reshape((-1, 2))
self.assertTrue(np.allclose(result, self.result))

def test_run_downbeats(self):
data, _ = run_program([self.bin, '--downbeats', 'single', sample_file])
result = np.fromstring(data, sep='\n')
self.assertTrue(np.allclose(result, self.downbeat_result))


class TestLogFiltSpecFluxProgram(unittest.TestCase):

Expand Down
5 changes: 5 additions & 0 deletions tests/test_features_beats.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,8 @@ def test_process(self):
self.assertTrue(np.allclose(beats, [[0.08, 3], [0.42, 4], [0.76, 1],
[1.1, 2], [1.44, 3], [1.78, 4],
[2.12, 1], [2.46, 2], [2.8, 3]]))

def test_process_downbeats(self):
self.processor.downbeats = True
beats = self.processor(sample_mb_features)
self.assertTrue(np.allclose(beats, [0.76, 2.12]))

0 comments on commit 8c7214f

Please sign in to comment.