Ugh, Alsa again … Linux versions after 5.10.94 have this regression that changing the sample rate with snd_pcm_hw_params returns "invalid argument" if you call it a second time, and I could finally no longer delay updating my kernel, so I worked around it by re-opening the device if I need to change the sample format.

That is everything I changed. And somehow, now playback sounds super noisy and as if there is overdrive in the high frequencies?

Unplugging the external sound card and plugging it in again has fixed this issue. I am now even more puzzled.

Rebooting also fixed it, and what’s more, if my program closes the device and re-opens it and sets it to a different sample rate and bit depth, then it’s also fine again. Seems to be totally a software problem. I wonder if it’s the Alsa `plug` system.

When it switches back from 24 bit / 48 kHz to 16 bit / 44.1 kHz, the 16-44 one sounds distorted again! Ugh!

I’m curious what it is that I’m hearing though! You can still hear the track clearly, but it sounds distorted especially in higher and louder parts, like the vocals. It sounds the same as distortion on a guitar amp. It is also still stereo.

Two hypothesis:

- It’s switching the endianness of the 2-byte samples.
- It’s interpreting signed samples as unsigned?

Follow

@ruuda Maybe some zeroes get interspersed inbetween actual samples?

@robryk Or a bug that I introduced that also causes noise, though way more extreme noise so I don’t think this was it: when you put 3 bytes of a 24-bit sample back together into an i32, but you forget to extend the sign bit 😬

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.