Scarlet Devil Mansion

22 October 2024

Benben v0.6.0 Soft Feature Freeze

Good news, Benben v0.6.0 is getting closer! There has been a LOT added this development cycle, and given that there’s very little left to be done, I’ve decided it’s time for a soft feature freeze. This means that no new planned features will be added to the milestone, and focus will instead be placed on tightening things up for release.

And I’ll say it right now: the tentative release date for v0.6.0 will be December 5th, 2024. This should provide enough time for testing.

So what’s going to be new in Benben v0.6.0? Well, get ready for a long post…

Support For New Formats

Benben v0.6.0 adds support for playing three new audio formats: WavPack, Commodore 64 SID, and a format called the Quite OK Audio format (QOA).

WavPack is similar to FLAC in that it’s a lossless format suitable for archival purposes. What makes it different is that it supports both PCM and Direct Stream Digital (DSD) formats, as well as providing an optional lossy encoding mode and a “hybrid” mode. Benben supports all of these, including hybrid files, and will report to you what it has detected.

Speaking of FLACs, FLAC files encapsulated in Ogg containers are now supported.

SID files contain music written for the good ol' Commodore 64 computer. They’re similar to VGM in that they capture the instructions sent to the MOS6581 SID chip instead of the actual sound data. Benben emulates this chip and plays these files using the libsidplayfp library, and will also support 2SID and 3SID files. Since SID files support having more than one song within a single SID file, Benben also supports selecting individual tracks, or a range of tracks, from each SID.

If you need some Commodore 64 music (maybe from some old games you used to play?), check out the High Voltage SID Collection. Benben also supports the Songlengths database that they publish, and various other playback options.

Finally, QOA is a relatively new format that (in my view) aims for very good quality, decent-ish file size, and extremely fast decoding. It seems to be mainly geared towards use in game engines, and I’ve kind of fallen in love with the format. I’ve decided to include it in Benben to hopefully raise some awareness of it, and also because eventually someone will rip some QOA files from a game and want to listen to them :-P Also it was just plain fun implementing an encoder and decoder for QOA in pure Crystal ^_^

New VGM Chips Supported

The underlying VGM library, YunoSynth, is also getting upgraded with support for new chips. VGM files that need a YM2413 emulated now work, meaning more MSX2 VGM files are now supported. This was also known as the VRC7 chip, so additional Famicom VGMs can now be played as well. I also plan to implement support for the Yamaha YMF278b (OPL4) and YMF271 (OPX) chips for the upcoming release. These shouldn’t take too long; I just keep putting them off since it’s kind of tedious work ^_^

But yeah, new VGM chips for Benben v0.6.0!

New Export Formats

Benben has had support for exporting audio to WAV or Au formats since the beginning, with options to output these at various sample rates and bit depths. Now, starting with v0.6.0, you will also be able to export audio directly to QOA and WavPack, at any sample rate or bit depth that Benben supports. Normalization while exporting to these isn’t supported yet, but I feel that this limitation is fine for the time being given that normalization isn’t often needed (and you can always export to WAV/Au, then encode to QOA or WavPack separately).

One thing to keep in mind is that Benben is NOT intended to be a replacement WavPack encoder, and as such, it does not support every single option that the official encoder does. Instead, it supports the most common options that should cover 90% of use cases. QOA doesn’t have this issue since it has no options in the first place :-P

Remote Control and New TCP Audio Driver

These kind of go together…

Before I made Benben, I would usually use a combination of command line players (mpg123, vgmplay, xmp, etc.) and Audacious for playing music. One nice thing about Audacious was a tool that it came with called audtool, which was basically a command line remote control program. I often would bind my media keys in my window manager to call this program in order to control Audacious without having to have it focused. It worked quite nicely, and also let me control the player remotely over SSH. Then I forgot all about it.

Recently I’ve switched to mainly using Bluetooth headphones. Both pairs that I own feature touch controls that let me control media remotely, and when it comes to X11, these signals are interpreted as standard media keys. Now I exclusively use Benben as my media player on PC these days, and I started to think: wouldn’t it be nice if I could control Benben with my Bluetooth headphones, especially if I could do it in a flexible Unix-y way?

And that’s how remote-benben was born. This is a very simple command line program, inspired by audtool, that communicates with Benben over a Unix domain socket. It provides a way to both send control signals to the player (“next track”, “pause”, “volume up”, etc.), and retrieve information from from (“retrieve song title”, “get song number”, etc.). Because it’s a simple command line program, it can be used over an SSH connection, be called with a keyboard binding from your window manager, be called from other programs… lots of possibilities. The protocol is also open and being formalized so that other programs can take advantage of it in the future, if they so choose. I’ve been using it successfully for a while now. Support for additional socket types will appear in the future.

Remote support can be enabled with the new --remote command line argument, or in the config file. The default location for the socket is ~/.local/share/benben/remote.sock (which is always chown’d to your user and chmod’d 0600), but this can be changed as well. Separate development AppImages for remote-benben will appear this coming week.

But I didn’t stop there. I also started to think: what if I wanted my audio to play on one machine, but be piped to another machine? Normally you can do this with something like Pipewire or PulseAudio, and in fact I do this very often because I keep a laptop on my desk with the audio piped my desktop (and with Barrier for KVM stuff), giving me a sort of fake second screen. But PulseAudio was also a pain to set up to work over my network. Plus, what if I wanted to run Benben on a headless (and PulseAudio-less) server? Heck, what if I wanted something more, well… Unix-like?

Well, to complement the new remote-benben program, I decided to add a basic way to send audio directly over a TCP connection. The idea is simple: an unencrypted TCP connection is established with a remote host, and raw PCM or floating point audio is sent over that connection. That’s it. I’ve been testing it on the remote end just using good ol' netcat piped into aplay, though I’m sure that’s not the only way to do it. If you need encryption, you can easily tunnel this over SSH. And since it’s just a very simple TCP connection, and you can use netcat, you can just treat it like any basic stream of data over a Unix pipe, such as adding some compression using something like lz4. There are just way too many possibilities here. The only thing you need to keep in mind is latency.

Smaller New Features

There’s a lot of smaller additions and enhancements as well:

What’s Removed

Two thigns have been removed from Benben: HTTP/HTTPS support, and Gemini support. Technically these were only supported by the VGM format, so this shouldn’t be too big of a loss, and they may still be added back in the future. But as it was, the old implementations were downright awful.

Closing

And that’s it! As I said, the tentative release date is December 5th, 2024 as long as everything goes well.

If you enjoy Benben, and want to see it continue to flourish, please consider making a small donation via Ko-Fi or Liberapay, or checking out my ]Throne wishlist](https://throne.com/remiliascarlet). Support for this project matters, and I cannot tell you how much it means to me to both provide a useful piece of software, and essentially fulfill a dream I’ve had since I was a kid.