Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No music on Fedora 32 #639

Open
valsu opened this issue Oct 2, 2020 · 7 comments
Open

No music on Fedora 32 #639

valsu opened this issue Oct 2, 2020 · 7 comments

Comments

@valsu
Copy link

valsu commented Oct 2, 2020

On Fedora Linux 32 the music doesn't play anymore. I don't know at which revision it stopped working. Terminal throws errors:

Note: Illegal Audio-MPEG-Header 0x00000000 at offset 1481.
Note: Trying to resync...
Note: Hit end of (available) data during resync.
Note: Illegal Audio-MPEG-Header 0x00000000 at offset 36772.
Note: Trying to resync...
Note: Hit end of (available) data during resync.
@valsu valsu changed the title No music on fc32 No music on Fedora 32 Oct 2, 2020
@valsu
Copy link
Author

valsu commented Oct 3, 2020

It appears only MUS-files are affected. When adding a file with pre-recorded music, like doom1mus.wad, music plays just fine.

@tslilc
Copy link

tslilc commented Dec 17, 2020

This isn't very helpful, but the precise call that generates this is in i_music.c:152: Mix_PlayMusic(handle, (looping ? -1 : 1)). It seems that SDL is being asked to play a MUS as audio data. Presumably this means that the issue is in I_RegisterSong of the same file, but more testing is required to see where things break.

@tslilc
Copy link

tslilc commented Sep 24, 2021

I came back to this some time later, because it still doesn't work for me on Arch (but does on Debian 11, a clue?). Anyway, after stepping through the code on both OSs it would seem that the precise difference is indeed in I_RegisterSong. In i_music.c:284 we have

        if ((rwops = SDL_RWFromMem(data, size)))
            music = Mix_LoadMUS_RW(rwops, SDL_FALSE);

        return music;

For whatever reason this SDL call, Mix_LoadMUS_RW returns differently for the same data on Arch and Debian. This causes a different branch to be taken in S_ChangeMusic in s_sound.c:652:

    if (!(handle = I_RegisterSong(music->data, W_LumpLength(music->lumpnum))))

which on Arch incorrectly branches into writing and then loading the MUS data as an mp3 file. On Debian, however, this branch is not taken.

I can't find any documentation for Mix_LoadMUS_RW presently, but i'll keep looking.

@valsu
Copy link
Author

valsu commented Sep 24, 2021

FWIW, music works fine on Ubuntu too.

@tslilc
Copy link

tslilc commented Sep 26, 2021

Here is a work-around! Ensure that you have a soundfont installed, and then set the environment variable SDL_SOUNDFONTS. This works for me on Arch, with the example invocation

SDL_SOUNDFONTS=/usr/share/soundfonts/FluidR3_GM.sf2 doomretro [...]

@joanbm
Copy link

joanbm commented Jun 26, 2022

In case this helps anyone... @tslilc's answer works for me on Arch, but only along with the fluidsynth optional dependency.

@ismagilli
Copy link
Contributor

ismagilli commented Oct 15, 2023

I'll put in my two cents too.

A couple of days ago I ran into a similar problem on my macOS computer. The problem was also related to Mix_LoadMUS_RW, but it was of a slightly different nature.

The music in the doom game is stored in MIDI format, and the sound effects are stored in WAV format. SDL2_mixer supports both of these formats:

It supports 8 channels of 16 bit stereo audio, plus a single channel of music.
It can load FLAC, MP3, Ogg, VOC, and WAV format audio. It can also load MIDI,
MOD, and Opus audio, depending on build options (see the note below for details.)

But playback of MIDI files does not work out of the box (unlike WAV) and requires a special backend. SDL2_mixer supports 3 backends:

  1. native (only windows, macos and haiku);
  2. fluidsynth;
  3. timidity.

Therefore, to work with MIDI files, it is necessary to have at least one of the backends and, in the case of fluidsynth and timidity, perform additional actions.

The problem I encountered was that the official release of SDL2_mixer from github does not contain any of these backends:

$ nm -a /Library/Frameworks/SDL2_mixer.framework/SDL2_mixer | grep Mix_MusicInterface
0000000000038710 d _Mix_MusicInterface_DRFLAC
0000000000038560 d _Mix_MusicInterface_DRMP3
0000000000038630 d _Mix_MusicInterface_OGG
0000000000038838 d _Mix_MusicInterface_WAV

The solution to the problem was self-build of SDL2_mixer from the source code. I want to note that the compilation time of SD2_mixer and doomretro is almost the same, so no one should have any problems building SDL2_mixer. You can also build SDL2_mixer as a subproject in doomretro. To do this in CMakeLists.txt it is necessary to replace PKG_SEARCH_MODULE(SDL2_MIXER REQUIRED SDL2_mixer) with add_subdirectory(SDL2_mixer) and ${SDL2_MIXER_LINK_LIBRARIES} with SDL2_mixer::SDL2_mixer.

Let's return to linux and the fluidsynth and timidity libraries. The solution given by @tslilc is correct, but only works with fluidsynth. Here is an excerpt from the SDL2_mixer wiki website on using fluidsynth and timidity:

If you have built with FluidSynth support, 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)

To play MIDI files using Timidity, you'll need to get a complete set of GUS
patches from timidity.tar.gz and unpack them in /usr/local/lib under UNIX,
and C:\ under Win32.

The last few posts in this thread are dedicated to archlinux. If you use the official PKGBUILD for SDL2_mixer (without fluidsynth package) and examine the resulting .so library file, you can detect the presence of a timidity backend:

$ nm -a libSDL2_mixer.so
0000000000026360 d Mix_MusicInterface_CMD
0000000000026440 d Mix_MusicInterface_FLAC
0000000000026520 d Mix_MusicInterface_MODPLUG
0000000000026600 d Mix_MusicInterface_MPG123
00000000000266e0 d Mix_MusicInterface_OGG
00000000000267c0 d Mix_MusicInterface_TIMIDITY
00000000000268a0 d Mix_MusicInterface_WAV

Therefore, it is necessary to use a solution for timidity (get a complete set of GUS
patches). If you use fluidsynth, then there will be more backends:

0000000000027380 d Mix_MusicInterface_CMD
0000000000027460 d Mix_MusicInterface_FLAC
0000000000027540 d Mix_MusicInterface_FLUIDSYNTH
0000000000027620 d Mix_MusicInterface_MODPLUG
0000000000027700 d Mix_MusicInterface_MPG123
00000000000277e0 d Mix_MusicInterface_OGG
00000000000278c0 d Mix_MusicInterface_Opus
00000000000279a0 d Mix_MusicInterface_TIMIDITY
0000000000027a80 d Mix_MusicInterface_WAV

I hope my message will help someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants