While undertaking a project to review about 30 English translations of freeware Japanese visual novels from three festivals in 2005, 2006, and 2008, I came across issues involving MIDI sound. A non-insignificant minority of the games that I am looking at rely on MIDI for their music and sound effects. None of the Linux distributions that I have tried these games on – Manjaro Linux (based on Arch), Bodhi Linux (based on Ubuntu), and EndeavourOS (based on Arch Linux) handled sound from these games by default. In September 2022, I wrote an article about struggling to get MIDI sound working on EndeavourOS, a Linux distribution that is close to vanilla Arch Linux, after having successfully gotten it working on Manjaro (based on Arch, but a couple more steps removed than EndeavourOS). At the time, I succeeded by installing Fluidsynth, a MIDI synthesizer, and specifically installing the 32-bit libraries for Fluidsynth. The fix did not last. See when you are grasping at straws, your solutions sometimes come unglued. Now I have fixed it again. Let us see what worked.

Notes before reading

Before continuing, please take note a few points.

  • I run EndeavourOS, which is a derivative of Arch Linux. This story and limited guide only covers my experience on EndeavourOS. This may be significant to the extent that different Linux distributions may have different initial configurations.
  • It should go without saying that nothing in this article is directly applicable to Windows, MacOS, or BSD-based systems, all of which can run ONScripter-EN visual novels.
  • My specific reason for wanting MIDI sound to work is limited to a small number of older visual novels. I have confirmed that my fix works with the native Linux versions of ONScripter-EN visual novels. It is entirely possible that different types of games using MIDI may have some specific issues or requirements that I am not aware of.
  • This is not a guide per se. All of the steps I follow come directly from the Arch Wiki, which is an indispensable research for people running Arch Linux or Linux distributions based on Arch. Moreover, it has plenty of useful Linux information for users of non-Arch-based Linux distributions. To the extent that one who has similar issues to me may consider it a guide, I do cite to all of my sources, detail my solution, and explain the thought process of someone who went into the MIDI-game issue without knowing much about the fundamentals.

With my initial notes aside, let us proceed to MIDI-ing content.

Identifying the MIDI problem

I did not review any al|together visual novels after June 2022 until November of the same year. When I returned after this hiatus, I decided to review Wanderers in the Sky and Visions from the Other Side, two translations from the 2006 set. Because both are written use ONScripter-EN, a free and open source implementation of the NScripter visual novel game engine, I could run them natively on Linux (contrast this with an earlier MIDI game I reviewed, Summer, Cicadas, and the Girl, which is written in KiriKiri and only runs natively on Windows). When I started the games, I quickly noticed that there was no sound. Having had experience with these games, I deduced the likely culprit. One look in the game directories revealed the MIDI files.

The humanity.

The first fix works for Windows ONScripter-EN only

I confessed in my September MIDI article that I did not really know what I was doing. Despite not knowing, I was twice able to get MIDI sound in ONScripter games to play (once on Manjaro and then again on EndeavourOS). This time I decided to dig deeper into the issue. Before continuing, note that everything I am writing about is applicable (to some extent or another) to Arch-based Linux distributions that use Systemd. In this section, I will be discussing the Fluidsynth documentation in the Arch Wiki.

(Rule of thumb: Always read the Arch Wiki.)

As I explained in the first MIDI article, I had installed the 32- and 64-bit Fluidsynth packages on my system previously. Moreover, per the Arch Wiki, I had created a symbolic link to a soundfont file (I downloaded FludR3_GM.sf2).

(Note: After struggling a bit with Fluidsynth, I also tried the Timidity++ synthesizer. However, after having no more luck with that, I returned to Fluidsynth since I had some record of success with it in the past. My understanding, however, is that everything I accomplished with Fluidsynth can be done just as well with Timidity++ if you prefer that software synthesizer for one reason or another.)

I had not previously looked at the Arch documentation on running Fluidsynth in ALSA daemon mode. It seemed like it might be a lead, so I decided to try it and see if it would (permanently) fix my problem. While I could explain the steps in detail, I will note that I followed the Arch Wiki’s instructions to the letter. First, I used the Nano text editor to edit the Fluidsynth configuration file, found on my system at ‘/etc/conf.d/fludsynth’ exactly as the Arch Wiki suggested (note that you must make sure you use your soundfont in the config). Next I had to start the Fluidsynth service. At first I failed, but then I read the Wiki more closely and realized that my failure was due to the fact that I was trying to use root to start the Fluidsynth service. I was ultimately able to start it as a user unit with ‘systemctl –user start fluidsynth.service’. (Note that my audio driver is Pipewire.)

Running Fluidsynth in ALSA daemon mode resolved my issue partially. I can run both the Windows (on top of WINE) and Linux versions of the ONScripter-EN games. When I ran the Windows versions of ONScripter-EN games with Fluidsynth running, sound worked perfectly. However, when I ran the native Linux versions on Linux, I had no sound. This was ultimately why, as I explained in my articles, that I reviewed the Windows versions of Wanderers in the Sky and Visions from the Other Side on top of WINE instead of running the Linux version of ONScripter-EN.

Interlude: Why I care

It does not make much practical difference whether I run the Windows versions of the ONScriptter-EN visual novels on top of WINE or the Linux versions. Porting save data from one system to another may be marginally more intuitive with the Linux version of ONScripter-EN, but actual game-play is the same. Moreover, I will note that the old Windows executables for ONScripter-EN generally run perfectly on top of WINE, whereas I have seen reports that they often struggle on Windows. This suggests that WINE may provide a better experience for running the original al|together Windows visual novels versions than Windows does or ever did (the solution for contemporary Windows users having issues is to replace the original executable with the newest version of ONScripter-EN, the process for Windows would be the same as the process I detailed for Linux, just with the Windows ONScripter-EN instead of the Linux version).

But nevertheless, it bothered me that I could not get sound out of the MIDI ONScripter-EN games with the native Linux versions. As a matter of principle, I prefer running native Linux games where possible, although I am in favor of tools like WINE and Proton when doing so is impossible. Moreover, having written several guides to ONScripter on Linux, I figured that I ought to figure it out. I put the problem off because none of my intervening al|together reviews had the MIDI issue. But as I prepare to hit the home stretch of my project, a few more MIDI games are outstanding.

Let us resolve this once and for all.

Getting MIDI sound to work in ONScripter-EN games running natively on Linux

Here, note we are starting from the foundation I described above. I have Fluidsynth involved (32- and 64-bit versions) and I have configured it to run in ALSA daemon mode. Windows ONScripter-EN games running on top of WINE have no MIDI sound issues. The issue only arises when I try to run the Linux ONScripter-EN binary for the same game.

For this test, I used My Black Cat, an al|together game that I have not yet reviewed but plan to read in the near future. My Black Cat has the unfortunate MIDI issue. Every time I made a change, I ensured that MIDI was still working for games running on WINE by testing my existing Windows-WINE install of Visions from the Other Side. Before continuing, I will note that none of the things that I tried affected MIDI working for Windows games running on WINE, so I will not discuss that step going forward.

My first thought was to try changing launch variables for My Black Cat to see if I could resolve the issue that way. This can be done by adding an ons.cfg text file to the game’s directory (see docs). However, I could not find any that worked, so we can proceed to the next step.

My second thought (this probably should have been my first thought) was to check the terminal output when running My Black Cat. I recalled having noticed something several months ago while launching Night of the Forget-Me-Nots (the first MIDI ONScripter-EN game I reviewed) that seemed relevant. I noted the following line in the terminal output for My Black Cat:

open /dev/sequencer: No such file or directory

This did seem relevant. I confirmed that I did in fact have no sequencer file in the /dev/ directory. This seemed like the issue, but I did not know how to resolve it.

While I had little hope for finding an ONScripter-EN-specific solution to the issue, I figured that the MIDI issue was broader. I did find some results when I searched for the error message, but most were from more than 10 years ago (this was not too surprising). One suggested loading the snd-seq kernel module, so I tried that and then created a symbolic link from /dev/sequencer/ to snd-seq. This did change the terminal output, but only insofar as ONScripter-EN complained that there was no audio driver. This is, I believe, because I would have needed a hardware synthesizer for it to work. I removed the symbolic link and with this final hint, looked for a solution.

The Arch Wiki explains that ALSA “provides kernel driven sound card drivers.” I was running Fluidsynth in ALSA daemon mode. In this mode, the Arch Wiki explains on its Fluidsynth page, Fluidsynth “add[s] MIDI support to ALSA.” Taken together, I figured that perhaps I could do something to ensure that ALSA answers when ONScripter-EN looks for something in /dev/sequencer. I looked through the Arch Wiki page for ALSA, and I noted something interesting in part 1.3, OSS compatibility:

Note: This is important if your application complains about missing /dev/dsp or /dev/snd/seq.

My application is so old that it is complaining about missing /dev/sequencer instead of /dev/snd/seq, but I optimistically hoped that we were over the target. Arch Wiki provided instructions in two steps:

If you want OSS applications to work with dmix, install the alsa-oss package as well. Then load the snd-seq-oss, snd-pcm-oss and snd-mixer-oss kernel modules to enable OSS emulation.

I first checked to make sure that I had alsa-oss installed. After confirming that I did, I loaded the snd-seq-oss, snd-pcm-oss, and snd-mixer-oss kernel modules.

modprobe -a snd-seq-oss snd-pcm-oss snd-mixer-oss

After loading these modules, I launched My Black Cat again from the terminal. This time, there were no complaints about a missing /dev/sequencer. That looked promising, but My Black Cat starts slowly – so I was unsure if I had won. I clicked through a brief prologue and after about 30-40 seconds, music began to play.

(Of course my test game had to be a game with no music for 30-40 seconds.)

My MIDI struggle has finally ended. Native Linux ONScripter-EN games work too!

Note that loading the modules once only loads them for a particular session. While you can configure the modules to load at boot, I (for the time being) opted to create an alias so I can load them with a short keyword whenever I need to run the Linux version ONScripter-EN game with MIDI sound.

Conclusion

I hope that this solution, which came from research and provided me a somewhat better understanding (only somewhat) of what is going on, at least prevents any MIDI issues through my completion of the al|together project this summer. While I cannot promise that these steps will resolve the issue for others (I cannot account for different Linux distributions or set-ups, and things worked with less set-up in the MIDI area on Manjaro than they did on EndeavourOS), my solution, which really was lifted from the excellent Arch Wiki, should help point someone in the right direction. It was an interesting journey (and I sincerely hope that I never have cause to write about MIDI sound in games again).