deadbeef icon indicating copy to clipboard operation
deadbeef copied to clipboard

DSD DoP support - encapsulate DSD in PCM, for sending to external DAC

Open Oleksiy-Yakovenko opened this issue 7 years ago • 24 comments

Background

To play DSD streams through external DAC, the DSD files need to be demuxed, and sent as DoP PCM, as documented on the link below.

Documentation

http://dsd-guide.com/dop-open-standard

Implementation ideas

This could be implemented as a special input plugin, which could be switched on/off by the user.

The plugin should handle the supported file types, and have higher priority than ffmpeg.

Oleksiy-Yakovenko avatar Oct 05 '16 13:10 Oleksiy-Yakovenko

Besides DoP, some DAC supports play native DSD stream from Linux. See links

I found my DAC is supported format called 'DSD_U32_BE' by ASLA:

...
 10) USB Audio Class Digital alsa audio output interface `hw:3,0'
 - device name       = iFi (by AMR) HD USB Audio                                   
 - interface name    = USB Audio                                                   
 - usb audio class   = 2 - isochronous asynchronous                                
 - character device  = /dev/snd/pcmC3D0p                                           
 - encoding formats  = S32_LE, SPECIAL, DSD_U32_BE                                 
 - monitor file      = /proc/asound/card3/pcm0p/sub0/hw_params                     
 - stream file       = /proc/asound/card3/stream0  

Although it won't work in Mac OS X which core audio require PCM, it sounds that it is easier to implement native DSD than DoP. I will dig deeper the protocol and see if I can contribute on this.

rickyzhang82 avatar Mar 19 '17 13:03 rickyzhang82

There is some DSD to DoP encoding routines in https://github.com/hank/dsf2flac/blob/master/src/main.cpp#L282

denius avatar Apr 20 '17 00:04 denius

DSD has long been available in MPD. Both Linux and MacOS support are pretty stable. On Linux both Native DSD and DoP are provided. On MacOS due to limitations of CoreAudio we only support DoP. It is a pretty good bit-perfect test for media players. If the audio pipleline code is not properly written and player losses bit perfection, DSD would be broken.

Wang-Yue avatar Jan 29 '19 19:01 Wang-Yue

any updates on this feature?

xingfanxia avatar Feb 10 '19 01:02 xingfanxia

Sorry, no updates at this time, aside from nobody is working on it.

Oleksiy-Yakovenko avatar Feb 10 '19 12:02 Oleksiy-Yakovenko

I am sitting in front of a 250 USD DAC with DSD512 support but with no player. I am very sad.

edescourtis avatar Jan 25 '21 04:01 edescourtis

@edescourtis could you tell what's the device name? I am actually searching for something in this price range. NB: You can still use both mpd and smplayer or mplayer to play DSD

sxiii avatar Feb 16 '21 03:02 sxiii

Maybe this can help:

https://github.com/marcoc1712/squeezelite-R2/blob/Release/dsd.c

https://github.com/marcoc1712/squeezelite-R2/blob/Release/dop.c

https://github.com/marcoc1712/squeezelite-R2/tree/Release/dsd2pcm

spvkgn avatar May 15 '21 03:05 spvkgn

There is a tool that is able to play dsd over dop live. hopefully it can be made a plugin by someone. it's a modded version of dsf2flac that spits to stdout.

https://github.com/dhalsimax/dsf2flac

ex. usage:

dsf2flac -d -w -i "pathtofile" -o - | ffmpeg -i - -c pcm_s32le -f alsa iec958:CARD=DAC57750571,DEV=0

ghost avatar Dec 13 '21 05:12 ghost

@jackloomen I don't think there's any technical difficulty in adding this. Only lack of resources or interest. I personally don't use linux, and I don't own a DAC with DSD support, and I'm not really interested in listening to music in this way. I'm sure that if any of the existing or new contributors wanted to add such functionality, it wouldn't be problematic for them.

Oleksiy-Yakovenko avatar Dec 15 '21 13:12 Oleksiy-Yakovenko

And i don't see the reason behind you are not interested in "listening to music in this way".

For better explanation:

For this is a music player github repo thread, "direct" DSD playback support SHOULD definitely taken in consideration, and your subjective flavors SHOULD definitely taken out. (at least from github! you are a moderator!)

I'm by no means willing to be rude here!

For me, deadbeef playin' straight DSD to usb dac, dropping or upgrading ffmpeg decoding, would be MARVELLOUS, since i consider this player a DIAMOND GEM among all the others avalaible.

c3kkos avatar Jan 20 '23 12:01 c3kkos

And i don't see the reason behind you are not interested in "listening to music in this way".

Because I'm not interested in owning / storing / purchasing the hardware necessary to make this work. I don't mind if someone else adds the necessary code - remember that this is an open-source hobby project, and I'm free to do whatever I like with it.

Oleksiy-Yakovenko avatar Jan 20 '23 18:01 Oleksiy-Yakovenko

I have bought a daart dac recently. In order to play DSD audio directly in Linux, I modified some part of the master branch code, and it works. image See my fork for details.

cqpwx avatar Feb 08 '23 14:02 cqpwx

Hi @cqpwx,

I've read your fork, would you mind to make a PR to get it merged ?

HiFiPhile avatar May 23 '23 10:05 HiFiPhile

Currently running Fedora 38 and I thought I would try out DoP support in master but all it does is play silence or some weird kind of static.

Gave @cqpwx's repo a try and after I figured out I had to enable direct stream DSD in the FFMPEG plugin (kind of like I had to do for DoP) all it did was play static. This was using Pipewire and Pulseaudio outputs, ALSA just locked up and wouldn't play anything just a ... icon.

Currently the only option to actually play DSD in Linux seems to be pw-play:

pw-play dsd

cat /proc/asound/card2/pcm0p/sub0/hw_params

access: MMAP_INTERLEAVED
format: DSD_U32_BE
subformat: STD
channels: 2
rate: 88200 (88200/1)
period_size: 512
buffer_size: 131072

Strange that pw-play is playing a 352800 Hz file in 88200 while pw-top is saying it's DSD64.

jasker5183 avatar Sep 02 '23 02:09 jasker5183

Hi @cqpwx,

I've read your fork, would you mind to make a PR to get it merged ?

Sorry for the delay, I was so busy for my new work these days. I read my code again yesterday, and I found that my code has a coupling relationship with ALSA. I was worried that this might cause problems for the project in the future. And I am planing to add DoP and SACD ISO support for deadbeef. This makes deadbeef has fully support for DSD. Wish I could make a PR when all these is done. Maybe write a new group of plugins is the final choice to solve this problem.

cqpwx avatar Sep 03 '23 16:09 cqpwx

@cqpwx isn't this your merge? 661d2fc15b3054df620d54e088af27d8e36479f3

It adds some DSD/DoP support, but I'm not sure whether it works (don't have DSD hardware)

Oleksiy-Yakovenko avatar Sep 03 '23 16:09 Oleksiy-Yakovenko

Seems like it's from someone else, but also looks very related.

Oleksiy-Yakovenko avatar Sep 03 '23 16:09 Oleksiy-Yakovenko

I've been able to use DoP on a FiiO KA5 on Linux with the latest master branch build. You need to use the ALSA driver and the "Enable DoP output" setting on the FFmpeg plugin. It only works for .dsf and .dff files, not DSD Wavpack files.

ToadKing avatar Sep 03 '23 21:09 ToadKing

@Oleksiy-Yakovenko I pull the recent code, and the the DoP works. Platform is macOS 13.

cqpwx avatar Sep 04 '23 10:09 cqpwx

Just gave master another try and using the ALSA output and turning DoP on in the FFMPEG plugin seems to work fine for the most part. Here is a DSD64 file without DoP: DSD64 without DoP Here is the same DSD64 file with DoP: DSD64 with DoP DoP also worked fine with a few DSD128 files I have, the problem begins when you try to play a DSD256 file and Deadbeef starts to get errors cannot set sample rate (Invalid argument) and then nothing will play (even if you turn DoP off) until you either change the output plugin or restart the player. Even if you do change the output plugin when trying to play the DSD128 files they will play at half speed or very slowly until you turn DoP back on. Also any notification sounds result in crackling audio when playing DoP.

Then switching over to the Pipewire output plugin and testing this I had zero issues with all the files I tested previously, same behavior where it's halving the sample rates when DoP is on. Not running into any playback problems while playing any files DSD64, DSD128, and DSD256 all work fine with no sample rate errors. Notification sounds still pause the music yet create no sound, only with DSD though.

Really looking forward to native DSD support.

jasker5183 avatar Sep 04 '23 23:09 jasker5183

DoP is technically an abuse of the standard protocol, DSD256 may require a sample rate (non-DSD) higher than what the DAC supports. DAC may also not support DSD256 in which case DoP can't help.

If that isn't the case then it's a bug.

ghost avatar Sep 05 '23 00:09 ghost

I could not replicate the @jasker5183 results. I guess their DAC must only support up to DSD256 which with DoP will be limited to playing DSD128 files.

Using a DAC which natively supports up to DSD512 (22.5792 MHz) equivalent to DoP256; deaDBeeF 1.9.6 with ALSA → “Direct hardware device without any conversion”, and DoP output enabled for FFMPEG plugin, I can play DSD64, DSD128, and DSD256 files. However, [as expected] due to DoP overheads playing DSD512 files is not possible.

MFTabriz avatar Mar 28 '24 23:03 MFTabriz

... the problem begins when you try to play a DSD256 file and Deadbeef starts to get errors cannot set sample rate (Invalid argument) and then nothing will play (even if you turn DoP off) until you either change the output plugin or restart the player.

I also had a similar issue trying to play DSD512 files with DoP on my device (which does support up to DoP256)!

MFTabriz avatar Mar 28 '24 23:03 MFTabriz