When this crackling happens on my computer, I have to restart the audio service. I copy-pasted a batch file together from several sources to do this automatically with elevated privileges. You just make a .txt file with the code in it, save it, and rename the .txt extension to .bat. Here is the code. Please, try to understand the code before using it so that you don't run something that is unsafe. I don't fully understand the code myself.
Here is the code:
@echo off
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
REM --> Batch Script:
net stop audiosrv /y
net start audiosrv