Skip to content

Instantly share code, notes, and snippets.

@jtorvald
Last active March 29, 2022 11:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtorvald/fa2311e7ab933e6a84cce9654caa45c3 to your computer and use it in GitHub Desktop.
Save jtorvald/fa2311e7ab933e6a84cce9654caa45c3 to your computer and use it in GitHub Desktop.
Fix annoying popping crackling sound on the new MacBook Pro 16inch. Save this file and run it or copy and paste the onliner and run it in a terminal.
# if you don't understand how to save this file and execute it (open reset-audio.command)
# then copy and paste this oneliner and enter your password for privileged access:
# sudo kill -9 $(ps axc|awk "{if (\$5==\"coreaudiod\") print \$1}");
# get the process ID of coreaudio
PID=$(ps axc|awk "{if (\$5==\"coreaudiod\") print \$1}")
if [ $PID != "" ]
then
echo "Killing coreaudiod process on $PID"
# Killing the audio daemon ( don't worry: MacOS will bring it back up )
if sudo kill -9 $PID; then
echo "Done. Audio should be fine"
else
echo "That didn't work..."
fi
else
echo "CoreAudio not running?"
fi
@Viamusic1000
Copy link

How do you know this works?

@jtorvald
Copy link
Author

jtorvald commented Jan 7, 2020

@Viamusic1000 because I had some crappy noise coming out of my speakers and tried to kill the coreaudiod to see if it worked since they said it’sa software issue. The result was that it solved the noise instantly. Of course it’s not a permanent fix, but I didn’t have the issue since. When it happens again I just run the command again until Apple comes with a real patch.

@Viamusic1000
Copy link

@Viamusic1000 because I had some crappy noise coming out of my speakers and tried to kill the coreaudiod to see if it worked since they said it’sa software issue. The result was that it solved the noise instantly. Of course it’s not a permanent fix, but I didn’t have the issue since. When it happens again I just run the command again until Apple comes with a real patch.

How do I know this won't break anything? I do work with audio and music notation so this bothers me sometimes.

@jtorvald
Copy link
Author

jtorvald commented Jan 8, 2020

@Viamusic1000 well I don't give guarantees because I don't want to be sued for anything. ;-) But I'm 99.9999% sure that this won't break anything. It looks more dangerous than it is. Ending (a.k.a. Killing) a process on a operating system is quite common. It's like restarting your MacBook, it ends the running processes and reboots your computer. Only now you just end the process while you don't restart. And MacOS finds the coreaudiod process important enough to restart it itself directly when it ends. I ran this command more than 10 times while testing my script and all is good. No worries! If you have your audio crackling and popping just try it and see if it helps you.

@Viamusic1000
Copy link

@Viamusic1000 well I don't give guarantees because I don't want to be sued for anything. ;-) But I'm 99.9999% sure that this won't break anything. It looks more dangerous than it is. Ending (a.k.a. Killing) a process on a operating system is quite common. It's like restarting your MacBook, it ends the running processes and reboots your computer. Only now you just end the process while you don't restart. And MacOS finds the coreaudiod process important enough to restart it itself directly when it ends. I ran this command more than 10 times while testing my script and all is good. No worries! If you have your audio crackling and popping just try it and see if it helps you.
Should I download the script and run it as a text file or what? I copy and pasted in it terminal but Im not sure it did anything in the system and didn't do anything with the speaker for sure.

@jtorvald
Copy link
Author

jtorvald commented Jan 8, 2020

@Viamusic1000 Try this:

  1. Copy this text: sudo kill -9 $(ps axc|awk "{if ($5=="coreaudiod") print $1}");
  2. CMD + Space to open Spotlight search.
  3. Type: Terminal (You will see a black Icon in front of the word: Terminal) press ENTER
  4. Press CMD+V to paste this into the terminal (or right mouse button + paste)
  5. Press Enter
  6. It will ask for your MacBook password to execute this command as admin. Enter the password and press ENTER

You should now hear a pause in audio and your audio volume reset to 50%

@Viamusic1000
Copy link

I got an error that said:
awk: syntax error at source line 1
context is
{if >>> (== <<<
awk: illegal statement at source line 1
awk: illegal statement at source line 1

@jtorvald
Copy link
Author

jtorvald commented Jan 9, 2020

@Viamusic1000 something went wrong here in the comments. The backslashes \ were stripped. Hope this helps:
sudo kill -9 $(ps axc|awk "{if (\$5==\"coreaudiod\") print \$1}");

@Viamusic1000
Copy link

Viamusic1000 commented Jan 9, 2020 via email

@jtorvald
Copy link
Author

jtorvald commented Jan 9, 2020

@Viamusic1000 too bad! Hope that Apple soon comes with a fix because it's an annoying bug to have for such an expensive device.

@Viamusic1000
Copy link

Viamusic1000 commented Jan 9, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment