'Raspberry Pi 3 A+ distorted/screeching audio when using ALSA + Jackd2 through on-board headphone jack

I am trying to set up Supercollider on my Raspberry Pi 3 A+ on Raspbian Lite using this guide. Jackd2 and Supercollider both compile fine, and there are no errors when I try to run Supercollider or the jack_simple_client test. However, regardless of different sample rates, buffer sizes, number of periods etc. used in booting the jack server the audio always comes out heavily distorted, with loud high pitched squealing and low popping noises.

Using the speaker-test command from ALSA creates a clean, non distorted test tone. Previously trying pyo as a DSP module would also suffer from the same issue if I used Jack, but would work fine otherwise. This leads me to believe that there is some issue in the communication between jack and ALSA. Power supply is likely not the problem as well. My installed jack version is 1.9.17 and ALSA is k5.4.83-v7+. I am new to working with Linux audio/Jack, so any help is much appreciated!



Solution 1:[1]

I've been working with Alsa around 4 years ago, but remember I had the problem.

First I thought that my device was the reason, and it turned out to be that the noise was coming from wrong channel, and I had to force set alsa channels manually with cli commands and later in config files.

Try to check that alsa does not assign wrong channel when Jack is up.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kai Light