MixerTUI 1.5
Tags: audio, mixer, freebsd, unix
Published: 2024-02-24 13:41:36

[MixerTUI](https://gitlab.com/alfix/mixertui) is an audio mixer with a terminal user interface (TUI) for the [FreeBSD](https://www.freebsd.org) sound system. It allow to switch easily between laptop and HDMI, headphones and speakers,and so on. Features include: show the current driver configuration, select an audio device to get information, change the volume, or make the device the default. The version 1.5 is out!

![Window in a terminal with bars to select volume](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uniwp8ycppzq657q8pct.png)

--------------------------------------------------------------

To install the port [audio/mixertui](https://www.freshports.org/audio/mixertui):
```
# cd /usr/ports/audio/mixertui/ && make install clean
```

To add the package:
```
# pkg install mixertui
```

To build from sources:

Step 1. Install deps
```
# pkg install bsddialog libsysctlmibinfo2
```
Step 2. Download, build, and run
```
% git clone https://gitlab.com/alfix/mixertui.git
% cd mixertui
% make
% ./mixertui
```

--------------------------------------------------------------

## Version 1.5 Changes and Improvements

**1)** Pop-ups are implemented using [libbsddialog](https://gitlab.com/alfix/bsddialog), for example the screenshot shows a bsddialog menu. Curiosity, the first version of bsddialog was just a copy of the mixertui pop-ups to implement dialogs, now mixertui uses libbsddialog to show pop-ups.


**2)** Improvements for the menu to select the device/pcm.
The item with the default pcm (_sysctl hw.snd.default_unit_) has the "(Default)" prefix; pcm4 in the screenshot. Opening the menu the selected item is the current pcm; pcm2 in the screenshot.

![Window in a terminal with bars to select volume](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q7xd35e6x4k61nv3eevk.png)

**3)** Fix fault with terminals without colors. Example
```
% env TERM=vt220 mixertui
```

![Window in a terminal with bars to select volume](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d2wwxlxcc9c286ncvqat.png)

**4)** Few internal refactoring. Probably this is the last C/ncurses version, (see Future subsection below).

--------------------------------------------------------------

## Future

MixerTUI started out as a personal project (...game :D). I spent 30 minutes to set up my microphone to record my [BSDCan presentation](https://papers.freebsd.org/author/alfonso-s.-siciliano/) during the first lockdown. I set audio quickly via alsamixer in the past. Now my main laptop runs FreeBSD, so I wrote mixertui to avoid to waste time setting up a microphone, headphones, [accessibility](2023-01-21-freebsd-disable-stereo-sound.html), and so on.

The first version was just 1000 lines of code; mainly ncurses stuff because the sound system interface is actually easy: just some _ioctl_ and _sysctl_. However several users started to use it. I received a lot of tips, feedback, merge request, iussues, email, and so on.

The utility grew messy to implement the user requests. Mainly I spent time to use libncurses, because it does not provides widgets (buttons, title, bars, ...), it is just a "render" library. I would have preferred to spend time implementing new audio features instead of "drawing" a bar. ncurses is not suitable. I am considering other TUI libraries to rewrite MixerTUI in the next version 2.0. Under the radar: brick/haskell, tui-rs/rust, FTXUI/C++.

Conclusion, this is just a TUI improvements version. I' ll rewite mixertui. TODO, Ideas and new audio features in the future: mouse, virtual\_oss, devd, sound(4) improvements, accessibility, and so on.

--------------------------------------------------------------