raspberry pi spdif hats - BASS chooses s16_le format for 24 bit audio

Started by tom p,

tom p

issue affecting spdif/digi audio HATs commonly used on raspberry pi (linux)
example devices allo digione, hifiberry digi, others using same wm8804 chipset
alsa driver supports s24_le and s16_le formats
with 24 bit audio, BASS chooses s16_le and truncates, why not s24_le?

Ian @ un4seen

Are you using the BASS_SAMPLE_FLOAT flag in your stream creation calls? Without that, the streams will be limited to 16-bit.

If you still have the problem when using the BASS_SAMPLE_FLOAT flag, please post what "aplay -D X --dump-hw-params /dev/random" reports (where 'X' is the ALSA device you're using - you can get it from BASS_DEVICEINFO::driver). Also confirm what BASS version you're using (with BASS_GetVersion) and the arch.

tom p

using version 2.4.17

yes, pretty sure i'm setting bass_sample_float
HSTREAM stream = BASS_StreamCreateFile(FALSE, filename, 0, 0, BASS_SAMPLE_FLOAT);
channel info: freq: 44100 Hz, ch: 2, flags: 0x110, origres: 24
$ cat /proc/asound/sndallodigione/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 441
buffer_size: 1764

$ aplay -D hw:0 --dump-hw-params /dev/random
Playing raw data '/dev/random' : Unsigned 8 bit, Rate 8000 Hz, Mono
HW Params of device "hw:0":
--------------------
ACCESS:  MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT:  S16_LE S24_LE
SUBFORMAT:  STD
SAMPLE_BITS: [16 32]
FRAME_BITS: [32 64]
CHANNELS: 2
RATE: [32000 192000]
PERIOD_TIME: (166 2048000]
PERIOD_SIZE: [32 65536]
PERIOD_BYTES: [256 524288]
PERIODS: [2 4096]
BUFFER_TIME: (333 4096000]
BUFFER_SIZE: [64 131072]
BUFFER_BYTES: [256 524288]
TICK_TIME: ALL
--------------------
aplay: set_params:1352: Sample format non available
Available formats:
- S16_LE
- S24_LE

Ian @ un4seen

Thanks. BASS currently supports S32_LE (32-bit) and S24_3LE (24-bit) formats, but indeed not S24_LE (24-bit padded to 32-bit). Here's an update that should add support for it:

    www.un4seen.com/stuff/bass-linux.zip

tom p

this works, thank you!

(these pi spdif devices are the only ones i've used that need the s24_le format)