PulseAudio on OpenWRT with MPD and other Stuff: Difference between revisions
mNo edit summary |
mNo edit summary |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
READ THIS FIRST: [[ALSA Basics|ALSA Basics - Wiki.TerraBase.info]] | |||
First of all, good to be back. Issues with MediaWiki, along with time constraints on fixing it, have prevented new articles from being created. | First of all, good to be back. Issues with MediaWiki, along with time constraints on fixing it, have prevented new articles from being created. | ||
Line 24: | Line 26: | ||
Dependencies include some basic ALSA (Advanced Linux Sound Architecture) stuff, but a couple of more items are nice to have for several reason, including testing, so; | Dependencies include some basic ALSA (Advanced Linux Sound Architecture) stuff, but a couple of more items are nice to have for several reason, including testing, so; | ||
opkg install alsa-utils alsa-ucm-conf mpd-full mpd-avahi-service mpc lib<ins>mpd</ins>client | opkg install ffmpeg-full ffprobe alsa-utils alsa-ucm-conf mpd-full mpd-avahi-service mpc lib<ins>mpd</ins>client | ||
...and maybe opkg install madplay mpg123 (they don't install any services, so they're just there if you need them) | ...and maybe opkg install madplay mpg123 (they don't install any services, so they're just there if you need them) | ||
Line 33: | Line 35: | ||
...but first: opkg install python3 (don't worry that the OpenWRT version of Python 3 is lower than the required version of PulseMixer, as it seems to work fine) | ...but first: opkg install python3 (don't worry that the OpenWRT version of Python 3 is lower than the required version of PulseMixer, as it seems to work fine) | ||
==== MPD Notes ==== | |||
* Make sure to install ffmpeg-full, using opkg install ffmpeg-full EXPLICITLY, otherwise ffmpeg-mini will be installed (which miraculously does NOT include support for the simplest format there is, .WAV Files) | |||
* ffprobe is a useful tool to install | |||
* Modify the /etc/init.d/mpd File to run as root:root (just do it, saves a lot of trouble later) | |||
====The Errors==== | ====The Errors==== | ||
Line 40: | Line 48: | ||
chmod: /dev/mixer: No such file or directory | chmod: /dev/mixer: No such file or directory | ||
chmod: /dev/dsp: No such file or directory | chmod: /dev/dsp: No such file or directory | ||
</syntaxhighlight>Will this fix it (spoiler alert, NO, so like Frankie said "don't do it")?: opkg install gst1-mod-dv<ins>dsp</ins>u gst1-mod-audiomixer (a bunch of dependencies would be installed too). We'll get to the fix later, let's focus on the "Show Stopper" | </syntaxhighlight>Will this fix it (spoiler alert, NO, so like Frankie said "don't do it")?: opkg install gst1-mod-dv<ins>dsp</ins>u gst1-mod-audiomixer (a bunch of dependencies would be installed too). We'll get to the fix later, let's focus on the "Show Stopper". Just kidding, fix is below; | ||
*...just make sure the Audio Device is plugged in. | |||
=====The "Show Stopper" for PulseAudio===== | =====The "Show Stopper" for PulseAudio===== | ||
Line 58: | Line 68: | ||
There's a bunch of stuff about Cookies (one of PulseAudio's security methods), anonymous authentication, etc., but this is the simplest and works without changing PulseAudio's default configuration. | There's a bunch of stuff about Cookies (one of PulseAudio's security methods), anonymous authentication, etc., but this is the simplest and works without changing PulseAudio's default configuration. | ||
===Surround Sound=== | |||
First thing to do is this, enable or put this item in the /etc/pulse/default.conf file: <code>default-sample-channels = 6</code> | |||
Then add all of the below instead (to cut down on any pops and hisses; | |||
===Bluetooth (AKA Bluez)=== | ===Bluetooth (AKA Bluez)=== | ||
Line 78: | Line 93: | ||
====FIRST! (or rather the next thing to do)==== | ====FIRST! (or rather the next thing to do)==== | ||
REMEMBER: PulseAudio has to be properly configured and running for Bluetooth (bluetoothctl) to work! and because OpenWRT doesn't include of the Bluez Tools (nope, not Blues Clues), make sure PulseAudio has the Bluetooth Modules loaded up and ready to go (IE, the AVAHI version of PulseAudio)! | |||
See: [[PulseAudio on OpenWRT with MPD and other Stuff#Installation of Software]] | |||
AND make sure the /etc/pulse/system.pa loads the Bluetooth Module | |||
====Crap that Does NOT work==== | ====Crap that Does NOT work==== | ||
Line 89: | Line 106: | ||
===ALSA Related Commands=== | ===ALSA Related Commands=== | ||
====Starting and Stopping ALSA==== | |||
Good luck! Ain't no ALSA service. Oh, wait, try the following (it's the only solution besides restarting that seems to work, because modpropbe seems to be 'neutered' on OpenWRT with no additional 'modprobe package' available); | |||
*"Stop ALSA Service": echo '1-1' > /sys/bus/usb/drivers/usb/unbind | |||
*"Start ALSA Service": echo '1-1' > /sys/bus/usb/drivers/usb/bind | |||
*...followed by: alsactl restore | |||
*...and just as a note, stopping and starting pulseaudio has the net effect of re-reading the /etc/asound.conf file. | |||
*...and pkill -9 pulseaudio (works great if the process is 'stuck', and don't forget okpg install procps-ng-pkill) | |||
/usr/share/pulseaudio/alsa-mixer/paths/<span> </span>: Path to ALSAMIXER settings (yup, PulseAudio is in the path!) | |||
/proc/asound/card0/usbmixer<span> </span>: possible location where ALSAMIXER gets names for different controls | |||
alsactl<span> </span>: Good for testing basic sound device settings (Top Tip: By default, for whatever reason, the "state" (AKA stored configuration) Directory (/var/lib/alsa) does not exist, so create it. | |||
aplay -D stereoB BeeGees.wav | |||
aplay -D hw:0,0 -c 6 BeeGees.wav -vv<span> </span>: Will show information and a 'meter', along with playing the song. | |||
speaker-test -D hw:0,0 -c 4 --chmap=FL,FR,FC,LFE -t wav<span> </span>: Tests the speaker output (make sure alsa-utils-tests is installed), --chmap "allows for putting things in a different order". | |||
/var/lib/alsa/asound.state<span> </span>: Filie in a Directory (gonna have to create the 'alsa' sub-directory manually as it isn't created during ALSA installation) that preserves settings in ALSA Mixer | |||
alsactl store | |||
speaker-test -D hw:0,0 -c 8 --chmap=FL,FR,FC,LFE,SL,SR,SL,SR -t wav<span> </span>: For testing 7.1 surround sound, with a catch: Ain't no RL (Rear Left) or RR (Rear Right), there are two SL (Side Left(s)) and two SR (Side Right(s)). Hey, it is what it is. Now you know. | |||
amixer -c 0 sset 'PCM Capture Source' 'Line'<span> </span>: A handy command to change the input of a USB Audio Device that support more than one input / source. Keep in mind the two items in the quotes ( 'PCM Capture Source' and 'Line' ) are potentially unique to every USB Audio Device. How can one get that information? A couple commands (some noted below with details, but for now, just the commands): amixer scontrols (that's two words / commands typed together) and then: amixer -c 0 get 'PCM Capture Source' ( again, modify the item in ' ' (quotes) to the name obtained in the previous command) | |||
alsamixer: shows a text GUI of controls | alsamixer: shows a text GUI of controls | ||
cat /sys/kernel/debug/usb/devices<span> </span>: shows details about various USB Devices | |||
aplay -l<span> </span>: shows list of sound devices | aplay -l<span> </span>: shows list of sound devices | ||
Line 102: | Line 151: | ||
amixer scontents<span> </span>: Shows a detailed list of devices | amixer scontents<span> </span>: Shows a detailed list of devices | ||
alsactl info<span> </span>: Shows information about sound device | |||
amixer -c 0 controls<span> </span>: Shows detailed information about the controls_count variable from alsactl info | |||
amixer -c 0 cget numid=1<span> </span>: Shows even more detailed information about the 'control' from amixer command above | |||
amixer -c 0 get 'WhatEverNameOfDevice'<span> </span>: 'Gets' the 'capabilities' of an 'item' / device ( WhatEverNameOfDevice can be obtained with the amixer scontents command above) | |||
Example below;<syntaxhighlight lang="text"> | Example below;<syntaxhighlight lang="text"> | ||
Line 171: | Line 228: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Some WTF? Holes One Can Fall Into === | ===Some WTF? Holes One Can Fall Into=== | ||
==== module-detect ==== | ====module-detect==== | ||
In /etc/pulse/system.pa load-module module-detect (Works great, but can also cause some unexpected issues) | In /etc/pulse/system.pa load-module module-detect (Works great, but can also cause some unexpected issues) | ||
Line 184: | Line 241: | ||
Experiments showed that even loading module-detect after module-alsa-sink still produces an error. So either module-detect always runs first OR module-detect doesn't check and see if an ALSA device is already loaded. | Experiments showed that even loading module-detect after module-alsa-sink still produces an error. So either module-detect always runs first OR module-detect doesn't check and see if an ALSA device is already loaded. | ||
=== Useful Commands for Testing (from a live file, hence the # Comment Tags) === | ====module-native-protocol-unix==== | ||
If the module-native-protocol-unix isn't loaded ( load-module module-native-protocol-unix ) then the PACTL Command won't work. | |||
The error will be: pa_context_connect() failed: Connection refused | |||
===Web / HTML GUIs=== | |||
====amixer-webui==== | |||
opkg install git git-http libmbedtls python3 python3-pip (assumes ALSA is installed already) (substitute python2 for older versions of OpenWRT) | |||
pip3 install flask | |||
git clone <nowiki>https://github.com/JiriSko/amixer-webui.git</nowiki> | |||
./alsamixer_webui.py -p 8080 -l W.X.Y.Z (where W.X.Y.Z is the IP Address of the router) | |||
====amixer-web==== | |||
...won't work as OpenWRT doesn't have the ALSA Mixer "library.so" files or packages | |||
====viacast - alsamixer==== | |||
Looks great. Doesn't work (even though it shows the correct USB realtek chip). On a side note, REACT installs and works on OpenWRT (Hmmm, a good thing???) | |||
===Useful Commands for Testing (from a live file, hence the # Comment Tags)=== | |||
====Multi-Channel Testing (first need a multi-channel file)==== | |||
sox CominUnderFire.mp3 --show-progress -t wav CominUnderFire_6ch.wav remix 1v0.8 2v0.8 1v0.5 2v0.5 1v0.3 2v0.3 | |||
Input File : 'CominUnderFire.mp3' | |||
Channels : 2 | |||
Sample Rate <span> </span>: 44100 | |||
Precision <span> </span>: 16-bit | |||
Duration : 00:04:14.49 = 11223097 samples = 19086.9 CDDA sectors | |||
File Size <span> </span>: 10.2M | |||
Bit Rate : 320k | |||
Sample Encoding: MPEG audio (layer I, II or III) | |||
Comments : | |||
Title=08 - Comin' Under Fire | |||
Artist=Def Leppard | |||
Album=Pyromania | |||
Tracknumber=8 | |||
Genre=Power Metal | |||
In:100% 00:04:14.48 [00:00:00.01] Out:11.2M [ | ] Hd:2.6 Clip:0 | |||
Done. | |||
...and what channels are available from a device, well, use this command: amixer -c 0 scontents | |||
Below is the output for a 7.1 surround USB Audio Device;<syntaxhighlight lang="text"> | |||
Simple mixer control 'PCM',0 | |||
Capabilities: pvolume pswitch pswitch-joined | |||
Playback channels: Front Left - Front Right - Rear Left - Rear Right - Front Center - Woofer - Side Left - Side Right | |||
Limits: Playback 0 - 87 | |||
Mono: | |||
Front Left: Playback 37 [43%] [-37.50dB] [on] | |||
Front Right: Playback 37 [43%] [-37.50dB] [on] | |||
Rear Left: Playback 60 [69%] [-20.25dB] [on] | |||
Rear Right: Playback 60 [69%] [-20.25dB] [on] | |||
Front Center: Playback 60 [69%] [-20.25dB] [on] | |||
Woofer: Playback 60 [69%] [-20.25dB] [on] | |||
Side Left: Playback 60 [69%] [-20.25dB] [on] | |||
Side Right: Playback 60 [69%] [-20.25dB] [on] | |||
Simple mixer control 'PCM',1 | |||
Capabilities: pvolume pswitch pswitch-joined | |||
Playback channels: Front Left - Front Right | |||
Limits: Playback 0 - 87 | |||
Mono: | |||
Front Left: Playback 4 [5%] [-62.25dB] [on] | |||
Front Right: Playback 4 [5%] [-62.25dB] [on] | |||
Simple mixer control 'Line',0 | |||
Capabilities: cvolume cswitch cswitch-joined | |||
Capture channels: Front Left - Front Right | |||
Limits: Capture 0 - 56 | |||
Front Left: Capture 16 [29%] [0.00dB] [on] | |||
Front Right: Capture 16 [29%] [0.00dB] [on] | |||
Simple mixer control 'Mic',0 | |||
Capabilities: cvolume cswitch cswitch-joined | |||
Capture channels: Front Left - Front Right | |||
Limits: Capture 0 - 56 | |||
Front Left: Capture 16 [29%] [0.00dB] [on] | |||
Front Right: Capture 16 [29%] [0.00dB] [on] | |||
root@PandoraWRT:/MP3# | |||
</syntaxhighlight> | |||
<nowiki>###</nowiki> Useful Commands for testing stuff; | <nowiki>###</nowiki> Useful Commands for testing stuff; | ||
Line 258: | Line 413: | ||
<nowiki>###</nowiki> /usr/bin/pulseaudio --system --disallow-exit --disable-shm --exit-idle-time=-1 --verbose --log-level=debug --log-target=stderr | <nowiki>###</nowiki> /usr/bin/pulseaudio --system --disallow-exit --disable-shm --exit-idle-time=-1 --verbose --log-level=debug --log-target=stderr | ||
<nowiki>###</nowiki> /usr/bin/pulseaudio --system --disallow-exit --disable-shm --exit-idle-time=-1 -vvvvvv --log-level=debug --log-target=stderr | |||
<nowiki>###</nowiki> | <nowiki>###</nowiki> | ||
Line 358: | Line 515: | ||
<nowiki>###</nowiki> Configuration Services and Scripts (by me): /etc/init.d/bt-reconnect, /etc/bluetooth.sh, /etc/pulse/pulseaudio.sh | <nowiki>###</nowiki> Configuration Services and Scripts (by me): /etc/init.d/bt-reconnect, /etc/bluetooth.sh, /etc/pulse/pulseaudio.sh | ||
<br /> | |||
===Rough Notes;=== | |||
The below two items are functionally equivalent; | |||
----pcm.LINE { | |||
type plug | |||
slave.pcm { | |||
type route | |||
slave.pcm "hw:0,0" | |||
slave.channels 2 | |||
ttable.0.0 1 | |||
ttable.1.1 1 | |||
} | |||
} | |||
---- | |||
pcm.line { | |||
type dmix | |||
ipc_key 1024 | |||
slave { | |||
pcm "hw:0,0" | |||
channels 2 | |||
} | |||
} | |||
<nowiki>#</nowiki> Line Test | |||
pcm.LINE { | |||
type plug | |||
slave.pcm { | |||
type route | |||
slave.pcm "line" | |||
slave.channels 2 | |||
ttable.0.0 1 | |||
ttable.1.1 1 | |||
} | |||
} | |||
----<br /> |