Repository: beetbox/beets

Issue:
DSD/DSF file format support
DSF files apparently use ID3 metadata. Here's a project that adds support for them to Mutagen: https://code.google.com/p/dsf2flac/source/browse/trunk/extras/picard+dsf+file+support/dsf/dsf.py



Discussion:
this is quite exciting. I'm keeping my SACD stuff separate for now but would love to tag it!

Has anyone tested out tagging dsf files yet? 

I was the one that originally brought this to Adrian's attention. Really hoping that this can be added to Beets to help me tag my very large collection of SACD (DSD) DSF files. 

I think it should be a necesairy feature to have dsf files aboard Beets. dsf's are just normal taggable. Just like storrgie says, the only solution for now is to keep them seperate... and thats a pity.

Contributions from people who are actually familiar with the format (i.e., not me) would be very welcome here.

Not exactly an expert, but I have some experience with dsf files. DSD comes into two flavours. dff and dsf files. One of the two is the format of Sony, the other is Philips. I noticed that  dsf files are tag-able. There are tools to convert dff to dsf quiet easily. My experience is in JRiver for mac and Linux where the dsf files behave exactly like any other format. I will find out about the conversion tools and make another post in here about it. 
Shortly I am using Linux and with HQPlayer, the best audiophile audioplayer there is in my opinion. Musicmanagement is very basic in HQPlayer. For now I investigate the combination between Beets and HQPlayer. The lack of support for dsf files is a pity, with that it would be a very strong combination.

DSF is a stereo only simplification of DFF [1](http://en.wikipedia.org/wiki/Direct_Stream_Digital#DSD_disc_format). DSF apparently supports ID3V2 tags. I saw a post on head-fi by @pekingduck about his [metadsf](https://github.com/pekingduck/metadsf) utility that might provide some reference. I was assuming that once mutagen added support for DSF that it would be pretty straitforward (read, similar to other supported formats) to add support within beets. I'm not sure if mutagen supports DSF yet, I saw this [forum post](http://forums.musicbrainz.org/viewtopic.php?id=4150) about DSF support in picard a while back.

I've actually put collecting SACD on hold for a bit, there is a bug within [sacd_extract](https://code.google.com/p/sacd-ripper/source/browse/#svn%2Ftrunk%2Ftools%2Fsacd_extract) that causes an audible pop at the beginning of the track. The issue is documented [here](http://www.computeraudiophile.com/f11-software/sacd_extract-dsf-output-problem-18114/). It seems that some folks are going ISO->DFF->DSF as that somehow avoids the pop. Others appear to be endlessly tweaking foobar to skip the beginning content of the track. I didn't want to archive content in a way that added noise to the original information, so I'm waiting to see how it all shakes out.

I know this doesn't help beets much, but I've been poking around the mpd codebase trying to wrap my head around adding support to mpd that would allow for SACD ISO playback. I've seen some folks claim that utilities can 'tag' the ISO files themselves, however I'm not sure if thats true as I can't find any proof of the implementation. 

In the long run I am willing to bet that DSF/SACD will be a fad that will fizzle out once more. I believe it's been getting popular lately because its a competing factor for hardware manufactures (to offer DSDoverPCM support on their USB interfaces). There might be some hype due to that competition, however, ultimately most of these systems are stereo only... so aside from psychoacoustic differences there isn't a merit in using SACD over PCM. I'm scared about what kind of damage might be done to the community through DSD/DXD hype. I wonder what would happen if we were focused on something else and continued to use PCM.

I'd be interested to hear an acoustics engineer weigh in about how it would be better to re-master in SACD format over using their original PCM masters. If the draw is to be able to communicate multichannel audio I think that it's become easier to stick to PCM. Now days there are commonly implemented specificiations for lossless multichannel mastering such as [DTS-HD](http://en.wikipedia.org/wiki/DTS-HD_Master_Audio) and [Dolby True-HD](http://en.wikipedia.org/wiki/Dolby_TrueHD). 

There was a paper (that I can't find now) on mastering in SACD and PCM. It went on to show how operations on SACD content result in an increase in noise where PCM can be modified without adding noise in any way. I felt after reading it that SACD was pretty damned as a mastering format (as if the specialized hardware wasn't enough), however I guess that doesn't preclude people from mastering in PCM and using SACD as a distribution mechanism (however that seems almost as bad as mastering in PCM and pressing some vinyl).

I guess I meant to say: If mutagen adds DSF support I would like to take a swing at the implementation... but I don't think the beets community should go out of their way to get DSF support into the upstream.

I have over 2000 SACD albums ripped as DSF files, all fully tagged. I _very
occasionally_ hear a slight tick at the end of a track due to the
sacd_extract issue, but if I do hear it I have to be consciously listening
for it. It's barely audible to me. In no would this issue prevent me from
wanting to have my music in the DSF format.  Nor do I agree with the
statement DSD files are just a fad, but we all have our own opinions and I
won't bother trying to defend mine. I just know I LOVE how my digital music
library sounds.

I would have loved to use beets for tagging my DSD files but had to look
elsewhere to help with the task. I would still like to see DSF tagging
support added though because I know I will continue to purchase SACD's in
the future.

Sent from my iPhone

On Aug 27, 2014, at 8:54 AM, "Andrew G. Dunn" notifications@github.com
wrote:

DSF is a stereo only simplification of DFF 1
http://en.wikipedia.org/wiki/Direct_Stream_Digital#DSD_disc_format. DSF
apparently supports ID3V2 tags. I saw a post on head-fi by @pekingduck
https://github.com/pekingduck about his metadsf
https://github.com/pekingduck/metadsf utility that might provide some
reference. I was assuming that once mutagen added support for DSF that it
would be pretty straitforward (read, similar to other supported formats) to
add support within beets. I'm not sure if mutagen supports DSF yet, I saw
this forum post http://forums.musicbrainz.org/viewtopic.php?id=4150 about
DSF support in picard a while back.

I've actually put collecting SACD on hold for a bit, there is a bug within
sacd_extract
https://code.google.com/p/sacd-ripper/source/browse/#svn%2Ftrunk%2Ftools%2Fsacd_extract
that causes an audible pop at the beginning of the track. The issue is
documented here
http://www.computeraudiophile.com/f11-software/sacd_extract-dsf-output-problem-18114/.
It seems that some folks are going ISO->DFF->DSF as that somehow avoids the
pop. Others appear to be endlessly tweaking foobar to skip the beginning
content of the track. I didn't want to archive content in a way that added
noise to the original information, so I'm waiting to see how it all shakes
out.

I know this doesn't help beets much, but I've been poking around the mpd
codebase trying to wrap my head around adding support to mpd that would
allow for SACD ISO playback. I've seen some folks claim that utilities can
'tag' the ISO files themselves, however I'm not sure if thats true as I
can't find any proof of the implementation.

In the long run I am willing to bet that DSF/SACD will be a fad that will
fizzle out once more. I believe it's been getting popular lately because
its a competing factor for hardware manufactures (to offer DSDoverPCM
support on their USB interfaces). There might be some hype due to that
competition, however, ultimately most of these systems are stereo only...
so aside from psychoacoustic differences there isn't a merit in using SACD
over PCM. I'm scared about what kind of damage might be done to the
community through DSD/DXD hype. I wonder what would happen if we were
focused on something else and continued to use PCM.

I'd be interested to hear an acoustics engineer weigh in about how it would
be better to re-master in SACD format over using their original PCM
masters. If the draw is to be able to communicate multichannel audio I
think that it's become easier to stick to PCM. Now days there are commonly
implemented specificiations for lossless multichannel mastering such as
DTS-HD http://en.wikipedia.org/wiki/DTS-HD_Master_Audio and Dolby True-HD
http://en.wikipedia.org/wiki/Dolby_TrueHD.

There was a paper (that I can't find now) on mastering in SACD and PCM. It
went on to show how operations on SACD content result in an increase in
noise where PCM can be modified without adding noise in any way. I felt
after reading it that SACD was pretty damned as a mastering format (as if
the specialized hardware wasn't enough), however I guess that doesn't
preclude people from mastering in PCM and using SACD as a distribution
mechanism (however that seems almost as bad as mastering in PCM and
pressing some vinyl).

—
Reply to this email directly or view it on GitHub
https://github.com/sampsyo/beets/issues/459#issuecomment-53584355.

"I know this doesn't help beets much, but I've been poking around the mpd codebase trying to wrap my head around adding support to mpd that would allow for SACD ISO playback. I've seen some folks claim that utilities can 'tag' the ISO files themselves, however I'm not sure if thats true as I can't find any proof of the implementation. "

storrgie - oh what I would do to have MPD read SACD ISO's... :) Not sure how I can help tho. I do know MPD plays CD and DVD-A ISOs, so I suppose first step would be to get a catalogue of tracks on SACD by utilising that code.... Foobar2000 SACD ISO plugin is opensource, so that might help. sacd_extract code is also opensource, so once MPD knows what DSD tracks are in an ISO and where, it should be reasonably simple to use that code to read dsd from that location. And MPD allready plays DSD.

Maybe a bounty offer to MPD developers would do the trick?

I just saw this on the mailing list this evening: http://git.musicpd.org/cgit/manisiutkin/mpd.git/

I've not built it yet, however I'm super geeked to give it a try.

Ah yes.... Maxim last week ported his Foobar 2000 SACD ISO plugin to MPD... 

https://sourceforge.net/p/sacddecoder/discussion/1844612/thread/ab5b297b/

Ocassionaly, talking to people does help :)

Oh man! Thank you a ton of linking these people together. I hope that the mpd folks don't flame him for the commit. I've seen them really hammer on people for submitting code that didn't respect their guidelines/sanity.

Get on the MPD dev list, and let's make sure Maxim get's all the support he needs... I subscribed 5 days ago, but for some strange reason am not receiving any messages... And there are some of interest: http://mailman.blarg.de/pipermail/mpd-devel/2014-September/thread.html#123
BTW, Max Kelerman's question needs an answer... (I emailed him privately) but you may want to add to it, if you have access...

I extracted and tagged my SACD ISO library in Windows using ISO2DSD from Sonore (£0.00).  http://www.audiocircle.com/index.php?topic=129913.0 - and MP3Tag.  The resulting .dsf files are pop-free, and fully tagged.  ISO2DSD (also available for Linux) allows to extract to either .dsf or .dff.

I dual-boot to Linux and have mpd/GMPC which deals with the .dsf files perfectly.  Just make sure ID3 tags are written in something legible, not v2.4.

It seems that DSF is still not supported. At least that's what my last test suggested. Any updates on the current plans? Anything I can help with?
Yeah, some help would be awesome if you're interested! The most helpful thing you can do is take ownership of adding DSF format support to [Mutagen](https://github.com/quodlibet/mutagen). That would involve doing the research to find out how exactly ID3 tags are stored on those files and contributing a module to that project.

Resolving patch:
diff --git a/beets/mediafile.py b/beets/mediafile.py
--- a/beets/mediafile.py
+++ b/beets/mediafile.py
@@ -40,7 +40,6 @@
 import mutagen.mp4
 import mutagen.flac
 import mutagen.asf
-
 import codecs
 import datetime
 import re
@@ -73,6 +72,7 @@
     'mpc':  'Musepack',
     'asf':  'Windows Media',
     'aiff': 'AIFF',
+    'dsf':  'DSD Stream File',
 }
 
 PREFERRED_IMAGE_EXTENSIONS = {'jpeg': 'jpg'}
@@ -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
@@ -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__)
 


Test patch:
diff --git a/test/rsrc/empty.dsf b/test/rsrc/empty.dsf
new file mode 100644
Binary files /dev/null and b/test/rsrc/empty.dsf differ
diff --git a/test/rsrc/full.dsf b/test/rsrc/full.dsf
new file mode 100644
Binary files /dev/null and b/test/rsrc/full.dsf differ
diff --git a/test/rsrc/unparseable.dsf b/test/rsrc/unparseable.dsf
new file mode 100644
Binary files /dev/null and b/test/rsrc/unparseable.dsf differ
diff --git a/test/test_mediafile.py b/test/test_mediafile.py
--- a/test/test_mediafile.py
+++ b/test/test_mediafile.py
@@ -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):