Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix downbeat output bug #128

Merged
merged 1 commit into from
Apr 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]))