-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea | ||
build | ||
dist | ||
voicemeeter-auto-affinity.spec | ||
__* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,22 @@ | ||
# voicemeeter-auto-affinity | ||
Automatically sets the affinity of "audiodg.exe" to only one core on computer start to fix the crackling noises that can occur in VoiceMeeter. | ||
Automatically sets the affinity of "audiodg.exe" to only one core on computer start to fix the crackling noises that can | ||
occur in VoiceMeeter. | ||
|
||
## The Problem | ||
Some users of the program VoiceMeeter have a problem with a sound channel having crackling noises. This can be fixed by | ||
setting the affinity of the windows process "audiodg.exe" to only one core. This, however can not be done persistently | ||
in Windows itself, so a common solution is to use [Process Lasso](https://bitsum.com/). My problem with this solution was | ||
that the free version of this program asks to buy the paid version on every boot and constantly runs in the background although | ||
the only feature I use does not require that. This is why I decided to write a simple batch script that is run once on | ||
system boot and changes the affinity of audiodg to only one core. | ||
|
||
## How to Use | ||
To install the batch script, do one of the following: | ||
|
||
### Using the Installation Tool | ||
To conveniently install the batch script, download the InstallationTool.exe from the | ||
[releases page](https://github.com/Gobidev/voicemeeter-auto-affinity/releases) and click the Install button. | ||
|
||
### Manual Installation | ||
Download the batch file directly and place it into the startup folder that you can access by pressing WIN + R and typing | ||
"shell:startup". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
pyinstaller --noconfirm --windowed --onefile --add-data "set-audiodg-affinity.bat;." "install.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import tkinter as tk | ||
import tkinter.ttk as ttk | ||
import tkinter.messagebox | ||
import subprocess | ||
import os | ||
import sys | ||
import shutil | ||
|
||
|
||
AUTOSTART_DIR = os.path.join(os.getenv("APPDATA"), "Microsoft\\Windows\\Start Menu\\Programs\\Startup") | ||
BATCH_FILE_NAME = "set-audiodg-affinity.bat" | ||
INSTALLED_SCRIPT_PATH = os.path.join(AUTOSTART_DIR, BATCH_FILE_NAME) | ||
|
||
if hasattr(sys, "_MEIPASS"): | ||
# noinspection PyProtectedMember | ||
ORIGIN_BATCH_FILE_LOCATION = os.path.join(sys._MEIPASS, BATCH_FILE_NAME) | ||
else: | ||
ORIGIN_BATCH_FILE_LOCATION = os.path.join(os.getcwd(), BATCH_FILE_NAME) | ||
|
||
|
||
def install_batch_file(): | ||
try: | ||
if not os.path.isfile(INSTALLED_SCRIPT_PATH): | ||
shutil.copy(ORIGIN_BATCH_FILE_LOCATION, AUTOSTART_DIR) | ||
subprocess.call([INSTALLED_SCRIPT_PATH]) | ||
tk.messagebox.showinfo("Success", "The batch script was successfully installed") | ||
else: | ||
tk.messagebox.showerror("Error Occurred", "The batch script was already installed") | ||
except Exception as e: | ||
tk.messagebox.showerror("Error Occurred", e) | ||
|
||
|
||
def uninstall_batch_file(): | ||
try: | ||
if os.path.isfile(INSTALLED_SCRIPT_PATH): | ||
os.remove(INSTALLED_SCRIPT_PATH) | ||
tk.messagebox.showinfo("Success", "The batch script was successfully uninstalled") | ||
else: | ||
tk.messagebox.showerror("Error Occurred", "No installed script was found") | ||
except Exception as e: | ||
tk.messagebox.showerror("Error Occurred", e) | ||
|
||
|
||
class Application(ttk.Frame): | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
self.info_text = "This is a simple tool that automatically installs the\nrequired batch file to the users " \ | ||
"autostart folder." | ||
|
||
# Row 0 | ||
info_lbl = ttk.Label(self, text=self.info_text) | ||
info_lbl.grid(row=0, column=0, padx=3, pady=3) | ||
|
||
# Row 1 | ||
install_button = ttk.Button(self, text="Install", command=install_batch_file) | ||
install_button.grid(row=1, column=0, padx=10, pady=10, ipadx=13) | ||
|
||
# Row 2 | ||
uninstall_button = ttk.Button(self, text="Uninstall", command=uninstall_batch_file) | ||
uninstall_button.grid(row=2, column=0, padx=3, pady=3, ipadx=13) | ||
|
||
|
||
if __name__ == '__main__': | ||
root = tk.Tk() | ||
root.title("voicemeeter-auto-affinity Installation Tool") | ||
root.resizable(False, False) | ||
application = Application(root) | ||
application.pack(fill="both", padx=5, pady=5) | ||
|
||
root.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@echo off | ||
|
||
:: Get administrator priviliges | ||
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | ||
|
||
if '%errorlevel%' NEQ '0' ( | ||
goto UACPrompt | ||
) else ( goto gotAdmin ) | ||
|
||
:UACPrompt | ||
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" | ||
set params = %*:"=" | ||
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" | ||
|
||
"%temp%\getadmin.vbs" | ||
del "%temp%\getadmin.vbs" | ||
exit /B | ||
|
||
:gotAdmin | ||
pushd "%CD%" | ||
CD /D "%~dp0" | ||
|
||
|
||
:: Set affinity | ||
PowerShell.exe "$Process = Get-Process audiodg; $Process.ProcessorAffinity=1" | ||
|
||
:: Affinity table | ||
::Core # = Value = BitMask | ||
::Core 1 = 1 = 00000001 | ||
::Core 2 = 2 = 00000010 | ||
::Core 3 = 4 = 00000100 | ||
::Core 4 = 8 = 00001000 | ||
::Core 5 = 16 = 00010000 | ||
::Core 6 = 32 = 00100000 | ||
::Core 7 = 64 = 01000000 | ||
::Core 8 = 128 = 10000000 | ||
::... |