Thank you for your donation!


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


Instruction Guide 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi
Adrian,

What are the specific modifications to moOde source files to support your software? If they are generally compatible with the rest of moOde it may be possible to incorporate them as a config option and avoid the need for all this hacking.

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
(01-27-2020, 06:02 PM)adrii Wrote: Hi JB

It sounds like the sound modules are loading in the wrong order, and so the loopback has device index 0 and your USB sound card has index 1, with Moode expecting your sound card to have index 0. With your changes you are starting the modules in different places, and the loopback driver is started later and has index 1.


The usual way to fix this is to specify the index number as a module option. E.g. create a file /etc/modprobe.d/alsa-base.conf with the following line

Code:
options snd-aloop index=1

Or, I believe an index of -2 means don't make this the primary device, which might be better.

I'll review the mpd_oled installation instructions against a clean install of Moode 6.4.1

Adrian.

Brilliant!!
I've added the file /etc/modprobe.d/alsa-base.conf with the following content:
Code:
options snd-aloop index=-2

Everything works fine now, with that config file and snd-aloop in /etc/modules it all works!
Reply
Strike that....it's not working
Why can't I delete my own post?

I'll be back - investigating further
Reply
Whatever I do, I can't get my usb dac to be device 0

cat /proc/asound/modules
0 snd_bcm2835
1 snd_aloop
2 snd_usb_audio

Editing /etc/modprobe.d/alsa-base.conf doesn't make any difference to the order and i've also tried editing /lib/modprobe.d/aliases.conf but also to no avail

If i put in options snd-usb-audio index=0, then the usb dac isn't listed at all
cat /proc/asound/modules
0 snd_bcm2835
1 snd_aloop

Something is preventing the usb dac to be device 0.
It was initially in /lib/modprobe.d/aliases.conf where it said snd-usb-audio index=-2 but changing that to 0, or just commenting out that line doesn't make any difference....
Reply
So i tried adding /etc/modprobe.d/blacklist-snd_bcm2835.conf and added: blacklist snd_bcm2835
This successfully removes snd_bcm2835 from the list and my usb dac is now listed as device 0

cat /proc/asound/modules
0 snd_usb_audio
1 snd_aloop

However, in Moode mpd config i can now no longer select Device type: usb audio device (it's not there in the dropdown box)
I'm lost....
Reply
I've now figured out that blacklisting snd_bcm2835 is not necessary.
You can use "options snd slots=snd_usb_audio,snd-aloop,snd_bcm2835" in /lib/modprobe.d/aliases.conf to change the order of the sounds cards.

I'm still stuck because in Moode mpd config the option to select device type: usb audio device is still not there.
Reply
Hi JB

I plugged in a no-name USB audio device, set the I2S audio device to none, and in the MPD audio device section I was able to select the USB device.

I used the same ALSA configuration file as before: https://github.com/antiprism/mpd_oled/is...-567146826

The other configuration I have is

Code:
pi@moode:~ $ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

i2c-dev
snd-aloop

pi@moode:~ $ cat /etc/modprobe.d/alsa-base.conf 
options snd_bcm2835 index=0
options snd_usb_audio index=1
options snd_aloop index=2

pi@moode:~ $ cat /proc/asound/modules
 0 snd_bcm2835
 1 snd_usb_audio
 2 snd_aloop

pi@moode:~ $ sudo ./mpd_oled -o 6 -b 21 -g 1 -f 25 -c alsa,plughw:Loopback,1


I have looked at the mpd_oled installation on Moode 6.4.1 as per the usual instructions, and the Moode patch file needs to be updated. I will post when this change is available. Thanks for letting me know about the issue!

Adrian.
Reply
Hi Tim

mpd_oled includes a spectrum analyser visualisation, and for this to work it needs a copy of the audio that is playing.

A basic way to do this is to get MPD to make a copy and send it to a FIFO. The current mpd_oled installation instructions patch Moode to append the contents of a file (/usr/local/etc/mpd_oled_fifo.conf) to /etc/mpd.conf and enable mpd_oled_FIFO as a second output. The file contains

Code:
audio_output {
        type            "fifo"
        name            "mpd_oled_FIFO"
        path            "/tmp/mpd_oled_fifo"
        format          "44100:16:2"
}

For Moode to support this approach to duplicating the audio generally, a possibility is to have a directory, e.g. /etc/audio_outputs, which could contain files containing the lines that should appear in an audio_outputs section. You could check that lines have the formats (with appropriate extra whitespace)

key "value"
#comment

and put a limit on the file length.

If the file is valid, and there is a name key, then the contents would be written to an audio_output section in /etc/mpd.conf and the name would be enabled for ouput.

However, this approach doesn't work with Spotify, so it might not be worth the effort. For something simpler, perhaps you could have a UI box for the number of FIFO copies and just add them as
Code:
audio_output {
        type            "fifo"
        name            "audio_copy_1_FIFO"
        path            "/tmp/audio_copy_1_fifo"
        format          "44100:16:2"
}

Accepting that the format may not suit all applications (but this could now be the default for mpd_oled, as Cava, which produces the spectrum analysis, will now handle a 48000 sample rate FIFO for input).


A much better solution though would be for Moode to provide a duplicate copy (or copies) of the currently playing ALSA stream. You can see my attempt to do this with Moode here (works for me with an I2S device and a USB device)

   https://github.com/antiprism/mpd_oled/is...-567146826

It seems like a lot of work for a little spectrum analyser, but imagine passing on the duplicate stream to another computer attached to a largescreen TV for an artistic-type audio visualisation that doesn't affect audio quality

  https://github.com/projectM-visualizer/projectm

And, if the Pi Zero can run a spectrum analyser, maybe some lighter-weight visualisations could be run on a Pi directly, and displayed on a local screen (touchscreen or over HDMI).

[I also found, when researching the ALSA configuration, that some people want the same audio to go to more than one device e.g. headphones and speakers, which is also supported by duplicating the ALSA stream.]

I appreciate that providing a configuration option for duplicating the ALSA stream likely involves core changes to Moode and the potential for extreme breakage.

Thanks for your interest!

Adrian.
Reply
Hi Adrian,

The order of the sound cards seem very important for some reason.
I now have:

cat /proc/asound/modules
0 snd_bcm2835
1 snd_usb_audio
2 snd_aloop

This works just fine!!

The weird thing is, when i blacklist snd_bcm2835 and the order looks like:
cat /proc/asound/modules
0 snd_usb_audio
1 snd_aloop

That doesn't work!!

So for some reason snd_bcm2835 needs to be there and it needs to be at index 0, then the usb dac needs to be at index 1 and the loop at index 2.
Any other combination breaks stuff...

Long story short: I like your solution to use ALSA configuration file for Moode that creates a duplicate of the hw:0,0 stream as this doesn't need any Moode hacking.
The only proviso is that the order of the sound cards must be correct for this to work, but this seems easy enough now that we've figured that out!

Thanks for all the hard work and support, both Adrian and Tim!
Reply
I have updated the mpd_oled repository with a new patch for Moode 6.4.1.

JB, I wish I could propose the ALSA method as the primary solution, but I don't know how the different possible audio configurations will present themselves, i.e. whether the final output will always be of the form hw:X,Y, or even whether overriding the hw: plugin will interfere with certain configurations. Anyway, as the method is working for a basic USB card setup, and a basic I2S card setup, I will prepare some detailed instructions for these two cases.

Adrian.
Reply


Forum Jump: