deadbeef
deadbeef copied to clipboard
DSD DoP support - encapsulate DSD in PCM, for sending to external DAC
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.
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.
There is some DSD to DoP encoding routines in https://github.com/hank/dsf2flac/blob/master/src/main.cpp#L282
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.
any updates on this feature?
Sorry, no updates at this time, aside from nobody is working on it.
I am sitting in front of a 250 USD DAC with DSD512 support but with no player. I am very sad.
@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
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
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
@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.
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.
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.
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.
See my fork for details.
Hi @cqpwx,
I've read your fork, would you mind to make a PR to get it merged ?
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
:
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.
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 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)
Seems like it's from someone else, but also looks very related.
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.
@Oleksiy-Yakovenko I pull the recent code, and the the DoP works. Platform is macOS 13.
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:
Here is the same DSD64 file 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.
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.
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.
... 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)!