Thank you for your donation!

Add audio_output FIFO to mpd.conf

I have written an OLED display for MPD-based players and I am trying to provide instructions for installing it on Moode.

Demonstration video:

The spectrum analyser reads data from an MPD FIFO, so I would like to add add an audio_output FIFO section to /etc/mpd.conf

audio_output {
        type            "fifo"
        name            "mpd_oled_FIFO"
        path            "/tmp/mpd_oled_fifo"
        format          "44100:16:2"
        #buffer_time     "500000"

Is it possible to make the FIFO survive MPD reconfiguration via the Moode UI?



[ For RuneAudio, which also regenerates /etc/mpd.conf, I was advised that I would have to change the RuneAudio code to insert the FIFO configuration text when mpd.conf was regenerated, and I have provided a patch to do this as part of the installation instructions for that system. ]

Nice project :-)

moOde only allows a single MPD output to be enabled so more work than just persisting the output block in mpd.conf.

Have a look in /var/www/inc/playerlib.php

function wrk_mpdconf()
function configMpdOutputs()
function parseMpdOutputs()

Hi Tim

Thanks for your help. I have amended wrk_mpdconf() to insert the FIFO configuration text from a file as follows

PHP Code:
       $output .= "device \"btstream\"\n";
        $output .= "}\n";

        // mpd_oled FIFO
        $output .= file_get_contents('/usr/local/etc/mpd_oled_fifo.conf');

        $fh fopen('/etc/mpd.conf''w');

This appears to be working fine.

I am not sure how the other functions apply. Do they need any changes if I am not providing any configuration of the FIFO in the UI?

Not really sure. What shows up when u list the outputs and which one is enabled?

mpc outputs

Hi Tim

I get

pi@moode:~/proj/mpd_oled $ mpc outputs
Output 1 (ALSA default) is enabled
Output 2 (ALSA crossfeed) is disabled
Output 3 (ALSA parametric eq) is disabled
Output 4 (ALSA graphic eq) is disabled
Output 5 (ALSA bluetooth) is disabled
Output 6 (mpd_oled_FIFO) is enabled

Have a look at /var/www/command/worker.php in the section headed by the comment line below. You will see that this block of code will enable only one of the outputs based on whats returned by configMpdOutputs().

// start mpd

If for some reason the fifo output is excluded internally by MPD from being disabled then you might be ok.

Hi Tim

Thanks for the extra information. The FIFO won't survive an 'mpc enable only 1', and so I have also amended that area of the code to reenable the FIFO after it is disabled (a single command like 'mpc enable only 1 mpd_oled_FIFO' was also an option).

PHP Code:
$mpdoutput configMpdOutputs();
sysCmd('mpc enable only ' $mpdoutput);
sysCmd('mpc enable mpd_oled_FIFO');
// report mpd outputs
$sock openMpdSock('localhost'6600); 

The display appears to be working fine. I will test it for a couple of days and then update the repository with the installation instructions for Moode.


Forum Jump: