MIDI under Linux w/ QSynth

Found a bug in R'n'D? Report it here!

Moderators: Flumminator, Zomis

Post Reply
User avatar
armanelgtron
Posts: 29
Joined: Sat Jul 25, 2015 8:25 pm

MIDI under Linux w/ QSynth

Post by armanelgtron »

When running QSynth, RocksnDiamonds doesn't seem to pick it up and I get no music on the levelsets which include MIDI files. Other applications (including applications running under WINE) seem to pick the presence of QSynth just fine, though some do require changing the MIDI output from "midi through" to "FLUID Synth" every time. I can assume RocksnDiamonds is also selecting the wrong MIDI output, but I see no options to change it.
Last edited by armanelgtron on Wed Oct 21, 2020 6:57 am, edited 1 time in total.
Image
User avatar
armanelgtron
Posts: 29
Joined: Sat Jul 25, 2015 8:25 pm

Re: MIDI under Linux w/ QSynth

Post by armanelgtron »

Well, I was playing around some other utilities such as using naconnect to connect "Midi Through Port-0" to "Synth input port"... but after that failed I realized...
armanelgtron wrote: Wed Oct 21, 2020 5:13 am(including applications running under WINE)
So... I tried running RocksnDiamonds under WINE, and that does indeed work correctly. Not ideal though; I'd prefer if MIDI worked natively, but it's better than nothing. (And, for some reason 4.2.0.3 under WINE is playing all normal sounds [NOT MIDI!] at super-speed, while 4.1.4.1 is working fine. EDIT: After more experimentation, it seems to be because of the newer SDL2 included with 4.2.0.3)

Also, I keep having to hit "Panic" in QSynth because notes keep sticking when changing between menus and menus and levels. Gaaah!
Image
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: MIDI under Linux w/ QSynth

Post by Holger »

Yes, playing MIDI in R'n'D (on various platforms) is a constant source of "interesting" things happening... :-/

And yes, as you already found out, I'm quite limited to what SDL_mixer can do for me, unfortunately.

Regarding MIDI playback in SDL_mixer, the "README.txt" says the following:
The mixer can currently load Microsoft WAVE files and Creative Labs VOC
files as audio samples, it can load FLAC files with libFLAC, it can load
Ogg Vorbis files with Ogg Vorbis or Tremor libraries, it can load MP3 files
using mpg123 or libmad, and it can load MIDI files with Timidity,
FluidSynth, and natively on Windows, Mac OSX, and Linux, and finally it can
load the following file formats via ModPlug or MikMod: .MOD .S3M .IT .XM.

[...]

To play MIDI files using FluidSynth, you'll need to set the SDL_SOUNDFONTS
environment variable to a Sound Font 2 (.sf2) file containing the musical
instruments you want to use for MIDI playback.
(On some Linux distributions you can install the fluid-soundfont-gm package)
So, yes, MIDI through FluidSynth should be supported -- and if I googled that right, QSynth is a "Qt GUI Interface for FluidSynth". But wouldn't that mean that playing MIDI through FluidSynth should work with ot without QSynth?

Unfortunately, there are some parts of the SDL library family that are not that well maintained, I think (contributed some bug reports in the past by myself, which were sometimes related to the same bugs that showed up again and again)... :-(
User avatar
armanelgtron
Posts: 29
Joined: Sat Jul 25, 2015 8:25 pm

Re: MIDI under Linux w/ QSynth

Post by armanelgtron »

Ah, I didn't even think about trying to research how SDL handles MIDI... based on what you posted, I tried launching RnD with

Code: Select all

SDL_SOUNDFONTS=/usr/share/soundfonts/FluidR3_GM.sf2 rocksndiamonds
... and it worked! But that means it's launching its own instance of Fluidsynth to use rather than connecting to an external midi connection like with WINE? Interesting, but hey, it seems to be working, so I can't complain. Well, I can, it could've attempted to find the Soundfonts itself instead of requiring me to set an environment variable.

A slightly interesting issue though with this, it seems to be restarting songs where they left off instead of restarting them at the beginning. Also I had to turn down RnD's volume quite a bit in the menu, else the music tends to get too loud and clip.

Anyway,
Holger wrote: Thu Oct 22, 2020 2:41 pm QSynth is a "Qt GUI Interface for FluidSynth".
Yeah, essentially it allows for relatively easy configuration and launching of Fluidsynth, a bit like qJackCtl does with Jack. Fluidsynth can be run independently though.

The thing is, most applications that implement MIDI functionality will send data to an external process that's already running (is it called a MIDI server?). This obviously also means that you're just not limited to just Fluidsynth and Timidity. However, SDL's implementation for some reason apparently launches Timidity/Fluidsynth by itself and runs data directly to that somehow (it doesn't seem to be through ALSA; I don't see anything related to it on naconnect)

When RnD is running under WINE, I assume SDL just sends MIDI data to WINE when RnD is running under it like it'd probably do to Windows, and WINE takes care of routing the events to an external process.

Well, I'm rambling now, but I think this actually explains something else. Years ago I did use Timidity (with freepats, missing instruments and all), and I noticed then that there were differences between listening to a MIDI file directly in Timidity versus how it sounded in the game. I remember specifically that some drum sounds were higher pitched than they should've been. For all I know, that might even still be an issue... I should play with it again at some point in the near future. Little good it does though, heh.
Image
Post Reply