Skip to content

Tired of iRacing and SimHub losing your audio settings every time Windows renumbers your devices?

License

Notifications You must be signed in to change notification settings

xilonoide/SimAudioFixer

Repository files navigation

SimAudioFixer

SimAudioFixer Logo

The definitive solution for audio device renumbering issues in iRacing and SimHub

.NET 8 WPF C# Tests

Donar


Problem It Solves

Tired of iRacing and SimHub losing your audio settings every time Windows renumbers your devices? SimAudioFixer creates a stable "fingerprint" for each device and automatically updates configurations when GUIDs change.

Features

  • Smart Detection: Identifies devices by hardware ID (VID/PID), not by temporary GUID
  • Automatic Updates: Patches app.ini (iRacing) and ShakeITBassShakersSettingsV2.json (SimHub)
  • Active Monitoring: FileSystemWatcher detects when iRacing/SimHub modify files
  • Notifications: Alerts you and asks if you want to reapply your configuration
  • Dark Mode: Fully dark interface so you don't get blinded at 3 AM
  • Auto Start: Option to run silently at Windows startup (no UAC prompts!)
  • Automatic Backup: Saves a backup before modifying files

Installation

Using the Installer (Recommended)

  1. Download SimAudioFixer-Setup.msi from Releases
  2. Run the installer (requires administrator privileges)
  3. Launch SimAudioFixer from the Start Menu or Desktop shortcut
  4. Optionally enable "Run at Windows startup" from the tray icon menu

From Source

  1. Clone and build:

    git clone https://github.com/xilonoide/SimAudioFixer.git
    cd SimAudioFixer
    dotnet build SimAudioFixer.Installer -c Release
  2. The MSI installer will be at:

    SimAudioFixer.Installer\bin\Release\SimAudioFixer-Setup.msi
    

Administrator Privileges

SimAudioFixer requires administrator privileges because:

  • SimHub is typically installed in C:\Program Files (x86)\ which requires admin access to modify
  • The app will show a UAC prompt when launched manually
  • Auto-start runs without UAC prompts using Windows Task Scheduler with pre-authorized elevated privileges

Usage

First Time Setup

  1. Open SimAudioFixer from the desktop icon or system tray (accept UAC prompt)
  2. Go to the Soundcards tab to see your detected devices
  3. In the iRacing tab:
    • Select the folder where app.ini is located (if not in the default path)
    • Assign each device to its role (Main, Spotter, LFE, etc.)
    • Press "Save Configuration"
  4. In the SimHub tab:
    • Select the folder where ShakeITBassShakersSettingsV2.json is located
    • Assign the device for Bass Shaker
    • Press "Save Configuration"
  5. Press "Apply Changes" to patch the files

Daily Use

SimAudioFixer runs in the system tray. Right-click the icon to:

  • Apply Changes: Force manual update
  • Configure Devices: Open the main window
  • Run at Windows startup: Enable/disable auto start
  • Exit: Close the application

Silent Mode

To run without interface (ideal for scripts or startup):

SimAudioFixer.exe init

This applies all configured patches immediately and exits.

Architecture

How Device Fingerprinting Works

The core innovation of SimAudioFixer is the stable device fingerprint. Instead of relying on Windows GUIDs (which change unpredictably), we create a composite identifier:

Fingerprint = SHA256(HardwareId + "_" + DataFlow)

Components:

  1. HardwareId: USB vendor and product identifier (e.g., VID_1234&PID_5678)
  2. DataFlow: Whether the device is for rendering (output) or capture (input)

This fingerprint remains stable across:

  • Windows reboots
  • Driver updates
  • Windows updates that renumber devices

Project Layers

┌─────────────────────────────────────────────────────────────┐
│                    SimAudioFixer.WPF                        │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐  │
│  │ ViewModels  │  │   Views     │  │     Services        │  │
│  │ - Main      │  │ - MainWindow│  │ - TrayIconService   │  │
│  │ - Soundcards│  │ - Tabs      │  │ - StartupManager    │  │
│  │ - iRacing   │  │ - DarkTheme │  │   (Task Scheduler)  │  │
│  │ - SimHub    │  │             │  │ - DarkMessageBox    │  │
│  └─────────────┘  └─────────────┘  └─────────────────────┘  │
└─────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────┐
│                    SimAudioFixer.Core                       │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐  │
│  │   Models    │  │  Services   │  │       Utils         │  │
│  │ - AudioDev  │  │ - Scanner   │  │ - IniFileParser     │  │
│  │ - Fingerpr  │  │ - Mapper    │  │ - BackupManager     │  │
│  │ - Mapping   │  │ - Patchers  │  │                     │  │
│  │ - Config    │  │ - Watcher   │  │                     │  │
│  └─────────────┘  └─────────────┘  └─────────────────────┘  │
└─────────────────────────────────────────────────────────────┘

Data Flow

  1. Scan: NAudioDeviceScanner queries Windows Audio API (WASAPI)
  2. Fingerprint: AudioDeviceFingerprint creates stable identifiers
  3. Map: AudioDeviceMapper associates fingerprints with roles (Main, Spotter, etc.)
  4. Patch: IracingConfigPatcher / SimHubConfigPatcher update config files
  5. Watch: FileWatcherService monitors for external changes
  6. Notify: TrayIconService shows balloon notifications to alert user

For Developers

Requirements

  • .NET 8 SDK
  • Visual Studio 2022 or Rider

Build from Source

git clone https://github.com/xilonoide/SimAudioFixer.git
cd SimAudioFixer
dotnet restore
dotnet build

Run Tests

dotnet test

114 tests covering all core functionality:

Unit Tests (9 test files)

  • Models: AudioDevice, AudioDeviceFingerprint, DeviceMapping, AppConfiguration
  • Services: AudioDeviceMapper, IracingConfigPatcher, SimHubConfigPatcher
  • Utils: IniFileParser, BackupManager

Integration Tests (2 test files)

  • EndToEndPatchingTests: Full workflow testing for iRacing and SimHub patching
  • FileWatcherIntegrationTests: File monitoring, debouncing, pause/resume functionality

All tests use:

  • xUnit as the test framework
  • FluentAssertions for readable assertions
  • Moq for mocking dependencies
  • coverlet.collector for code coverage

Project Structure

SimAudioFixer/
├── SimAudioFixer.Core/           # Business logic (no UI dependencies)
│   ├── Models/
│   │   ├── AudioDevice.cs        # Represents an audio device
│   │   ├── AudioDeviceFingerprint.cs  # Stable device identifier
│   │   ├── DeviceMapping.cs      # Role-to-device association
│   │   └── AppConfiguration.cs   # App settings persistence
│   ├── Services/
│   │   ├── IAudioDeviceScanner.cs    # Interface for device scanning
│   │   ├── NAudioDeviceScanner.cs    # NAudio implementation
│   │   ├── AudioDeviceMapper.cs      # Manages device-role mappings
│   │   ├── IConfigPatcher.cs         # Interface for config patchers
│   │   ├── IracingConfigPatcher.cs   # Patches iRacing app.ini
│   │   ├── SimHubConfigPatcher.cs    # Patches SimHub JSON
│   │   └── FileWatcherService.cs     # Monitors config file changes
│   └── Utils/
│       ├── IniFileParser.cs      # INI file read/write
│       └── BackupManager.cs      # Backup creation/restoration
│
├── SimAudioFixer.WPF/            # WPF UI application
│   ├── ViewModels/               # MVVM ViewModels
│   ├── Views/                    # XAML views
│   ├── Services/
│   │   ├── TrayIconService.cs        # System tray icon and notifications
│   │   ├── StartupManager.cs         # Task Scheduler integration
│   │   └── DarkMessageBox.cs         # Themed message boxes
│   ├── Themes/
│   │   └── DarkTheme.xaml        # Dark mode styles
│   └── app.manifest              # UAC elevation manifest
│
├── SimAudioFixer.Tests/          # xUnit test project
│   ├── UnitTests/                # Unit tests for Core
│   └── IntegrationTests/         # End-to-end tests
│
└── SimAudioFixer.Installer/      # WiX installer project
    ├── SimAudioFixer.Installer.wixproj  # WiX project file
    ├── Package.wxs               # Installer definition
    ├── Assets/
    │   └── icon.ico              # Application icon
    └── README.md                 # Installer build instructions

Building the Installer

To create the MSI installer:

dotnet build SimAudioFixer.Installer -c Release

Output: SimAudioFixer.Installer\bin\Release\SimAudioFixer-Setup.msi (~51 MB)

This automatically builds and publishes the WPF application first.

The application is self-contained - it includes the entire .NET 8 runtime, so users don't need to install anything else.

See SimAudioFixer.Installer/README.md for more details on the installer project.

Key Design Decisions

  1. Self-Contained Deployment: The application includes the entire .NET 8 runtime (~156 MB), eliminating dependency issues and simplifying installation.

  2. Task Scheduler for Auto-Start: Instead of the Startup folder, we use Windows Task Scheduler with "Run with highest privileges" to avoid UAC prompts on every Windows boot.

  3. Static FileWatcherService.Current: Allows ViewModels to pause file watching during their own writes, preventing infinite loops.

  4. Fingerprint-based Mapping: Device roles are stored with fingerprints, not GUIDs, ensuring mappings survive device renumbering.

  5. Backup Before Patch: Every config modification is preceded by a backup, allowing recovery if something goes wrong.

  6. Embedded Resources: The application icon is embedded as a manifest resource, ensuring it works correctly in single-file deployments.

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a branch for your feature (git checkout -b feature/AmazingFeature)
  3. Write tests for new functionality
  4. Ensure all tests pass (dotnet test)
  5. Commit your changes (git commit -m 'Add some AmazingFeature')
  6. Push to the branch (git push origin feature/AmazingFeature)
  7. Open a Pull Request

Code Style

  • Use meaningful variable and method names
  • Add XML documentation comments to public methods
  • Follow MVVM pattern for WPF code
  • Keep Core layer free of UI dependencies

Files It Modifies

iRacing

  • File: %USERPROFILE%\Documents\iRacing\app.ini
  • Section: [Audio]
  • Keys: devSpeakerId, devSPCCId, devLFEId, devMicrophoneId, devVoiceChatId (and their corresponding Name values)

SimHub

  • File: C:\Program Files (x86)\SimHub\PluginsData\Common\ShakeITBassShakersSettingsV2.json
  • JSON Path: OutputManager.ChannelsSettingsV3[0]
  • Fields: Name, OutputId, InstanceId, HardwareID1/2/3

Troubleshooting

Not detecting my devices

  • Make sure devices are connected and recognized by Windows
  • Only WASAPI-compatible devices are detected
  • Try refreshing devices with the "Refresh Devices" button

Cannot write to SimHub config

  • SimHub must be closed before applying changes
  • If you get "Access Denied", make sure you accepted the UAC prompt
  • The app needs administrator privileges to write to Program Files

Cannot write to iRacing config

  • iRacing must be closed before applying changes
  • Check that the app.ini file is not read-only

Notifications don't appear

  • Check that Windows notifications are enabled for SimAudioFixer
  • Verify "Focus Assist" is not blocking notifications

Auto-start not working

  • Open Task Scheduler and verify "SimAudioFixer" task exists
  • Check that the task is set to "Run with highest privileges"
  • Try disabling and re-enabling "Run at Windows startup"

UAC prompt appears on every startup

  • This should NOT happen if auto-start is configured correctly
  • The Task Scheduler method should bypass UAC
  • If it still happens, recreate the startup configuration

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

This project is built with these amazing libraries:

Special thanks to:

  • The iRacing and SimHub communities for inspiration and feedback
  • All contributors and testers

Like this project? Give it a star on GitHub!


Donar

Made with ❤️ for the simracers community

About

Tired of iRacing and SimHub losing your audio settings every time Windows renumbers your devices?

Topics

Resources

License

Stars

Watchers

Forks

Languages