GioF71 / mpd-alsa-docker

Easily run mpd with Alsa or PulseAudio output with Docker. Upsampling 2x 4x 8x with "Goldilocks" settings by Archimago. Scrobbling support.
Apache License 2.0
18 stars 5 forks source link

Not sure if you are familiar with mympd #398

Closed bonelifer closed 2 months ago

bonelifer commented 2 months ago

Not sure if you are familiar with mympd, but I'm trying to use it with this this in pulse audio mode. Here are my docker-compose.yml files and the ,env file.

mympd: docker-compose.yml

services:
  mympd:
    image: ghcr.io/jcorporation/mympd/mympd
    container_name: mympd
    ports:
      - 8081:8080
    user: 1000:1000
    environment:
      - UMASK_SET=022
      - MYMPD_SSL=false
      - MYMPD_HTTP_PORT=8081
    volumes:
      - /run/mpd/socket:/run/mpd/socket
      ## Optional for myGPIOd support
      ## - /run/mygpiod/socket:/run/mygpiod/socket
      - ./data/workdir:/var/lib/mympd/
      - ./data/cachedir:/var/cache/mympd/
      - /media/william/OracleHarbor/LidarMusic/CLEAN/:/var/lib/mpd/music/:ro
      - ../mpd-alsa-docker/data/.mpd/playlists/:/var/lib/mpd/playlists/:ro
    restart: unless-stopped

.env

HTTPD_OUTPUT_CREATE=yes
HTTPD_OUTPUT_ENABLED=yes
HTTPD_OUTPUT_NAME=httpd
HTTPD_OUTPUT_PORT=8000
HTTPD_OUTPUT_BIND_TO_ADDRESS=192.168.1.80
HTTPD_OUTPUT_ENCODER=wave
HTTPD_OUTPUT_ENCODER_BITRATE=128000
HTTPD_OUTPUT_ENCODER_QUALITY=3.0
HTTPD_OUTPUT_MAX_CLIENTS=0
HTTPD_OUTPUT_ALWAYS_ON=yes
HTTPD_OUTPUT_TAGS=yes
HTTPD_OUTPUT_FORMAT=44100:16:2
HTTPD_OUTPUT_MIXER_TYPE=software
PULSE_AUDIO_OUTPUT_CREATE=yes
PUID=1000
GUID=1000

mpd-alsa-docker: docker-compose.yml:

---
services:
  mpd-alsa:
    container_name: mpd-alsa
    devices:
      - /dev/snd
    ports:
      - 6600:6600
    environment:
      - PULSE_AUDIO_OUTPUT_CREATE=${PULSE_AUDIO_OUTPUT_CREATE:-yes}
      - MPD_BIND_ADDRESS=${MPD_BIND_ADDRESS:-192.168.1.80}
      - MPD_PORT=${MPD_PORT:-6600}
      - PUID=${PUID:-1000}
      - GUID=${GUID:-1000}
      - HTTPD_OUTPUT_CREATE=${HTTPD_OUTPUT_CREATE:-yes}
      - HTTPD_OUTPUT_ENABLED=${HTTPD_OUTPUT_ENABLED:-yes}
      - HTTPD_OUTPUT_NAME=${HTTPD_OUTPUT_NAME:-httpd}
      - HTTPD_OUTPUT_PORT=${HTTPD_OUTPUT_PORT:-8000}
      - HTTPD_OUTPUT_BIND_TO_ADDRESS=${HTTPD_OUTPUT_BIND_TO_ADDRESS}
      - HTTPD_OUTPUT_ENCODER=${HTTPD_OUTPUT_ENCODER:-wave}
      - HTTPD_OUTPUT_ENCODER_BITRATE=${HTTPD_OUTPUT_ENCODER_BITRATE}
      - HTTPD_OUTPUT_ENCODER_QUALITY=${HTTPD_OUTPUT_ENCODER_QUALITY}
      - HTTPD_OUTPUT_MAX_CLIENTS=${HTTPD_OUTPUT_MAX_CLIENTS:-0}
      - HTTPD_OUTPUT_ALWAYS_ON=${HTTPD_OUTPUT_ALWAYS_ON:-yes}
      - HTTPD_OUTPUT_TAGS=${HTTPD_OUTPUT_TAGS:-yes}
      - HTTPD_OUTPUT_FORMAT=${HTTPD_OUTPUT_FORMAT:-44100:16:2}
      - HTTPD_OUTPUT_MIXER_TYPE=${HTTPD_OUTPUT_MIXER_TYPE:-software}
    volumes:
      - /media/william/OracleHarbor/LidarMusic/CLEAN/:/music:ro
      - ./data/.mpd/playlists:/playlists
      - ./data/.mpd/log:/log
      - ./data/.mpd/config:/user/config
      - ./data/.mpd/db:/db
      - /run/user/${PUID}/pulse:/run/user/${PUID}/pulse
    network_mode: "host"  # Add host mode networking
    image: giof71/mpd-alsa
GioF71 commented 2 months ago

Hello, yes I know about mympd, I also participated in a few discussions/issues, it's an awesome project. I am running a few instances of mpd+mympd+yams, in server+satellite mode using sshfs/autofs for the file sharing with very good results.

GioF71 commented 2 months ago

Is something not working with your setup?

bonelifer commented 2 months ago

Have to check the logs tomorrow but mympd won't connect to mpd. Also the log complained about the entries in mpd.conf, made by these environment variables:

      - HTTPD_OUTPUT_ENCODER_BITRATE=${HTTPD_OUTPUT_ENCODER_BITRATE}
      - HTTPD_OUTPUT_ENCODER_QUALITY=${HTTPD_OUTPUT_ENCODER_QUALITY}

Was wondering if you could test this to see what I'm missing, or providing working yml files. I need to head off to sleep as it's almost 2am.

GioF71 commented 2 months ago

Can you post the logs where mpd complains about the configuration?

Also, what is your goal? Seeing that you want to enable PulseAudio output, I assume you want to play from your desktop computer, is that right?

Do you also want to support for mympd's local playback? That is useful when you want to connect to mympd from a web server on another device, and play through the browser. But that's weird if your player is on a desktop, looks like something more useful to configure on a mpd "server" instance, maybe running 24/7. If you have mpd running through PulseAudio on your desktop, I would prefer PulseAudio against "local playback". Anyway the configuration is legit, is that what you want?

GioF71 commented 2 months ago

About mympd connection to mpd, given your two distinct compose files, you should probably use "localhost" and "6600" in mympd configuration page:

image

bonelifer commented 2 months ago

Thanks for the help. A lot of my problems where TLDR; and a bad headache that wouldn't let me sleep. So I chunked the configuration table at chatgpt, and told it that they described docker .env variables and how to setup of mpd httpd and told it to give me the proper configs. should of then checked it against my old mpd.conf for httpd config. Change to lame, 128. Now fixed. I plan to redeploy this later on a thin-client. Just trying to get something up that works for now. I assume for the thin-client headless, I should switch out to ALSA. I want alsa/httpd, so I can listen to music on my stereo from the thin-client, but also listen on my phone via Bluetooth ear buds when it's not appropriate to listen on the stereo when people are sleeping. Also to listen via laptop browser.

GioF71 commented 2 months ago

Amazing that chatgpt could help you configure my container image, what a world! :-) Sorry for your headache also.

About httpd, maybe lame@128 is a bit too much, it will hurt quality quite a lot. You might still want to use wave and let the other two arguments empty. Or if you want to reduce bandwidth usage, you can stick with lame, but maybe use 320 as the bitrate. Or even better you can use vorbis with quality set to -1, those might be more sensible settings if you want to listen with headphones. Look here for a reference to the encoder plugins.

For the output to the hifi system, alsa is definitely the way to go!

Another thing, for a mpd instance which is used through mympd, you might want to set ENFORCE_PLAYER_STATE to no, so the startup script won't reset the state of the players (enabled/disabled) during startup. This behaviour is used in order to avoid that, while starting up, some outputs are disabled because you disabled in the previous run, but I believe is not ideal with mympd, which has a nice interface for enabling and disabling outputs