Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm writing a test script that checks for the function of Linux audio, so it checks Alsa, Pulseaudio and Jackd, if they are available and play a test sound. The output then gets presented in this form:
The working ones are shown in green, the others in red.
Now I can check if Alsa and Pulseaudio are working or not by trying to play a sound file and if that does not work, catching the failure return code.
But I have not been able to do that with jack, as there seem to be no audio players that only work on jack and fail when jack is not available. Mplayer and vlc have a jack module, but when jack is not available, it does not produce an error code.
Strangely enough, there are no official python jackd bindings. I building this in Python and would prefer if I could resolve this by using an external command and not having to build everything from scratch.
Do you know of a sound player that directly interfaces with jack and fails properly when jack is not available for playing sounds?
Once this is done, I might release this script on github, so others can benefit from it, if they run into Linux audio trouble and need reliable troubleshooting.=
According to the Jack User Documentation, you need to call jackd and alsa in the same command for jackd to work.
As for the test sound, the Jack doc provides an example which uses ecasound to produce a pure tone to test the sound card.
Extract from Jack User Documentation:
Code:
You can use ecasound to generate a pure sine wave tone for
testing the sound quality of your device.
ecasound -f:32,1,48000 -i null -o jack_alsa,myport -b:1024
-el:sine_fcac,440,1
From the Ecasound package description:
Quote:
Ecasound is a software package designed for multitrack audio processing. It
can be used for simple tasks like audio playback, recording and format
conversions, as well as for multitrack effect processing, mixing, recording
and signal recycling.
Thanks, that command sounded perfect. Unfortunately, it does not fail gracefully when the jack server is not running or not available:
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
jack server is not running or cannot be started
(eca-chainsetup) "rt" buffering mode selected.
(eca-chainsetup) Opened input "null", mode "read". Format: s32_le, channels 1, srate 48000, interleaved.
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
jack server is not running or cannot be started
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
^C^C
it just keeps going forever with the error messages.
There seems to be no way to play a sound on jack and have it fail, so I check for the existence of the jack process first and then play a sound:
pslist = psutil.get_process_list()
#if we have not found jack, it is off
jack_ok = False
for element in pslist:
if "jackd" in element.name:
jack_ok = True
if jack_ok == True:
#play a test sound
os.system("mplayer -really-quiet -ao jack /usr/share/tuxtype/sounds/harp.wav")
So the script is almost finished, I can't believe how many years I spend constantly troubleshooting my audio setup without every realizing I urgently needed a test-script like this.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.