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.

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.

  1. Create a new .NET Core 6 Class Library type solution, and name it whatever you want.
    image
    image
  2. In the solution explorer, expand your new 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. R+Click on your .csproj file and click Properties. In the property pages, change the Target OS to Windows:
    image
  5. 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}'");
        }
    }
}

You can find the full code example here.

API Documentation

Loading Your Addon

Addons must be located within this directory:
C:\Users\<USERNAME>\AppData\Local\radj307\Addons

To check if your addon was loaded, launch VolumeControl and click on the Settings tab. Find the Filter dropdown in the log settings area, and enable DEBUG messages by checking the box.
Assuming you have logging enabled, you will now be able to see messages related to addons in the log file. (by default, this is named volumecontrol.log and is located next to the executable)
image

Note that any users of your redistributed addons must also place this file in the same location, so if you're writing installation instructions be sure to include that.

Publishing Addons

Once you've got your shiny new addon, you may want to distribute it to share your work.
To encourage this, I've created an official repository for third-party addons here.

Note: When uploading your addon to github, be sure to use the GPLv3 license, or a legally compatible alternative.

Clone this wiki locally