Jump to content

How-to send Emby Theater for RPi audio to my DAC HAT? Shell access?


them8os235
Go to solution Solved by them8os235,

Recommended Posts

them8os235

This question could have been in the Emby Theater topic too.  But as it has to do specifically with a DAC HAT on a RPi 4, I put it here.

Also, this question is specifically for music, not video; if that matters.  So, setting up Emby Theater on a RPi 4 using the canned image was simple and worked perfect and I connected immediately to my server on the first boot.  (presently using an HDMI display but plan to make a turn-key device using an official 7" display, along with a DAC HAT on the back of the display's case, if that too eventually matters)

However I'm finding the audio is output only to the built-in headphone output of the RPi 4.  Not the DAC HAT I have on it.  There is no Volumio~like audio output selection in the Emby App setup UI.  And when I exit the Emby Theater App then logout and see the OS login prompt, username/password of pi/raspberry doesn't work to allow me to login to the shell and setup the audio output routing of ALSA.

Hoping one of you fine people can point me in the right direction, either for how to redirect audio from within the Emby app that I missed, or how to login to shell on the current Emby Theater image for the RPi.  Thank you.

Link to comment
Share on other sites

them8os235

... Should I [do I need to?] just setup DietPi to a minimal install, setup the OS and config to use my DAC HAT, then install the Emby Theater package manually?  For the sake of expedience (as I'm doing all this for a friend for free) was hoping to not have to, but if anyone knows that that is what HAS to happen, would appreciate the gentle nudge.  :D  If I don't hear back from anyone in a few hours that may just be what I end-up doing anyway.

 

Edited by them8os235
Link to comment
Share on other sites

  • Solution
them8os235

I hadn't touched a Raspberry Pi in years.  And forgot many of the tools and techniques to do thing.  I was reminded by a HiFiBerry how-to page.  The answer to my question is here:

https://www.hifiberry.com/docs/software/configuring-linux-3-18-x/

There is a lot in there that isn't pertinent in this case.  Here is a summary of the [very] few things I had to do. *** No shell or ssh access to the Emby Theater turn-key OS necessary, as I was trying to do yesterday.

a) Put the mSD card on which you installed Emby Theater for RPi into another computer.

b) In the 'boot' FAT partition edit config.txt

c) Comment or remove dtparam=audio=on

d) Add a 'dtoverlay' statement under the line you just commented (or removed) for your HAT DAC (*** the corresponding file needs to be found in the root /overlays directory).  In my case I added dtoverlay=hifiberry-dacplus

e) Close the file. Removed the mSD card cleanly from the computer. Put the card back into the RPi 4. Boot.  And you're golden.   

At least that was the case for me.  Nothing else on that page was necessary.  And again, in "e)", whatever HAT DAC you have and name in the dtoverlay statement needs to have a corresponding overlay driver file located within the /overlays directory.  

 

  • Like 1
Link to comment
Share on other sites

them8os235

I'm really bummed to report that above ONLY works on the 3.0.19 image of Emby Theater for Linux on a Raspberry Pi 4 when the display is HDMI.  When I cut a new mSD image and modified the config.txt file to disable HDMI and use the 7" display, audio output to the HiFiBerry DAC stopped working. 

Audio will be output to the internal DAC's headhphone ouput if I continued to use this "dtparam=audio=on"; but no longer to the HiFiBerry's headphone output if I commented that and used this: "dtoverlay=hifiberry-dacplus"; also no audio to the HiFiBerry regardless of whether I used "dtoverlay=vc4-fkms-v3d,audio=off" or with no ",audio=off", where prior with a HDMI display I could use the pre-configured value of "dtoverlay=vc4-kms-v3d" and did not need to use ",noaudio" (kms uses a different format than fkms). 

Also and interestingly, when I use "dtoverlay=hifiberry-dacplus" the green light on the HiFiBerry DAC does light-up when I start playing a song in Emby Theater.  But obviously there is something amiss with the stream, as the DAC is not performing the conversion and outputting audio.

Still working on it.  I'll return here with good news if I work it out.  Or to beg for assistance from some of the principal authors of emby-theater if I exhaust everything I can find to try.  TBD which. 

 

re-edit: Is it possible for me to SSH to the Emby Theater image I have running?  Can someone give me the Username and Password of the 3.0.19 image? 

After several dozen cycles of shutting down the OS, disassembling the DAC HAT off the RPi 4, then removing the RPi 4 from the display case, just so that I can access the mSD (otherwise inaccessible due to the 7" display case design), all so that I can put the mSD into my PC so that I can modify config.txt, and then have to reassemble everything ... I'd REALLY love to be able to edit config.txt in place while it's in the RPi 4 and not constantly be disassembling and reassembling.  Additionally, to debug the DAC's operation and determine why audio output is failing, debug logging could be enabled.  But obviously, I need to be able to get shell access to do so.

Edited by them8os235
Link to comment
Share on other sites

them8os235

@Luke , I've exhausted everything I'm able to do.  In need of your assistance.  I'll try to give you a Reader's Digest version of what's transpired.  Ending at the "show-stopper" of where I am now.

1. First, setup Emby Theater on a Raspberry Pi 4 using the 3.0.19 image you published on Github.  Used an HDMI display.  And no DAC HAT.  Setup was easy.  And I got audio output immediately from the built-in RPi 4 headphone output.

2. Next, I added on a HiFiBerry DAC2 Pro.  (This was the original subject of this thread).  Noted in the post above dated "Thursday at 01:58 PM", that was very easy to get operational too.  I only needed a subset of the changed directed at this link:

 https://www.hifiberry.com/docs/software/configuring-linux-3-18-x/

3. Next, I broke that down and turned my attention to my ultimate goal.  A turn-key Emby Theater playback device using a Raspberry Pi 4 + a 7" Official Display, both mounted in a Smarti Pi Touch 2 case, with the HiFiBerry DAC2 Pro HAT mounted on top for higher quality audio out.

4. This is where the problem lies. I got the Emby Theater working well on the 7" display.  But using the same config.txt changes I made in step 2 above that successfully produced audio out of the HiFiBerry DAC2 Pro, it would not output audio. 

5. When I backed-out the dtoverlay change that enabled the DAC2 Pro, and uncommented "dtparam=audio=on", this assembly of the RPi4 + 7" display would output audio thru the RPi 4's headphone out.

6. I then went back to trying to get the DAC2 Pro working.  I added the other config.txt directives the link above recommended.  But none worked. 

And this, @Luke, is where I need your help:

- If I use an HDMI display, Emby Theater on a RPi 4 with a HiFiBerry DAC2 Pro HAT will output audio music.   

- If I use the Official 7" Display, Emby Theater on a RPi 4 with a HiFiBerry DAC2 Pro HAT will NOT output audio music. The only way I can get audio music out is if I disable the DAC2 Pro and use the default headphone output of the RPi 4.  But this is not a valid use case for me.

7. It's also worth noting that when I use the "dtoverlay=hifiberry-dacplus" directive in config.txt, the "green activity light" on the HiFiBerry DAC2 Pro lights up when I play a song in Emby Theater.  This tells me communications to the DAC HAT is working.  But some sort of incompatibility must exist, to belabor the point at this point :) only when coupled with the 7" display, as no audio is produced and output by the DAC when using the 7" display but audio is produced and output by the DAC2 Pro HAT when using an HDMI display.

BTW, regarding the username/password question I mentioned a few times above.  Don't know what I did wrong accidentally the few times I tried, but I did get connected via ssh just now.  So I'll explore some logs, and run some commands and test HiFiBerry documented.  I'll also say, I'm thrilled I'm not ever going to have to take the assembly apart again to access and remove the mSD card so that I can make changes to config.txt in my PC, and then reassemble.  Whew, one good piece of news.

The contents of my config.txt follows:  

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus overscan.
# Commented as I'm using the 7" display, so letting that get set automatically.
#framebuffer_width=1920
#framebuffer_height=1080

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1
#
# Disable HDMI, Use the 7" display
disable_fw_kms_setup=1

# These should force 7" display.  But didn't work.  Setting this did work: display_auto_detect=1
#hdmi_group=2
#hdmi_mode=87

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835) ... Commented now to output to the HiFiBerry DAC HAT, below
#dtparam=audio=on
dtoverlay=hifiberry-dacplus
force_eeprom_read=0

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Enable DRM VC4 V3D driver ... added ",audio=off" per the HiFiBerry usage page
dtoverlay=vc4-fkms-v3d,audio=off
max_framebuffers=2
gpu_mem=128

# Disable compensation for displays with overscan
disable_overscan=1

# 64 bit
arm_64bit=0

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[pi4]
# Run as fast as firmware / board allows
arm_boost=1

 

Link to comment
Share on other sites

them8os235

It seems the system is properly configured to be using my sound card:

emby@emby-theater:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dacplus], device 0: HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0 [HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

And when I used alsamixer the volumes were turned up and nothing was muted.  But wait, when alsamixer starts the Card and Chip are "PulseAudio".  Hrm... that doesn't seem right.

Edited by them8os235
  • Thanks 1
Link to comment
Share on other sites

them8os235

I just backed all my changes out in config.txt that I set to use the 7" display, reverting to use HDMI, and disconnected the 7" display ribbon cable.  Basically the default config.txt file plus only the two changes noted towards the top to enable the HiFiBerry output.  Which had worked then.  But it's not working now.  So that tells me whatever incompatibility there is, was introduced on first/initial boot and configuration of the system.  🤦‍♂️ I think I need to start over with a new image.

  • Thanks 1
Link to comment
Share on other sites

them8os235

Something is really screwy.  I returned to using the original HDMI display, made another image, put it in the original RPi4 in the original HiFiBerry case I used, made the same configuration changes, and I cannot get audio out of the HiFiBerry DAC2 Pro now!

You can imagine how I'm kicking myself for not keeping the original image that worked and set it aside somewhere. 

Link to comment
Share on other sites

them8os235

OMG, what a waste of time!  Please disregard the above.  If I had permissions to edit posts I delete everything related to the HiFiBerry DACs above...

The reason my HiFiBerry DACs seemed like they should be working but weren't -- as everything on the digital side was working both in software (alsa, aplay, pactl list, etc) and in hardware (as the green activity light was coming on) -- was that the analog section / output buffer failed!  On both of my HiFiBerry DAC2 Pros that I have!  

I finally broke down and commandeered an Allo Boss DAC I had in a Volumio setup.  And that works just fine in the Emby Theater devices, be they using HDMI or the official 7" display!  

Anyway, setup and operation of Emby Theater on a RPi 4 (2 Gig version no less) using the Official 7" display can't be easier and operation is smooth as butta (as long as you're using the 'vc4-kms-v3d' dtoverlay.  When I disabled it scrolling, navigation, everything, was noticeably slower and choppier).

If anyone cares to use the 7" display in a small turn-key device, here's my config.txt.  Unlike someone who had a thread about his experience, I didn't need to use the 'vc4-fkms-v3d' dtoverlay.  That's good. 

 

So, here is my config.txt (with most all commented options or defaults removed) that I used for an Emby Theater music player on a 7" display with audio-out thru a DAC HAT:

# Disable HDMI, Use the 7" display
disable_fw_kms_setup=1

# Thought this would force 7" display. But didn't work. Setting this did work: display_auto_detect=1
#hdmi_group=2
#hdmi_mode=87

# Automatically load overlays for detected DSI displays if = 1
display_auto_detect=1

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Enable audio (loads snd_bcm2835) ... notice, doesn't need to be commented 
# and Emby Theater still outputs to the ALLO BOSS.  But you can comment if you want.
dtparam=audio=on

# Allo Boss DAC
dtoverlay=allo-boss-dac-pcm512x-audio
audio_pwm_mode=2
force_eeprom_read=0

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2
gpu_mem=128

# Disable compensation for displays with overscan
disable_overscan=1

# 64 bit
arm_64bit=0

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[pi4]
# Run as fast as firmware / board allows
arm_boost=1

dtdebug=1

 

Edited by them8os235
typos
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
yaksplat

How much better does a PI sound with the DAC on it?  I'm using a handful of them for whole house audio and I think they sound pretty decent already.

Link to comment
Share on other sites

them8os235
On 1/17/2024 at 2:25 PM, yaksplat said:

How much better does a PI sound with the DAC on it?  I'm using a handful of them for whole house audio and I think they sound pretty decent already.

This old blog post has a few words on it: https://www.hifiberry.com/blog/why-your-new-raspberry-pi-b-still-needs-a-hifiberry-sound-card/

Unfortunately the detailed comparison with measurements between the 3.5mm out and the HiFiBerry DAC of that time that post links to ( in the old community forum from 2014) is no longer available.  (Tho that comparison was against the RPi 3 the RPi 4 uses the same audio PWM based conversion).

Here is a pretty decent discussion on the topic:  https://forums.raspberrypi.com/viewtopic.php?t=59823  The consensus of '11-bit dynamic range resolution and a theoretical 66dB SNR' is really quite sobering and way way below what should be the bare minimum: that being CD quality of 16-bit resolution @ 96db SNR.  And then, if you were to lower the volume on the RPi in ALSA or PulseAudio (with the music player making that adjustment), that resolution would only go down from 11-bits at very large increments. 

And that's another aspect of a DAC HAT.  Volume control of any decent DAC HAT (in the $50 price range and up) is hardware based internal to the DAC, with the music being converted up-sampled to 32-bit or 64-bits (depending on the DAC chip employed), volume adjustment applied, with little to no impact on the dynamic range of the output. 

I'll also say noticing a difference depends a lot on what you're connecting it to.  If you're plugging the 3.5 mm output of the RPi4 into one of the many compact self-powered speakers available that could be streamed to via Bluetooth or AirPlay or Chromecast etc. or fed by a 3.5mm analog input (which is the case in this case), I doubt you'll hear a difference.  If however you're feeding even a half-way a decent stereo or separates (integrated amp) driving decent speakers, you should notice better dynamics, detail, instrument separation, crisper treble, and beefier bass, etc.. 

The other month at the time I started this thread I was comparing the headphone out of both the built-in headphone out of a RPi 4 and the HiFiBerry DAC2 Pro, using headphones, and the difference was fairly dramatic.  Better in the ways I mentioned immediately above.  Plus had a good deal more voltage & current (i.e. power) out yielding a much louder max sound into the headphone.  Now, while the higher power out capability of a DAC that also has a headphone output, into a low impedance device (headphone), should not affect the high impedance input when driving a stereo, the higher voltage out will. The RPi probably has a max peak-to-peak out of 1 or 1.2 volts (guessing here based on how loud headphones I know well could go), where most if not all DAC HATs should produce an output of 2 or more volts peak-to-peak out.

Edited by them8os235
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...