Repository navigation
Open
Description
While trying to play 24-bit/96kHz or 24-bit 192kHz files with aplay the files are downsampled to 16-bit
pi@raspberrypi ~ $ aplay -v audio/JimmyAndTheCrows96kHz.wav
Playing WAVE 'audio/JimmyAndTheCrows96kHz.wav' : Signed 24 bit Little Endian in 3bytes, Rate 96000 Hz, Stereo
Plug PCM: Rate conversion PCM (48000, sformat=S16_LE)
Converter: linear-interpolation
Protocol version: 10002
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S24_3LE
subformat : STD
channels : 2
rate : 96000
exact rate : 96000 (96000/1)
msbits : 24
buffer_size : 32768
period_size : 8192
period_time : 85333
tstamp_mode : NONE
period_step : 1
avail_min : 8192
period_event : 0
start_threshold : 32768
stop_threshold : 32768
silence_threshold: 0
silence_size : 0
boundary : 1073741824
Slave: Hardware PCM card 0 'bcm2835 ALSA' device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 16384
period_size : 4096
period_time : 85333
tstamp_mode : NONE
period_step : 1
avail_min : 4096
period_event : 0
start_threshold : 16384
stop_threshold : 16384
silence_threshold: 0
silence_size : 0
boundary : 1073741824
appl_ptr : 0
hw_ptr : 0
pi@raspberrypi ~ $ mplayer -ao alsa audio/test32bit_44.1kHz.wav
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing audio/test32bit_44.1kHz.wav.
libavformat version 53.21.1 (external)
Mismatching header version 53.19.0
Audio only file format detected.
Load subtitles in audio/
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 2 ch, s32le, 2822.4 kbit/100.00% (ratio: 352800->352800)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [alsa] 44100Hz 2ch s32le (4 bytes per sample)
Video: no video
Starting playback...
A: 23.5 (23.5) of 66.0 (01:06.0) 1.8%
MPlayer interrupted by signal 2 in module: play_audio
A: 23.6 (23.5) of 66.0 (01:06.0) 1.8%
Exiting... (Quit)
pi@raspberrypi ~ $ mplayer -ao alsa audio/JimmyAndTheCrows96kHz.wav
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing audio/JimmyAndTheCrows96kHz.wav.
libavformat version 53.21.1 (external)
Mismatching header version 53.19.0
libavformat file format detected.
[wav @ 0xb63ecc78]max_analyze_duration reached
[lavf] stream 0: audio (pcm_s24le), -aid 0
Clip info:
comment: Jimmy And The Crows
encoded_by: Keith Greeninger, Chris Kee & Br
date: 2013-07-25
creation_time: 14:58:00
time_reference: 0
coding_history: A=PCM,F=96000,W=24,M=stereo,T=KORG AudioGate ver.2.3.2 (Windows 7),
artist: Keith Greeninger, Chris Kee & Brain
title: Jimmy And The Crows
Load subtitles in audio/
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 96000 Hz, 2 ch, s24le, 4608.0 kbit/100.00% (ratio: 576000->576000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [alsa] 48000Hz 2ch s24le (3 bytes per sample)
Video: no video
Starting playback...
A: 36.9 (36.9) of 475.2 (07:55.2) 9.2%
MPlayer interrupted by signal 2 in module: decode_audio
A: 37.0 (36.9) of 475.2 (07:55.2) 9.2%
Exiting... (Quit)
But playing with omxplayer they "appear" to play back correctly:
pi@raspberrypi ~ $ omxplayer -p audio/JimmyAndTheCrows96kHz.wav
Audio codec pcm_s24le channels 2 samplerate 96000 bitspersample 24
Subtitle count: 0, state: off, index: 1, delay: 0
have a nice day ;)
Reacted by Ben Leggett
Activity
popcornmix commentedon Jan 14, 2014
Alsa limits sampling rate to 48kHz, but can easily be increased.
It also only supports 8 and 16-bit samples. This can be increased although may be a little more involved.
omxplayer will honour the sampling rate. I believe the code path may involve the samples being converted to 16-bit.
The OMX API does allow 32-bit samples to be submitted (although hdmi is limited to 24-bit), so hello_audio could be modified to output higher depth samples. Whether you could hear the difference is debatable.
GeorgeIoak commentedon Jan 14, 2014
24-bit audio files are becoming more popular now. I just got back from CES and there was a whole room dedicated to companies that provide high resolution audio files for downloads. Sony had a whole section in their booth for high res audio and even Creative Labs had a section for high res audio.
The market may be small but it is growing.
popcornmix commentedon Jan 14, 2014
Agreed. If the hardware can support it, and some people want it, then I'd like to make it available.
But very subtle improvements are obviously lower priority than major bugs reported.
But, it's on my list!
GeorgeIoak commentedon Jan 14, 2014
Don't start a war with comments like "subtle improvements", trust me, there are quite a few people out there who are very passionate about this stuff. Do you know of anyone who is knowledgeable about this enough to help?
P33M commentedon Jan 14, 2014
Yes. Popcornmix.
GeorgeIoak commentedon Jan 14, 2014
Sorry, I meant besides popcornmix since I'm sure he's busy and this isn't at the top of his to do list.
popcornmix commentedon Jan 14, 2014
Increasing the max samplerate of alsa driver is trivial. Just edit the 48000 and rebuild kernel.
Supporting > 16-bit samples is trivial on the kernel side, but I'd guess there will be GPU side issues that need debugging (you can specify 32-bit samples and it does things with that, but it's never been tested, so is unlikely to work).
hello_audio already supports up to 192kHz. Making it support 32-bit samples should just work. Anyone can try that, and produce a "higher quality" player.
GeorgeIoak commentedon Jan 14, 2014
Yes, we've already checked the sample rate and as you say, it's trivial. 32-bit doesn't help too much in the real world since almost nothing is available in 32-bit. The trick is getting 24-bit packaged in the 32-bit and processed properly.
popcornmix commentedon Jan 14, 2014
Most APIs don't deal with actual packed 24-bit quantities as they are expensive to access.
Normally APIs (like openmax) will just deal with 32-bit quanties and the least significant 8 bits will not be used.
I'll need to check if ALSA treats SNDRV_PCM_FMTBIT_S24 as packed or not.
GeorgeIoak commentedon Jan 14, 2014
I think it's actually SNDRV_PCM_FMTBIT_S24_3LE that's needed if I'm not mistaken
amtssp commentedon Jun 10, 2014
Hi.
Previously (in kernel 3.14.1 and before (3.13.y) I was able to output 192khz (32_LE) via HDMI (after having changed the file and rebuild the module (like this) :
.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
.rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_192000,
.rate_min = 8000,
.rate_max = 192000,
.channels_min = 1,
.channels_max = 2
However, in later kernels it now outputs only 48 khz even though I have applied the same changes and build the modules like I always have been doing. At the moment I'm using 3.14.4.
I use it for making the small piCorePlayer which is used as a Squeezebox replacement player. It is not pure raspian as I need to rebuild the kernel to produce a tinycore linux. However, there has been no problems before, only at the latest kernels.
I noticed that the behaviour of how HDMI is selected has been changed - could that have an influence on the issue I'm seeing?
Steen
popcornmix commentedon Jun 10, 2014
@amtssp
The firmware does uses the maximum supported sample rate from the EDID as a limit.
What does "tvservice -a" report?
Try adding hdmi_force_edid_audio=1 which assumes all audio formats/rates are supported.
amtssp commentedon Jun 10, 2014
Thanks for your reply.
I already use the following commands in order to try to force audio via
HDMI.
Most users are using this player without a screen attached as it is only an
audio player.
sudo echo hdmi_force_mode=1
sudo echo hdmi_drive=2
sudo echo hdmi_force_hotplug=1
sudo echo hdmi_force_edid_audio=1
sudo echo hdmi_ignore_edid=0xa5000080
I will try to see if I can figure out exactly when the behaviour was
changed.
Sorry the tvservice command was not found - as I stated I'm using microcore
linux
tc@piCorePlayer:~$ tvservice -a
-sh: tvservice: not found
If you have time please try it:
https://sites.google.com/site/picoreplayer/home
Steen
On Tue, Jun 10, 2014 at 1:06 PM, popcornmix notifications@github.com
wrote:
popcornmix commentedon Jun 10, 2014
I'd suggest removing hdmi_ignore_edid=0xa5000080.
We now allow HDMI modes to be forced even if not listed in the EDID.
There was a firmware commit on "March 8th 2004" labelled:
"audioplus: limit sample rates chosen to ones supported by hardware"
so might be worth trying a firmware from just before and just after that point.
Is there a simple way of making PiCorePlayer play an audio file without a squeezebox client?
I'm not sure our work's network will support it.
(If I can play a file through ssh or http then that would be easier)
JulienCa commentedon Mar 26, 2015
Hello
Did anyone try to resolve this 24 bits issue and 48000 Hz limit in raspberry ?
I have some files from qobuz.com which are in 24 bits / 96 kHz and I cannot succeed playing them with mpd : it is always resampled to 16 bits / 48 or 44.1 khz depending on the existing limit in mpd.conf (format "44100:16:2") is activated or not. But is never played in the original format whereas omxplayer does it well.
I am ok to make a test if someone can compile the sources. Or if someone could give me information about the compiling process because I never did it on a raspberry. My first step would be to compile the unmodified sources and see if I can reproduce the reference image. Then I could try some code modifications as suggested above.
16 remaining items
w3ua commentedon Apr 28, 2019
Any progress?
nvme-pci: use blk-mq mapping for unmanaged irqs
nvme-pci: use blk-mq mapping for unmanaged irqs
jcucurull commentedon Sep 24, 2021
Any news on that? Any action is taken?
Hoeze commentedon Aug 13, 2022
@popcornmix Are there any updates on this issue?
popcornmix commentedon Aug 15, 2022
This is supported under kms from the kernel.
Apps like kodi are able to output 8 channel 192kHz audio over hdmi.
Hoeze commentedon Aug 15, 2022
@popcornmix thanks for your answer.
I just tried your command on my (freshly installed) Pi Zero:
Is this a limitation to my Pi Zero or can I do something about this?
For the record, I have also tried setting
hdmi_force_edid_audio=1, without any changes to above output.System details:
Details
Hoeze commentedon Aug 15, 2022
In the end, what I'd like to achieve is to directly loop USB OTG Audio to HDMI:
alsaloop -c8 -C default:CARD=UAC2Gadget -P default:CARD=vc4hdmi --rate=192000 -f S32_LEHowever, I have no clue why I fail with this...
My audio setup can be found (and easily reproduced) here:
bpf: Fix a race condition between btf_put() and map_free()
bpf: Fix a race condition between btf_put() and map_free()
cxl/mbox: Use proper endpoint validity check upon sanitize
bpf: Fix a race condition between btf_put() and map_free()
audio: drop redundant --audio-format=s16
selftests/bpf: Enable timed may_goto tests for arm64
Merge branch 'bpf-arm64-support-for-timed-may_goto'