Hi, thanks for the help.
But it doesn’t solve my problem. Still no audio in headless morde. And it makes me understand it even less. I have a couple of questions and observations now.
1. Should jack run or not?
Observation 1
Indeed, if I specify the pisound card with
aplay -D hw:pisound ~/path/to/my_audio.wav
It gives me this error: aplay: main:830: audio open error: Device or resource busy
And indeed, if I kill jack with sudo systemctl stop jack
, the error is gone, but I still get no sound out!
Observation 2
When, while running the graphical environment, (with startx
), the same command (explicitly specifying the pisound card), gives me the exact same error:
aplay -D hw:pisound ~/path/to/my_audio.wav
yields → aplay: main:830: audio open error: Device or resource busy
But without specifying it (while the graphical environment is running), there is full audio from the pisound card!
aplay ~/path/to/my_audio.wav
works!
Observation 3
Furthermore, if I start the graphical environment with jack stopped, or when the graphical environment is already running and I kill jack, none of my python scripts (using the simpleaudio
module) is producing any sound. Also the simple aplay ~/path/to/my_audio.wav
isn’t working (no errors, but also no sound).
So, I get the feeling I shouldn’t try to mess with the jack server, and just leave it running
2. Is always necessary to specify the sound card?
I’m assuming Jack takes care of specifying which audio card to use as default. Because if I don’t specify it with aplay
or with the python script, (and it is not running headless), it works.
Observation 4
If the graphical environment is running and jack server is stopped, the only way to get audio out, is to use aplay
and specify the card:
aplay -D hw:pisound ~/path/to/my_audio.wav
yields → Playing WAVE '/home/patch/path/to/my_audio.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
and actually plays the sound.
But when not specifying the card:
aplay ~/path/to/my_audio.wav
it yields the same → Playing WAVE '/home/patch/path/to/my_audio.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
.
Thus no error, but also no sound.
And I don’t know how I can specify the audio card with the simpleaudio
python module. So it seems I need the Jack server to run for that reason.
3. Deeper in the rabbit hole: What is the difference between specifying the card and not specifying it?
Observation 5
This is with a different audio file. (The one above was 16bit, 48kHz. This one is 24bit)
Environment: graphical OS running + Jack server stopped.
aplay ~/path/to/otherfile48kHz24bit.wav
yields → Playing WAVE '/home/patch/path/to/otherfile48kHz24bit.wav' : Signed 24 bit Little Endian in 3bytes, Rate 48000 Hz, Stereo
yet produces no audio.
When specifying the sound card:
aplay -D hw:pisound ~/path/to/otherfile48kHz24bit.wav
yields this error:
Playing WAVE '/home/patch/path/to/otherfile48kHz24bit.wav' : Signed 24 bit Little Endian in 3bytes, Rate 48000 Hz, Stereo
aplay: set_params:1343: Sample format non available
Available formats:
- S16_LE
- S24_LE
- S32_LE
What does this error mean and why do I get it?
As far as I know, and as far as I can create or convert (with sox
), this file is 24 bit signed, little endian.
Also, when Jack server is running in the graphical OS,
aplay ~/path/to/otherfile48kHz24bit.wav
is playing the audio just fine. So it is not a problem with aplay
or with the audio format. (Or at least that is how it seems.) This error only is displayed when specifying the audio card.
I feel I am still tumbling and tumbling down the rabbit hole, with aplay
, -D hw:pisound
, the Jack server and 24bit audio formats.
But my initial question how to get audio from the pisound without firing up the graphical OS, gets further away.