Skip to content

Repository files navigation

ActiveWindow Mute Toggle

This project is similar to Discord Global Attenuation, except any sound source can be selected as the priority source.

A Windows system tray application that provides global hotkeys for audio control of the active window's application, with a comprehensive UI for settings and manual control.

Features

1. Mute Toggle (Ctrl+Alt+M)

  • Instantly mute/unmute the currently active window's application
  • No more fumbling through the Windows volume mixer
  • Works with any application that has an audio session

2. Priority Mode (Ctrl+Alt+P)

  • Designate the active window as the "priority application"
  • When the priority app plays audio, all other applications are automatically ducked to 15% volume (configurable)
  • When the priority app stops playing audio, all other apps are restored to their original volume levels
  • Perfect for:
    • Voice calls (Discord, Teams, Zoom) - automatically duck music/games
    • Watching videos while gaming - auto-duck game audio when video plays
    • Streaming - ensure your voice is always heard over other apps

3. Control Panel UI

  • Status & Control Tab:

    • Real-time view of all audio sessions
    • See current volume levels for each app
    • Visual activity meters showing which apps are playing audio
    • Priority mode status indicator
    • Manual priority mode activation buttons for each app
    • Highlight showing which app is the priority app
  • Settings Tab:

    • Adjust ducked volume percentage (1-50%)
    • Configure audio monitoring interval (100-1000ms)
    • Set notification duration (500-3000ms)
    • View active hotkeys
  • Access the UI:

    • Double-click the system tray icon
    • Right-click → "Show Control Panel"

Usage

  1. Run ActiveWindowMuteToggle.exe
  2. The app runs in the system tray
  3. Use the hotkeys:
    • Ctrl+Alt+M: Toggle mute for the active window's app
    • Ctrl+Alt+P: Toggle priority mode for the active window's app
  4. Double-click the tray icon to open the Control Panel

Priority Mode - Manual Control

From the Control Panel's Status & Control tab:

  • Click "Set Priority" next to any app to enable priority mode for that app
  • The priority app is highlighted in yellow
  • Click "Remove Priority" on the priority app to disable priority mode
  • Click "Set Priority" on a different app to switch priority apps
  • Priority mode indicator shows ON/OFF status with a green/gray dot

Project Structure

The project is organized into modular components:

  • ActiveWindowMuteToggle.cs - Main entry point
  • Settings.cs - Configuration with runtime modification support
  • WindowHelper.cs - Win32 API calls for window management
  • AudioSessionHelper.cs - NAudio wrapper for audio session management
  • AudioSessionViewModel.cs - ViewModel for UI data binding
  • MuteFeature.cs - Mute toggle functionality
  • PriorityModeFeature.cs - Priority mode with automatic volume ducking
  • HotkeyForm.cs - Global hotkey registration and handling
  • TrayApplicationContext.cs - System tray icon and application lifecycle
  • MainWindow.xaml/.cs - WPF UI for settings and status

Configuration

You can modify settings from the Settings tab in the UI:

  • Ducked volume level: 1-50% (default: 15%)
  • Audio monitoring interval: 100-1000ms (default: 200ms)
  • Notification duration: 500-3000ms (default: 800ms)

Hotkeys are currently fixed to Ctrl+Alt+M and Ctrl+Alt+P.

Building

# Build the project
dotnet build --configuration Release

# Publish as single-file executable
dotnet publish --configuration Release --runtime win-x64 --self-contained false -p:PublishSingleFile=true

The executable will be in: bin\Release\net8.0-windows\win-x64\publish\ActiveWindowMuteToggle.exe

Requirements

  • .NET 8.0 Runtime (Windows)
  • NAudio 2.2.1 (automatically installed via NuGet)

Usage

  1. Run ActiveWindowMuteToggle.exe
  2. The app runs in the system tray
  3. Use the hotkeys:
    • Ctrl+Alt+M: Toggle mute for the active window's app
    • Ctrl+Alt+P: Toggle priority mode for the active window's app

Right-click the tray icon to view hotkeys or exit the application.

How Priority Mode Works

  1. Press Ctrl+Alt+P while focused on your priority app (e.g., Discord)
  2. The app monitors audio output every 200ms
  3. When priority app plays audio (peak volume > 0.001):
    • All other apps are ducked to 15% volume
    • Original volumes are saved
  4. When priority app stops playing audio:
    • All apps are restored to original volumes
  5. Press Ctrl+Alt+P again to disable priority mode

License

This project is provided as-is for personal use.

About

Collection of utilities for controlling audio volume.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages