Distorted sound

Sound from HDMI comes out of TV and is very distorted. I don’t use the TV sound, rather a Samsung soundbar connected to a Humax settop box. So I really want to use the
RPi AV socket. Tried “sudo amixer cset numid=3 1” which does redirect the sound to the
AUX input of the sound bar, but it is still very distorted. The AUX input works fine from a micro-hfi system. So how do I 1) get rid of the distortion, and 2) make the change survive a reboot.
I’m got RPi 3b model, with Ubuntu Mate 16.04.2

Looks like you have plenty of things to check.
Are you sure about the source feeding the Pi?

I have a theory that, on the Raspberry Pi 3, HDMI audio problems may be related to the GPU/MEMORY split. The higher the resolution and audio quality, perhaps, the higher the split needs to be weighted towards the GPU. I did have problems getting HDMI audio to work with the proper screen resolution before I bumped the GPU memory. It’s just a theory but something to try…

“source feeding the Pi” as far as I can tell, it’s all sources, and
affects both HDMI and AV out. What I get is a lot of white noise
above a faint but discernable audio signal.

Please tell me how to change this split.

VLC will successfully play an mp3 file.
Sound from Firefox and ‘test sound’ is as described.

I’m away from my pi right now but its somewhere in the menus of

sudo raspi-config

I have seen in this forum that there is no “raspi-config” in Ubuntu. It is a Raspbian artifact.

Actually, raspi-config is present in Ubuntu Mate for the Pi

Recent Changes
2017-02-16 - 16.04.2 Release for Raspbery Pi 2 and Raspberry Pi 3

Performance optimised.
Added automated first boot partition resizing.
Optimised partition offset calculations
Optimised filesystem features.
Disabled unnecessary services to reduce CPU cycles and RAM requirements.
Forked and adapted raspi-config to Ubuntu.

Source: https://ubuntu-mate.org/raspberry-pi/

My apologies. I was too lazy to boot the RPI to see.
Yes the command is present. No, it does not work - in so much as the documentation says to use the arrow keys to select an option. The arrow keys do nothing. Keyboard is a MC Saite micro keyboard which has always worked for me, but then I don’t use arrow keys with Terminal. Terminal setting is xterm. I have had the keyboard for 5 years, initially with a RPI 1Bii. “showkey” can’t get a file descriptor to see what codes is being generated.

I’ve used raspi-config both from a terminal on the system monitor, and a SSH login. The arrow keys work (for me)

Ditto on all accounts.

The keyboard is clearly not “generic 105”, I tried “Generic 101” and got some improvement, but not up/down arrows.
SO I edited /boot/config.txt and changed GPU memory from 64 to 128 and rebooted.
No change to sound problem.
VLC will play .mp3
VLC will play .mts and .dv files, but sound only with picture frozen on frame 1.
Firefox will play Utube, pictures - but no sound.
Firefox will play 1 radio station as white noise with music in background.
Firefox will not play two other radio stations at all.

Got to thinking about the arrow keys not working on your keyboard, and remembered encountering a similar circumstance when setting up my Pi.

Special characters where not typing correctly, and thus when I changed the default password from a SSH session, it could not be reproduced with the keyboard connected to the Raspberry Pi, or from the SSH session. I discovered that not only was the keyboard layout wrong, but the language was also. Until I corrected both, special characters did not type correctly. Perhaps something similar is preventing your arrows keys from working.

For me the correct keyboard Layout was Generic 104-Key PC, and the correct language was en_US.UTF-8 UTF-8

Back to the topic: I recently had the same issue, because in ALSA the HDMI volume was set to 100% (+4dB).
Setting it to 86% (-0.01dB) fixed the problem.
Alternatively, you can set volume to exactly 0dB via amixer set HDMI 0