Skip to content
radj307 edited this page May 22, 2022 · 18 revisions

Volume Control Wiki

Welcome to the Volume Control wiki! This is mainly intended for users who want to build their own addons, but it may be helpful to others as well.

Simple, expandable hotkey application for Windows that adds customizable hotkeys mainly focused around controlling the volume of specific applications instead of the system volume.

Terminology

A brief list of terminology used throughout the program:

Term Description
Device Audio devices, also known as Audio Endpoints. image
Session This is the audio session associated with a running process. These are visible in the audio mixer. image

Addon Development

Addons are written in C# with .NET Core 6 - you don't need any previous experience with C# in order to create addons, but this is not a tutorial for learning C#.
You are legally allowed to create and redistribute addons so long as you comply with the terms of the GPLv3 license - You must make the full source code available along with any redistributed binaries (.dlls in this case) without any terms or conditions.

Pre-Requisites

You'll need a copy of the Volume Control SDK, which is distributed through github actions.

  1. On the Actions tab and find the most recent successful run of the 'Generate Release' action. image
    Click on the title: image
  2. At the bottom of the page, click on the 'sdk' artifact to download it.
    image
  3. Extract the archive to a location of your choice; keep the filepath handy for later.
    You should now have these files (this may or may not be accurate in future versions) located somewhere:
    image

Environment Setup

This assumes you're using Visual Studio with the .NET/C# workload installed.

When you see italicized text in this section, it means that the text can be swapped out for your own objects, names, or text.

  1. Create a new .NET Core 6 Class Library type solution named VolumeControl.TestAddon.
    image
    image
  2. In the solution explorer, expand the VolumeControl.TestAddon project and R+Click on the Dependencies entry, then select any of the Add ... Reference options.
    image
  3. Click on the Browse tab & add the DLLs from the sdk you downloaded earlier using the Browse button at the bottom.
    image
    Once you're done, click OK.
  4. You are now able to create custom addons for Volume Control.

Here's an example of an addon that adds a hotkey action named 'Custom Action' that writes a message to the log when triggered.

using System.ComponentModel;
using VolumeControl.API;
using VolumeControl.Hotkeys.Attributes;
using VolumeControl.Log;

namespace VolumeControl.TestAddon
{
    [ActionAddon(nameof(TestActionAddon))] //< This is required for all addon classes that should be loaded.
    public class TestActionAddon
    {
        // Here, we make a lambda that allows us to use `API` instead of `VCAPI.Default` every time we call it.
        //  `VCAPI` is a static global API exposed to all addons through the static VCAPI.Default property.
        private static VCAPI API => VCAPI.Default;

        // This is the global logging object, which can be accessed through the static VCAPI.Log property.
        //  Here, we do the same as above so we can write log messages with shorter syntax.
        private static LogWriter Log => VCAPI.Log;


        // Now let's create a hotkey action named 'CustomAction', using the action event handler signature.
        // All hotkey actions must return void, and accept 2 parameters of types object? & HandledEventArgs.
        [HotkeyAction] //< this is required for all hotkey action methods
        public void CustomAction(object? sender, HandledEventArgs e)
        {
            Log.Debug($"Successfully triggered addon method {nameof(CustomAction)}!",
                      $"Currently selected session name: '{API.AudioAPI.SelectedSession?.ProcessName}'");
        }
    }
}
Clone this wiki locally