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

Support for DSF files #2379

Merged
merged 3 commits into from Jan 10, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions beets/mediafile.py
Expand Up @@ -40,7 +40,6 @@
import mutagen.mp4
import mutagen.flac
import mutagen.asf

import codecs
import datetime
import re
Expand Down Expand Up @@ -73,6 +72,7 @@
'mpc': 'Musepack',
'asf': 'Windows Media',
'aiff': 'AIFF',
'dsf': 'DSD Stream File',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not quite the expansion of the acronym, but maybe "DSD Stream" or even just "DSD" would better match the other short names we have here, none of which have a "file" or "audio" suffix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, there is also DSDIFF. Although it doesn't support tags, it might be valuable to be as precise as possible here. But if you want me to change that, I'll happily do that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arg, you're right—it's weird that there are competing standards here. But I agree in that case; let's keep the full name.

}

PREFERRED_IMAGE_EXTENSIONS = {'jpeg': 'jpg'}
Expand Down Expand Up @@ -728,7 +728,7 @@ def serialize(self, image):
class MP3StorageStyle(StorageStyle):
"""Store data in ID3 frames.
"""
formats = ['MP3', 'AIFF']
formats = ['MP3', 'AIFF', 'DSF']

def __init__(self, key, id3_lang=None, **kwargs):
"""Create a new ID3 storage style. `id3_lang` is the value for
Expand Down Expand Up @@ -1475,6 +1475,8 @@ def __init__(self, path, id3v23=False):
self.type = 'asf'
elif type(self.mgfile).__name__ == 'AIFF':
self.type = 'aiff'
elif type(self.mgfile).__name__ == 'DSF':
self.type = 'dsf'
else:
raise FileTypeError(path, type(self.mgfile).__name__)

Expand Down
Binary file added test/rsrc/empty.dsf
Binary file not shown.
Binary file added test/rsrc/full.dsf
Binary file not shown.
Binary file added test/rsrc/unparseable.dsf
Binary file not shown.
20 changes: 20 additions & 0 deletions test/test_mediafile.py
Expand Up @@ -886,6 +886,26 @@ class AIFFTest(ReadWriteTestBase, unittest.TestCase):
'channels': 1,
}

try:
import mutagen.dsf
except:
HAVE_DSF = False
else:
HAVE_DSF = True

@unittest.skipIf(not HAVE_DSF, "mutagen < 1.37")
class DSFTest(ReadWriteTestBase,
ExtendedImageStructureTestMixin, unittest.TestCase):
extension = 'dsf'
audio_properties = {
'length': 0.01,
'bitrate': 11289600,
'format': u'DSD Stream File',
'samplerate': 5644800,
'bitdepth': 1,
'channels': 2,
}


class MediaFieldTest(unittest.TestCase):

Expand Down