Arduino project for controlling audio volume for separate Windows processes using physical sliders (like a DJ!)
Video demonstration (click here)
- The sliders are connected to 5 analog pins on an Arduino Uno board. They're powered from the board's 5V output (see schematic)
- The board connects via a USB cable to the PC
- The code running on the Arduino board is a C program constantly writing current slider values over its Serial interface
deej-arduino.ino
- The PC runs a Python script
deej.py
that listens to the board's Serial connection, detects changes in slider values and sets volume of equivalent audio sessions accordingly. - A VBScript-based run helper
run.vbs
allows this Python script to run in the background (from the Windows tray).
deej
uses an external YAML-formatted configuration file named config.yaml
.
The config file determines which applications are mapped to which sliders, and which COM port/baud rate to use for the connection to the Arduino board.
This file auto-reloads when its contents are changed, so you can change application mappings on-the-fly without restarting deej
.
It looks like this:
slider_mapping:
0: master
1: chrome.exe
2: spotify.exe
3:
- 'pathofexile_x64.exe'
- 'rocketleague.exe'
4: discord.exe
# recommend to leave this setting at its default value
process_refresh_frequency: 5
# settings for connecting to the arduino board
com_port: COM4
baud_rate: 9600
- Process names aren't case-sensitive
- You can use a list of process names to either:
- define a group that is controlled simultaneously
- choose whichever process in the group is currently running (in this example, one slider is for different games that may be running)
master
is a special option for controlling master volume of the system.- The
process_refresh_frequency
option limits how oftendeej
may look for new processes if their appropriate slider moves. This allows you to leavedeej
running in background and open/close processes normally - the sliders will #justwork
If you've actually gone ahead and built yourself this kind of box, here's how you can run deej
:
- Python 2.7.x (Sorry!) and
pip
virtualenv
- Download the repository by either cloning it or downloading its archive.
- In the repo's directory, run:
virtualenv venv
venv\Scripts\activate.bat
pip install -r requirements.txt
- Make a shortcut to
run.vbs
by right-clicking it -> "Create Shortcut" - (Optional, but mandatory) Change the shortcut's icon to
assets/logo.ico
- (Optional, but optional) Copy the shortcut to
%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
to havedeej
run on boot
- Better logging and error handling
- Automatic COM port detection