Skip to content

Commit

Permalink
MP4: round bpm to nearest int. Fixes #2028
Browse files Browse the repository at this point in the history
  • Loading branch information
declension authored and lazka committed Sep 25, 2016
1 parent e5b5730 commit 67ab007
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion quodlibet/quodlibet/formats/mp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def write(self):
continue
values = self.list(key)
if name == "tmpo":
values = list(map(int, values))
values = list(map(lambda v: int(round(float(v))), values))
elif name.startswith("----"):
values = list(map(lambda v: v.encode("utf-8"), values))
audio[name] = values
Expand Down
7 changes: 7 additions & 0 deletions quodlibet/tests/test_formats_mp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ def test_length(self):
def test_bitrate(self):
self.assertEqual(self.song("~#bitrate"), 2)

def test_bpm_rounds(self):
self.song["bpm"] = "98.76"
self.song.write()
self.song.reload()
self.assertEqual(self.song("bpm"), "99")
self.assertEqual(self.song("~#bpm"), 99)

def test_write(self):
self.song.write()

Expand Down

0 comments on commit 67ab007

Please sign in to comment.