Author Topic: No sound through audio device  (Read 846 times)

eschime

  • Posts: 5
No sound through audio device
« on: 29 Oct '18 - 21:15 »
I have a display connected to my linux device (arm64) that uses an hdmi audio device. If I test the output using "sudo speaker-test -f 44100 -t wav -c 2 -D hw:0" I get sound out of it. However, if I try and play through it using BASS, it seems to initialize properly, but doesn't output any sound. I also have a dac that plays fine through BASS, but I can't seem to get any audio through the hdmi output device. Any ideas?

eschime

  • Posts: 5
Re: No sound through audio device
« Reply #1 on: 30 Oct '18 - 15:19 »
I got it working by setting the BASS_DEVICE_STEREO flag during init. Apparently the HDMI device does not work with the BASS_DEVICE_MONO flag. Does anyone know how to tell if a device doesn't support MONO? Both of my audio devices return the same data when calling BASS_GetInfo and flags is always set to 0. One supports MONO, but the HDMI device has no sound when I set the MONO flag?

Ian @ un4seen

  • Administrator
  • Posts: 22036
Re: No sound through audio device
« Reply #2 on: 30 Oct '18 - 17:08 »
If you don't use either the BASS_DEVICE_MONO or BASS_DEVICE_STEREO flag then BASS_Init will try to detect the number of available speakers. Does the problem happen then too?

eschime

  • Posts: 5
Re: No sound through audio device
« Reply #3 on: 30 Oct '18 - 18:11 »
If I set flags to 0, I get no sound. I also have to set the freq to get sound and it works even without the BASS_DEVICE_FREQ flag which is weird, I thought it only looked at the freq parameter when the BASS_DEVICE_FREQ is set.

These work.
BASS_Init (device_number, 44100, BASS_DEVICE_STEREO, 0, NULL)
BASS_Init (device_number, 44100, BASS_DEVICE_STEREO | BASS_DEVICE_FREQ, 0, NULL)

These do not work
BASS_Init (device_number, 0, 0, 0, NULL)
BASS_Init (device_number, 44100, 0, 0, NULL)
BASS_Init (device_number, 44100, BASS_DEVICE_FREQ, 0, NULL)
BASS_Init (device_number, 0, BASS_DEVICE_STEREO, 0, NULL)
BASS_Init (device_number, 44100, BASS_DEVICE_MONO, 0, NULL)
BASS_Init (device_number, 44100, BASS_DEVICE_MONO | BASS_DEVICE_FREQ, 0, NULL)


Ian @ un4seen

  • Administrator
  • Posts: 22036
Re: No sound through audio device
« Reply #4 on: 31 Oct '18 - 16:36 »
The BASS_DEVICE_FREQ flag has no effect on Linux, and the "freq" parameter will always be used as a suggestion to the device/driver. If the device/driver doesn't support the requested rate then it should automatically choose the closest one that is supported. You can use BASS_GetInfo to check what rate is actually being used, and also how many speakers/channels. What numbers do you see for those 2 things if you don't use any flags in the BASS_Init call?

Also, what do you see if you run "aplay -D hw:0 -f cd -d 1 --dump-hw-params /dev/zero"? Replace "hw:0" if using a different device with BASS.

eschime

  • Posts: 5
Re: No sound through audio device
« Reply #5 on: 31 Oct '18 - 17:11 »
aplay -D hw:0 -f cd -d 1 --dump-hw-params /dev/zero

Playing raw data '/dev/zero' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
HW Params of device "hw:0":
--------------------
ACCESS:  RW_INTERLEAVED
FORMAT:  S16_LE S24_LE S32_LE
SUBFORMAT:  STD
SAMPLE_BITS: [16 32]
FRAME_BITS: [16 256]
CHANNELS: [1 8]
RATE: [8000 192000]
PERIOD_TIME: (10 2048000]
PERIOD_SIZE: [2 16384]
PERIOD_BYTES: [64 65536]
PERIODS: [2 256]
BUFFER_TIME: (20 4096000]
BUFFER_SIZE: [4 32768]
BUFFER_BYTES: [32 65536]
TICK_TIME: ALL
--------------------

BASS_Init (device_number, 0, 0, 0, NULL)

freq: 8000
initflags: 0
speakers: 8

If I do the same thing with the DAC I have it sets the freq to 8000 as well, but only shows 2 speakers. Although the DAC has sound at this setting, the HDMI device does not, but it looks like it does support the 8000.


Ian @ un4seen

  • Administrator
  • Posts: 22036
Re: No sound through audio device
« Reply #6 on: 31 Oct '18 - 17:54 »
It looks like the issue there is that the driver says there are 8 channels available but the device doesn't actually like/support 8 channels. Unless the BASS_DEVICE_STEREO flag is used, BASS will attempt to use all available channels/speakers. So it looks like you do need to use that flag in this case. Note you also need to provide a sample rate in the "freq" parameter (don't use 0).

eschime

  • Posts: 5
Re: No sound through audio device
« Reply #7 on: 31 Oct '18 - 18:07 »
Thanks!