Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Add audio_output FIFO to mpd.conf
#1
Hi

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

Code: https://github.com/antiprism/mpd_oled
Demonstration video: https://youtu.be/6pgxGQIAX9s

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

Code:
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?

Thanks

Adrian.

[ 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. ]
Reply
#2
Hi,

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()

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
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');
        fwrite($fh$output); 

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?

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

mpc outputs

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
Hi Tim

I get

Code:
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

Adrian.
Reply
#6
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.

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#7
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.

Adrian.
Reply


Forum Jump: