Coder Social home page Coder Social logo

pakontrol's Introduction

pakontrol

Pakontrol is a simple python utility/daemon for controlling PulseAudio devices (sink, sink_input, source, source_output) from MIDI control messages. It is intended to be small, have few requirements, and be easy to use. I've tested it on Ubuntu 24 using a nanoKontrol2.

Requirements

All requirements are fairly mature and should be available in most distributions.

  • pulsectl
  • mido
  • rtmidi
  • python-daemon

Using sudo apt install python3-mido python3-pulsectl python3-rtmidi python3-daemon on Ubuntu should work

Usage

usage: pakontrol [-h] [-v] [-f CONFIG_FILE] [-d] [-i]

options:
  -h, --help            show this help message and exit
  -v, --verbose
  -f CONFIG_FILE, --config-file CONFIG_FILE
  -d, --daemon
  -i, --interactive     interactive configuration mode

Configuration

Pakontrol looks for configuration in $PWD/pakontrol.conf and $HOME/.config/pakontrol/pakontrol.conf and is in ConfigParser (.ini) format. See the pakontrol.conf.sample for an example.

You can use interactive mode to create a new configuration using your MIDI device and a PulseAudio mixer like pavucontrol. Just run ./pakontrol -i and follow the prompts.

Default Section

  • midi_device - Name of the midi device to open. Performs a regex match
  • midi_output - Set to True if you want feedback sent back to your device
  • log_path - Path to log file, or stdout if not specified
  • log_level - Logging level, one of DEBUG, INFO, WARNING, ERROR
  • pid_file - Path to pid file when using --daemon mode
  • multiplier - Float multiplied by to map to volumes above 100%. Defaults to 1.0.

Rules

Other sections define rules to match a MIDI message to an audio device. MIDI messages can be repeated to map to more than one PulseAudio device (eg: all music apps). Audio devices can be repeated too (eg: mapping to mute button and volume slider). See pakcontrol.conf.sample for examples.

  • midi_event - Type of midi event, usually control_change
  • midi_channel - Channel number
  • midi_control - Control number
  • pa_type - PulseAudio device type, one of sink, sink_input, source, source_input
  • pa_match_name - Name of device to regex match on (optional)
  • pa_match_prop_named - Name of property to match on (optional)
  • pa_match_prop_value - Value of property to regex match on (optional)
  • pa_change - Property to change/watch, one of volume, mute
  • multiplier - Float multiplied by to map to volumes above 100%. Defaults to 1.0.

Rules must specify pa_match_name and/or pa_match_prop_named/pa_match_prop_value. Some devices have names that change or are ambiguous, so the property match allows more flexibility. For exmaple Rhythmbox changes its' name depending on what's playing, so you can match on the property application.name.

pakontrol's People

Contributors

potatono avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.