Ubuntu 12.10 crackling and popping sound [duplicate]

A possible solution is disabling "auto-mute" in alsamixer. It is used when the "switch-to-headphone-and-back-again" bug occurs (in high volumes mainly).

First, open your terminal, or press:

CTRL + ALT + T

Then, type and hit "enter":

$ alsamixer

This screen will show up:

Alsa mixer screen in terminal

Use the right arrow until you select "Auto-Mute"

Then, press the down arrow to set it do "Disable" (see the text above it).

That's it.