Skip to content

Commit

Permalink
Merge pull request quodlibet#464 from drizzt/dsd_wavpack
Browse files Browse the repository at this point in the history
wavpack: add support for wavpack DSD
  • Loading branch information
lazka authored May 3, 2020
2 parents feefd9b + e989106 commit 189b6ea
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mutagen/wavpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def __init__(self, fileobj):
self.channels = bool(header.flags & 4) or 2
self.sample_rate = RATES[(header.flags >> 23) & 0xF]

# most common multiplier (DSD64)
if (header.flags >> 31) & 1:
self.sample_rate *= 4

if header.total_samples == -1 or header.block_index != 0:
# TODO: we could make this faster by using the tag size
# and search backwards for the last block, then do
Expand Down
Binary file added tests/data/dsd.wv
Binary file not shown.
24 changes: 24 additions & 0 deletions tests/test_wavpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,27 @@ def test_pprint(self):

def test_mime(self):
self.failUnless("audio/x-wavpack" in self.audio.mime)


class TWavPackDSD(TestCase):

def setUp(self):
self.audio = WavPack(os.path.join(DATA_DIR, "dsd.wv"))

def test_version(self):
self.failUnlessEqual(self.audio.info.version, 0x410)

def test_channels(self):
self.failUnlessEqual(self.audio.info.channels, 2)

def test_sample_rate(self):
self.failUnlessEqual(self.audio.info.sample_rate, 352800)

def test_length(self):
self.failUnlessAlmostEqual(self.audio.info.length, 0.01, 3)

def test_pprint(self):
self.audio.pprint()

def test_mime(self):
self.failUnless("audio/x-wavpack" in self.audio.mime)

0 comments on commit 189b6ea

Please sign in to comment.