I am working on reviewing close to 30 freeware indie Japanese visual novels that were translated into English from 2005 to 2008. For the most part, I have been able to run the visual novels without issue, including the Windows-only visual novels on Linux. With a bit of finagling, I was even able to run three Windows visual novels that require a Japanese language environment on Linux using compatibility tools (see my review of Summer, Cicadas, and the Girl). I discussed how I overcame two sets of issues with running some of the al|together visual novels on Manjaro Linux in earlier posts:
- Setting Japanese language environments in Lutris, Bottles, and Playonlinux
- Running Native Linux Visual Novels With Onscripter-en
In those articles, I referenced a different issue that I have had with a minority of the visual novels that I am reviewing for the project. A few of the visual novels contain .midi files. When I first ran these visual novels on Manjaro Linux and Bodhi Linux, they all had a common issue.
No sound. None at all.
I reviewed two visual novels – Night of the Forget-Me-Nots and Instant Death! Panda Samurai without sound because I could not figure out what to do with the MIDI files. In my onscripter post, I noted that I had figured out how to resolve the issue on Manjaro Linux. Before continuing, let us clarify a few points.
(Spoiler: Install the 32-bit Fluidsynth packages on Arch-based distributions.)
MIDI itself, which stands for “Musical Instrument Digital Interface”, is just a protocol and standard for communication between musical instruments and any device that understands the language. It can be used to control an array of synthesizers, make a tin can sound like a drum, or even operate industrial equipments.
I suppose that explains it a little. But what is in a MIDI file then? I quote again from the Arch Wiki:
Without going into the details of what the format is composed of, you just need to understand that a MIDI file eg. foobar.mid does not contain any digital audio data, hence no “PCM stream”. It is a common misconception that MIDI is a sound file format, and as such you usually see people complaining that music players like Amarok cannot play the file.
Interesting. When I first noticed that the visual novels that I was having sound issues with their contained .mid files, I assumed that MIDI itself was some sort of sound file format. However, this is not the case. But as we see above, MIDI clearly has something to do with sound. What then do we do with a MIDI file in the context of its being part of a game? Let us return to the Arch Wiki:
In order for such a file to be useful, there needs to be an “engine” that can translate the data to music. This engine will have a “tone generator”, and this is what we call a “synthesizer”. So any player that can play back a MIDI file without MIDI-capable hardware (your computer’s sound device), has a synthesizer built-in or uses an external one. A typical keyboard (not the thing you are typing on) is actually made up of two components – a MIDI “controller” (the keys) and a synthesizer (tone generator/module; the thing that makes sound).
So all we need is a synthesizer? Not so fast. The Arch Wiki notes that the synthesizer needs a “soundbank” – that is, a collection of sounds. Apparently there are different soundbank formats, but the only one that I have used is called a “SoundFont,” which seems to typically have a .sf2 ending. The Arch Wiki explains that some soundcards can make use of .sf2 files, but those of us who lack such a soundcard (or other hardware synthesizer) must use a software synthesizer. I know nothing about soundcards or other hardware synthesizers, so note that my entire piece will be about software synthesizers.
Before continuing, I should explain the context in which I was trying to make .mid files run on Linux.
From August 2020 to August 2022, I ran Manjaro Linux. Manjaro Linux is a distribution based on Arch Linux. Of the many Linux distributions that are based on Arch, Manjaro is one of the more distant for reasons having to do with how it manages and packages software (Manjaro aims to be a stable and somewhat user-friendly flavor of Arch, the degree to which it succeeds is beyond the scope of the instant article). In late August 2022, I switched from Manjaro Linux to EndeavourOS. EndeavourOS is also based on Arch Linux, but it is much closer to base Arch than is Manjaro because it uses Arch’s own package repositories and stays up to date with Arch. However, because both are, in the end, based on Arch, my MIDI issues were similar in both cases.
Before continuing, do note that my purpose here is not to provide a comprehensive guide to configuring Fluidsynth to handle MIDI files on Arch-based Linux distributions. I am not knowledgeable enough to do that credibly and troubleshoot issues for others, and in the end I followed the Arch Wiki (which you should too if you have the same issue) with one addendum for this particular use-case.
Back in June, I learned from some helpful people on Mastodon about Fluidsynth. I looked for the Fluidsynth package in Manjaro and discovered that it was already installed. Was I missing something?
I ran “fluidsynth” in the terminal and discovered that it was complaining about a missing soundfont file. Instead of doing the smart thing and reading the Arch Wiki, which contains detailed instructions for configuring Fluidsynth that would have been applicable to Manjaro, I manually downloaded a Soundfont file to where Fluidsynth expected it and renamed it what Fluidsynth expected it to be named. From there, I installed the Fluidsynth plugin for the VLC media player and successfully got sound from one of my .mid files in VLC. Eventually, after some tinkering that I no longer remember in exhaustive detail, I got to the point where Fluidsynth was working system-wide and my visual novels with MIDI files had proper sound.
The only caveat was that I was not getting sound when I ran certain visual novels in Bottles (which I have installed as a Flatpak) instead of Lutris or PlayOnLinux (neither of which are installed as Flatpaks), but that issue is too minor for me to concern myself with since I do not have a strong preference for Bottles for running old visual novels.
I wiped my old Manjaro installation when I installed EndeavourOS on my main desktop. Moreover, I did not transfer my entire home directory – only specific files. For this reason, I needed to set up Fluidsynth all over again to handle sound in the small number of al|together visual novels that require it.
Being a bit wiser now than I was earlier in the summer, I decided to actually read the Arch Wiki to learn how to configure Fluidsynth instead of playing whack-a-mole against errors that appeared when I ran Fluidsynth in the terminal. As luck would have it, Arch Wiki has a detailed FluidSynth guide.
I followed the guide by first installing FluidSynth from the Arch repositories. Instead of manually downloading a soundfont, I followed the Wiki’s advice and installed one of the two soundfont packages from the main Arch repository. This time, instead of renaming the soundfont file, I again followed the Wiki instructions and created a symbolic link to it. After completing these steps, I configured Audacious (my audio player) and VLC with a plugin to use the SoundFont file to handle MIDI, and both were able to interpret the .mid file in the Night of the Forget-Me-Nots directory (I decided to use Night of the Forget-Me-Nots) for testing.
However, I had one problem.
Night of the Forget-Me-Nots itself had no sound. To make sure the issue was consistent, I tested both the native Linux version of the visual novel and the Windows version through Wine. There was no sound in either.
I read through the Arch Wiki again and looked at some MIDI documentation for Wine as well to see if I could find the issue. I found nothing, and my tests continued to fail.
So I knew for a fact that FluidSynth was working (VLC relies on a FluidSynth plugin), but I was still not getting sound in my games. Was I missing something?
I was missing something.
I noticed that the Arch repositories had two Fluidsynth packages: fluidsynth and lib32-fluidsynth.
You can see that I have both packages installed now. However, in my initial tests, I had only installed the FluidSynth. None of the materials that I had read noted the lib32 version. Noting that the visual novels that I am working with are ancient (by our contemporary standards), it occurred to me that maybe I needed the 32-bit FluidSynth libraries. I checked to see if there were any conflicting packages, but there were no conflicts between lib32-fluidsynth and anything that I already had installed. Thus, I decided to install the lib32-fluidsynth and see what happened. After it installed along with its dependencies in a few seconds, I started Night of the Forget-Me-Nots.
I heard sound.
It became obvious to me that on Manjaro, I opted to install all of the main repository FluidSynth packages, whereas on EndeavourOS, I initally installed only fluidsynth and not the lib32-fluidsynth package. While Audacious and VLC with the FluidSynth plugin can interpret MIDI files without the lib32 package, my old visual novels need the 32-bit libraries.
Mystery solved, but a few hours of my life were gone.
The first lesson that I take from this is to follow the Arch Wiki (especially if you are using an Arch-based distribution, but it is often helpful even if you are using a different Linux distribution). Through following the Wiki, I was able to properly configure FluidSynth for general purposes expeditiously. My second lesson is that for people trying to work with MIDI files in older games, the 32-bit FluidSynth libraries may be necessary, but I suppose that it is worth testing the game in question before installing something that is potentially unneeded.
In any event, I cam now proceed with my al|together visual novel review project and enjoy the originally intended soundtracks in all of the games. All is well that ends well.