Sunday, August 19, 2018

Mytek Brooklyn and Manhattan - DSD with Ubuntu



This article is about getting Mytek DAC's to decode DSD with Ubuntu, but you'll probably learn a little even if that's not your distro or not your DACs.  Further down we also talk about integrating Squeezelite and the Logitech Media Server.

Prerequisites

For those of you more technically inclined, here is what you need to get DSD direct working with Mytek DACs and Ubuntu:

  • Linux Kernel 4.18.3 - For sure 4.4x. and 4.15.x do not work. This probably means you must be at Ubuntu 18. 
  • Logitech Media Server 7.9.x
  • LMS plugin DSDPlay 1.0
  • Squeezelite 1.9 compiled with DSD option. 
Currently Ralph's squeezelite download does NOT include this, and the Ubuntu distro (maddeningly) only supports DoP.  They do not work.

DSD vs. DoP

There are two common ways to send DSD data to an external DAC. One is a wrapper around the DSD data, so it looks like PCM, but it's interpreted as DSD. That is DoP. The problem with this approach is that the total amount of data sent over the wire (USB or S/PDIF) is quite high. So much so that it will saturate USB 2.0 at DSD 128. If that's all you need, then you can skip this article. DoP works in Ubuntu 16LTS with Squeezelite 1.8 and Logitech Media Server 7.9.x. So I imagine if you have other music player software that is DSD aware it will work the same way. 


Linux and DSD Direct

If yo want to playback quad DSD you have to go direct via USB. The ability to do this in Linux overall has been stupid-hard unless you were running some special builds like for the Rasperry Pi and perhaps others who have newer kernel builds or special patches applied by the distro. It's not only stupid-hard it's very device specific. Despite the protocol being practically the same for all DSD DAC's with USB, support for each device was up to the kernel builders. 

The root of the problem is what code decides whether the DAC supports a particular format. You would think this would be a simple handshaking thing, like this:

ALSA: Yo, are you a DAC?
Mytek: Yep
ALSA: Cool. Do you do quad DSD?
Mytek: Sure do!
Super. Here you go..."

However at least in Linux this is pretty stupid. The detection of whether or not the device is DSD compatible is not on the DAC but baked into the ALSA / USB drivers and these in turn are built into the kernel, so the conversation is more like this:

ALSA: Yo, what's your name?
DAC: Mytek Manhattan
ALSA So, no DSD support.
DAC: Wait a moment!
ALSA: Nope, not on my list. So DoP for you!  
If you wanted to add or modify the settings for a particular DAC you have to patch the kernel, which also makes keeping up with the latest security fixes stupid hard. There's no nifty "DSD_DAC_list.conf" file you can edit and update. At least not yet. Further, it is certainly possible that a new DAC won't be in the device list, and you'll have to wait for the kernel and distro maintainers to update their code. << sigh >>

But for now, all Mytek DACs should be working.


DSD Direct with Ubuntu

Arrival of Linux 4.18.3

After upgrading my Ubuntu 16LTS to 18LTS I was left with Linux kernel 4.15.x which did not work. After trying a couple of intermediate kernel builds, it was finally 4.18.3 which finally worked without patching. You may find an earlier version that works as well, but 4.18.3 is what worked for me. Fortunately upgrading your kernel above the distro default is now fairly easy and painless. You can read more here:

https://linuxhint.com/upgrade-kernel-ubuntu-1804/

I am not sure if you must have 18LTS for these instructions to work, so if you are curious and can get kernel 4.18.3 working on an earlier Ubuntu version that may be worthwhile.

If you are using a DSD DAC besides a Mytek, it is possible it was already in the driver list, in which case an earlier kernel will work, or that it hasn't been added yet.

Are you done?

If you are not going to use LMS or squeezelite then you are done with the information above. However if LMS is your music server of choice, what follows will help.

Logitech Media Server Settings

I'm using 7.9.1. There are a couple of things to pay attention to:

  1. Enable DSDPlayer (1.0) in the plugins. 
  2. Make sure you have disabled synchronized playback! LMS won't synch with different playback formats. So if you have a Squeezebox it will go down to a mutually compatible PCM format. 

Install Squeezelite 

There are three known sources for squeezelite binaries, but two have issues.

Ubuntu distro : Not up to 1.9 yet. Only has DoP support.
Ralph's binaries : It IS up to 1.9, but not compiled with DSD settings.
My repo : At 1.9, has all the settings of the Ubuntu Repo which includes DSD.

I suggest you install SL from the repo first, and then replace the binary. Detailed instructions are here:

http://inatinear.blogspot.com/2016/08/ubuntu-mytek-brooklyn-dsd-setup-guide.html

Once that is working and playing music then if it is not at 1.9 already you have two choices. Get the binary I built from Sourceforge or build it from Ralph's repo.

Get Squeezelite 1.9 

In case building files and spending an hour looking for missing dependencies is not your thing, I have put up a Sourceforge file repo with a compiled copy of Squeezelite 1.9 all ready for you.

Squeezelite 1.9 with DSD

Just copy my version to /usr/bin after you have installed SL 1.8 (as above), restart SL and you should be all set. 

Build Squeezelite 1.9 

Of course, you can always build SL from Ralph's sources, but I'm going to assume if you are building you are a masochist, or know what you are doing or both, so I'll leave you with only the essential details.

You can find the repo here:

https://github.com/ralph-irving/squeezelite


Once you can build without error, create your own makefile (Makefile.custom for instance) with these contents:


OPTS = -DRESAMPLE -DDSD -DVISEXPORT -DIR -DGPIO -DLINKALL

include Makefile
This will build SL with the same options as the Ubuntu repo currently is using, which appear pretty comprehensive. Then run "make -f Makefile.custom"


Check Squeezelite

If all goes well you have installed, built or stolen SL version at least 1.9 and "squeezelite -?" will say two important things. First, at the top:


Squeezelite v1.9.0-1112, Copyright 2012-2015 Adrian Smith ...

The "1.9.x" at the start is the important part. At the bottom we want to see the -D option appear along with this line:


Build options: LINUX ALSA EVENTFD RESAMPLE VISEXPORT IR GPIO DSD LINKALL

Of course, "DSD" is what we are looking for, the other options just match the distro defaults.


Reconfigure Squeezelite

Next, modify your /etc/default/squeezelite file to include the -D :


SB_EXTRA_ARGS="-D 100:u32be -f /tmp/squeezelite.log -d all=info" 
Note this option is a little different than squeezelite 1.8, which had no data format settings for -D. With SL 1.9 we may specify the data format but it may not be needed. I happen to know from looking at the source that Mytek uses U32BE (big-endian). If you are using another DSD DAC, you may want to experiment with this part left out if you aren't sure.

The -f and -d options to log to a file is optional, but highly recommended while debugging. If all works correctly you should see something like this in the squeezelite log:

dsd_decode:821 DSD64 stream, format: DSD_U32_BE
without any error messages, or "DoP" messages.

No comments:

Post a Comment