PhilippeBekaert / snd-hdspe

New linux driver and tools for RME HDSPe sound cards and extension modules
GNU General Public License v3.0
51 stars 18 forks source link

Distorted audio from some apps (happens with stock driver too) #6

Closed lucianoiam closed 2 years ago

lucianoiam commented 2 years ago

Hi and thanks for sharing this project.

Any idea where does this kind of distortion come from?

This clip was recorded from Bitwig 3.3 on Linux 5.13 / RME HDSPe AIO . The issue is reproducible with the stock snd_hdspm driver. It goes away when using JACK... On the other hand Ardour plays fine with the card with or without JACK.

All DAWs were running fine on the same hardware about two years ago, raw ALSA (no-JACK) output just broke for some programs at an undefined point in the past (using JACK almost exclusively so not sure when). REAPER is another example, some time ago it played well with ALSA/AIO and now it just cannot open the device anymore, getting this instead. That is why I think it is not a Bitwig only problem but a generalized one.

I am not an ALSA developer so any tips on how to debug this are very welcomed. I cannot believe Bitwig just forgot about this card, there has to be something somewhere. FYI the box is fine tuned for low latency audio, RT kernel, non-shared IRQs, etc.

hdsp-distortion.m4a.zip

PhilippeBekaert commented 2 years ago

Hi Luciano,

I'm unsure about what the cause can be. Since it works with jack, I'd be tempted to exclude a driver issue here. May I suggest to enable driver debug logging as follows:

 echo 8 > /proc/sys/kernel/printk

Send me a copy of the snd-hdspe driver related messages on your system log, as you try to configure/start reaper or other DAW software. You can watch your system log message as they are generated with the following command in a separate console window:

 journalctl -f

Both commands require root privileges, so use sudo.

Thanks for reporting anyways,

Philippe.

lucianoiam commented 2 years ago

Likely it is not a driver issue because the problem manifests exactly the same for two different drivers, and also not a hardware issue because JACK and Ardour work flawlessly. Wondering something changed in ALSA in the last 1-2 years and these programs are not handling it, in an unfortunate combination of factors. I will try with an older distro to add more evidence.

Logs don´t seem to reveal anything of interest:

Bitwig:

Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_set_sample_rate(48000)
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_system_sample_rate(48000) ...
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_internal_freq(3)
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_dds() dds = 2184533333 sample_rate = 48000 rc = 0.
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_set_channel_map()
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_mixer_update_channel_map:
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: Allocated sample buffer for capture at 0000000035cffb37
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_set_sample_rate(48000)
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_system_sample_rate(48000) ...
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_internal_freq(3)
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_dds() dds = 2184533333 sample_rate = 48000 rc = 0.
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_set_channel_map()
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_mixer_update_channel_map:
Mar 18 20:08:28 mulo kernel: snd_hdspe 0000:01:00.0: Allocated sample buffer for playback at 000000001cb6b5cd

Ardour (works fine):

Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_set_sample_rate(48000)
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_system_sample_rate(48000) ...
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_internal_freq(3)
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_dds() dds = 2184533333 sample_rate = 48000 rc = 1.
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_set_channel_map()
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_mixer_update_channel_map:
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: Allocated sample buffer for capture at 0000000035cffb37
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_set_sample_rate(48000)
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_system_sample_rate(48000) ...
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_internal_freq(3)
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_write_dds() dds = 2184533333 sample_rate = 48000 rc = 0.
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_set_channel_map()
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: hdspe_mixer_update_channel_map:
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: Allocated sample buffer for playback at 000000001cb6b5cd
Mar 18 21:01:12 mulo kernel: snd_hdspe 0000:01:00.0: snd_hdspe_midi_output_trigger: MIDI port 0 output DOWN.

REAPER: does not produce any logs

lucianoiam commented 2 years ago

Mystery solved:

Downgrading AIO firmware from v14 to v12: broken Bitwig 4 on Ubuntu Studio 21: broken Bitwig 4 on Ubuntu Studio 18: broken Bitwig 4 on Manjaro 21: broken Bitwig 3 on Ubuntu Studio 18: broken Bitwig 2 on Ubuntu Studio 18: works

Bitwig 2 is from 2019 which approximately matches the time when I often switched between ALSA and JACK and both worked as I remember. Reaper might be having its own issues; in an unfortunate coincidence both fail in 2022 and made me start debugging at the wrong place.

It nows makes more sense since JACK and Ardour work flawlessly.

Thanks for the testing tips I'll close this issue now and get in contact with the appropriate support teams.

PhilippeBekaert commented 2 years ago

Thanks for letting me know, Luciano. Good luck! Philippe.