This might be a kernel issue and not just a problem with Ubuntu since I've had this exact same issue on an HP Envy 13 i5 Kaby Lake running ALC295 on pretty much every distro. Back when I'd dual boot, I used to boot into Windows before booting back into Linux to fix this problem and it worked on every distro. Now I have a machine with only Linux on it can't seem to make this issue go away. Here's a list of the audio devices used.
Audio device: Intel Corporation Device 9d71 (rev 21) (prog-if 80) Subsystem: Hewlett-Packard Company Device 82b9 Flags: bus master, fast devsel, latency 32, IRQ 132 Memory at a1328000 (64-bit, non-prefetchable) [size=16K] Memory at a1310000 (64-bit, non-prefetchable) [size=64K] Capabilities: <access denied> Kernel driver in use: snd_hda_intel Kernel modules: snd_hda_intel, snd_soc_skl **** List of PLAYBACK Hardware Devices **** card 0: PCH [HDA Intel PCH], device 0: ALC295 Analog [ALC295 Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2] Subdevices: 1/1 Subdevice #0: subdevice #0 -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1648183 Title: Crackling and popping sound when using headphones To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/1648183/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs