adventuregamestudio / ags

AGS editor and engine source code
Other
696 stars 159 forks source link

3.6.0: Problems with MIDI audio (SDL_Sound / Timidity issue) #1941

Open i30817 opened 1 year ago

i30817 commented 1 year ago

Describe the bug I placed this timidity.cfg on a game that uses midi (trilby notes special edition) - .txt extension doesn't count, it's just for github to deign to allow it: timidity.cfg.txt

The file points to 'source /etc/timidity/fluidr3_gm.cfg' which does exist:

$ head /etc/timidity/fluidr3_gm.cfg 
dir /usr/share/sounds/sf2

bank 0
0 %font "FluidR3_GM.sf2" 0 0 amp=29 pan=0
1 %font "FluidR3_GM.sf2" 0 1 amp=41 pan=0
2 %font "FluidR3_GM.sf2" 0 2 amp=64 pan=0
3 %font "FluidR3_GM.sf2" 0 3 amp=32 pan=0
4 %font "FluidR3_GM.sf2" 0 4 amp=35 pan=0
5 %font "FluidR3_GM.sf2" 0 5 amp=51 pan=0
6 %font "FluidR3_GM.sf2" 0 6 amp=71 pan=0

and so does the soundfount itself:

$ ls /usr/share/sounds/sf2/
default-GM.sf2@  FluidR3_GM.sf2  TimGM6mb.sf2

Therefore the game starting should have music in the main menu (it has on the current scummvm version of ags, although that one is still using allegro iirc, so it might not using timidity through sdl).

But it doesn't. Using the cmd line variable TIMIDITY_CFG doesn't have a effect either.

The output of ags is:

Adventure Game Studio v3.6 Interpreter
Copyright (c) 1999-2011 Chris Jones and 2011-2023 others
ACI version 3.6.0.44

Initializing backend libs
SDL Version: 2.0.20
Initializing game data
Located game data pak: /media/i3/Mordred/Games/Adventure Game Studio/Trilby 3 - Trilby's Notes Special Edition/notes se.exe
Opened game data file: ac2game.dta
Game data version: 27
Compiled with: 2.62
Startup directory: /media/i3/Mordred/Games/Adventure Game Studio/Trilby 3 - Trilby's Notes Special Edition
Data directory: /media/i3/Mordred/Games/Adventure Game Studio/Trilby 3 - Trilby's Notes Special Edition/
Setting up game configuration
Unable to init voice pack 'speech.vox', file not found or of unknown format.
Initializing TTF renderer
Initializing mouse: number of buttons reported is 3
Install timer
Audio driver: pulseaudio
AudioCore: opened device "Default OpenAL playback device"
Supported sound decoders:
 - Play modules through ModPlug : 669,AMF,AMS,DBM,DMF,DSM,FAR,GDM,IT,MDL,MED,MOD,MT2,MTM,OKT,PTM,PSM,S3M,STM,ULT,UMX,XM,
 - MPEG-1 Audio Layer I-III : MP3,MP2,MP1,
 - Microsoft WAVE audio format : WAV,
 - Audio Interchange File Format : AIFF,AIF,
 - Sun/NeXT audio file format : AU,
 - Ogg Vorbis audio : OGG,
 - Creative Labs Voice format : VOC,
 - Raw audio : RAW,
 - Shorten-compressed audio data : SHN,
 - Free Lossless Audio Codec : FLAC,FLA,
Install exit handler
Initialize legacy path finder library
Game title: 'Trilby's Notes SE'
Game uid (old format): `1112392103`
Game guid: ''
Game GUI version: 105
WARNING: font 'agsfnt0.wfn' has mistakes in data format, some characters may be displayed incorrectly
WARNING: font 'agsfnt0.wfn' has mistakes in data format, some characters may be displayed incorrectly
Checking for disk space
Game native resolution: 320 x 240 (8 bit) letterbox-by-design
Graphic settings: driver: OGL, windowed: no, screen size: 0 x 0, game scale: round
Running OpenGL: 4.6
Graphics mode set: 1920 x 1080 (32-bit) fullscreen desktop
Mouse speed control: enabled, unit: 1.000000, user value: 2.000000
Touch-to-mouse motion mode: absolute
Multitasking mode set: 0
Setting up window
Multitasking mode set: 0
Initialize sprites
Engine initialization complete
Starting game
Quitting the game...
***** ENGINE HAS SHUTDOWN

and the acsetup.cfg config file in the game dir is:

[sound]
midiid=AUTO
[graphics]
vsync=1
game_scale_fs=max_round
windowed=0
[language]
translation=
[mouse]
auto_lock=0
speed=2

btw, was midiid deprecated meanwhile?

AGS Version Adventure Game Studio v3.6 Interpreter Copyright (c) 1999-2011 Chris Jones and 2011-2023 others ACI version 3.6.0.44

self compiled, commit 8365802092cd3f704aecffe7d08b4d9f65f1f396

Game https://archive.org/details/Trilbys_Notes

To Reproduce just start game

Expected behavior Music

Desktop (please complete the following information):

i30817 commented 1 year ago

Apparently the scummvm downstream is still playing music. I removed patches.dat to make sure, and apparently it's still playing.

I also tried to move the game dir to a place without spaces and changed the executable name to remove the spaces there to see if it made a difference - it didn't.

i30817 commented 1 year ago

Ahah. I installed freepats.

That soundfont does produce sound possibly because it's the default one so you might not even need to configure it... but it's very bad sound. One of the worst i ever heard. Pa-Pa-Pa. Seems like either pulseaudio just hates it or something else is going on.

ivan-mogilko commented 1 year ago

To clarify, difference with Scummvm may be irrelevant here, because they may be using their own midi loader and audio backend. ( - unless we use them as an example to implement something) In regards to Allegro, we (and scummvm's ags port) use a stripped version of allegro4 code which does not have any device or audio support code, but only math, bitmap drawing, and similar utilities.

ericoporto commented 1 year ago

@i30817 , there is something wrong in your build, I don't see the following in your log:

Supported sound decoders:
- MIDI decoder, using a subset of TiMidity : MIDI,MID,

How did you build SDL_sound from source? We don't use any timidity you may have installed in your system, the one used is inside SDL_sound itself, so you HAVE to build SDL_sound from source if you are building by hand.

Can you explain how you are building ags?

In you acsetup

[sound]
midiid=AUTO

I think this is not used anymore, midi goes through OpenAL interface now (mojoAL is the one we use).

i30817 commented 1 year ago

I see. I'd forgotten about it, but i built SDL2_sound ages ago and installed it with checkinstall. I guess it's so out of date that not even the make picks it up for MIDI.

I'll have to redownload it all over again and build it because i lost/removed the sdl git repo i had locally ages ago.

i30817 commented 1 year ago

Oh nice, they actually released it. https://github.com/icculus/SDL_sound/releases/tag/v2.0.1

Guess i don't need git.

ericoporto commented 1 year ago

Please build from their main and use the latest commit, I think their release is quite old. Also you need to do something there to actually include Timidity in the build.

i30817 commented 1 year ago

Do i need to do something else in the ags make file? Because i build sdl-sound with timidity support, created the deb package and installed it (removing the previous one), verified the package has playsound, include headers and libraries, both dynamic and static.

but when i try to build ags it still comes out without that line you mention.

i named the package sdl-sound, should it be another name or something, or is that irrelevant?

i30817 commented 1 year ago

Mmm, i'm not using cmake to build the ags engine, but the make file in the Engine subdir.

That's one possibility of breakage. The other is ... well, i'm not really a professional programmer so i'm ignorant about what linker names actually mean, and since i'm constructing the package, i'm worried i gave it the wrong name.

The linker (in Makefile-defs.linux for the non-cmake version) is using -lSDL2_sound

I tried package names and description 'libsdl-sound', 'libsdl2-sound', 'sdl2-sound' and 'sdl-sound', but it seems none picked it up.

The header file in the package ends up in /usr/local/include/SDL2/SDL_sound.h

i30817 commented 1 year ago

Mmm, no, that is controlled by the SDL_sound.pc file which is in the package, and appears to have all the right things... So i don't get it.

make CPATH=/usr/local/include/SDL2/ USE_BUILT_IN_LIBSRC=0 ags in the Engine dir is how i'm making it. It seems to pick up SDL2_audio (it doesn't fail linking SDL_audio.h) but it never shows that text you say it should and never plays midi. And i did build sdl_audio with timidity support and cmake says so...

ericoporto commented 1 year ago

Is there any specific reason to not use the prebuilt AGS engine from the release packages? Does it work in your system?

The CMake build will also just build everything by default and then you can selectively tell it to use libraries from your system by using it's variables, later, after you get it working with the default config.

i30817 commented 1 year ago

Well, i like to use the git so i can report bugs with bisects.

I'm not using cmake because it's easier to automate make because i already made a script and a navi snippet (it's a cmdline command organizer) to pull branches and prs then automatically make them.

Since the script is only working with make, that's what i'm using.

ericoporto commented 1 year ago

Can you give the output of ldd ags (or ldd MYAGSBINARY)? This should tell where is the SDL_Sound you are linking. And can you tell the exact commit of SDL_Sound that you build?

Is there any chance there's something else that uses SDL_Sound 1 (based on SDL 1) in your system? I don't remember if the package actually changed names. Only SDL_Sound 1 is in Ubuntu repositories.

I just mentioned to try using a binary from our releases, because the claim that Midi is not working is incorrect afaict - it's not a bug.

ivan-mogilko commented 1 year ago

I also use raw make in most cases (sometimes I use instructions for debian/rules in order to install ags as a package), and iirc I had to manually install SDL_sound on my system, because it did not have any installation scripts, at least at the time when I last checked. But I don't remember these details by heart unfortunately. I might try again later and see what I had to do.

i30817 commented 1 year ago

It's 'libSDL2_sound.so.2 => /usr/local/lib/libSDL2_sound.so.2 (0x00007fdb30116000)'

Which in turn is is a link to libSDL2_sound.so.2.0.1 (i put in that version in checkinstall), which is one of the two versions of the library that the package installs (the other is the .a file version).

Everything appears fine with that... i guess.

i30817 commented 1 year ago

libsdl-sound1.2 and libsdl-sound1.2-dev are also installed... but the header is on another directory (/usr/include/SDL/SDL_sound.h instead of /usr/include/SDL2/SDL_sound.h)

ericoporto commented 1 year ago

My suggestion would be, build libSDL2_Sound.so from main and then just mv it in place and see if it works. Don't use the release as there are several commits after that fixed different issues.

Edit: I think you can also use LD_LIBRARY_PATH to force Linux to look in the specific dir first, say if you have SDL_Sound/build you pass that dir.

i30817 commented 1 year ago

It may not be clear, but i took your advice before. I am building from main, specifically the last commit (first) then the next to last because the git log mentioned the last commit messed with the cmakefile.

I'm actually giving up. I built sdl_audio correctly at least 10 times, installing each time with make install after uninstalling the previous build, checked its make file and edited the default value of sdlsound_decoder_option(MIDI "Midi" ".MID" FALSE) to sdlsound_decoder_option(MIDI "Midi" ".MID" TRUE), tried instead to pass the required flags too, verified the ags built links to the .so, even tried the LD_LIBRARY_PATH=/SDL_sound/build/ trick, but ags never reports MIDI in its 'Supported sound decoders'.

Going to sleep and not think about this.

i30817 commented 1 year ago

Just for kicks, i tried to install the deb in the prerelease. It still didn't work (i used the full path to not be confused by the alias i have to my build dir ags)

This is what ldd said about that file:

i3@sleipnir:/media/i3/Mordred/Games/Adventure Game Studio/Trilby 3 - Trilby's Notes Special Edition$ ldd /usr/bin/ags 
    linux-vdso.so.1 (0x00007ffcf13e5000)
    libogg.so.0 => /lib/x86_64-linux-gnu/libogg.so.0 (0x00007f6682804000)
    libtheora.so.0 => /lib/x86_64-linux-gnu/libtheora.so.0 (0x00007f66827bb000)
    libvorbis.so.0 => /lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f668278e000)
    libSDL2-2.0.so.0 => /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 (0x00007f66825ee000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f66825e9000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f66825e4000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f66823b8000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f66822d1000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f66822b1000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6682089000)
    libcairo.so.2 => /lib/x86_64-linux-gnu/libcairo.so.2 (0x00007f6681f61000)
    libasound.so.2 => /lib/x86_64-linux-gnu/libasound.so.2 (0x00007f6681e5e000)
    libpulse.so.0 => /lib/x86_64-linux-gnu/libpulse.so.0 (0x00007f6681e07000)
    libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f6681cc7000)
    libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007f6681cb2000)
    libXcursor.so.1 => /lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f6681ca6000)
    libXinerama.so.1 => /lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f6681ca1000)
    libXi.so.6 => /lib/x86_64-linux-gnu/libXi.so.6 (0x00007f6681c8d000)
    libXfixes.so.3 => /lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f6681c83000)
    libXrandr.so.2 => /lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f6681c76000)
    libXss.so.1 => /lib/x86_64-linux-gnu/libXss.so.1 (0x00007f6681c71000)
    libXxf86vm.so.1 => /lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007f6681c6a000)
    libdrm.so.2 => /lib/x86_64-linux-gnu/libdrm.so.2 (0x00007f6681c54000)
    libgbm.so.1 => /lib/x86_64-linux-gnu/libgbm.so.1 (0x00007f6681c43000)
    libwayland-egl.so.1 => /lib/x86_64-linux-gnu/libwayland-egl.so.1 (0x00007f6681c3c000)
    libwayland-client.so.0 => /lib/x86_64-linux-gnu/libwayland-client.so.0 (0x00007f6681c2b000)
    libwayland-cursor.so.0 => /lib/x86_64-linux-gnu/libwayland-cursor.so.0 (0x00007f6681c21000)
    libxkbcommon.so.0 => /lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007f6681bda000)
    libdecor-0.so.0 => /lib/x86_64-linux-gnu/libdecor-0.so.0 (0x00007f6681bd0000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f668282f000)
    libpixman-1.so.0 => /lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007f6681b23000)
    libfontconfig.so.1 => /lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f6681ad9000)
    libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f6681a11000)
    libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f66819d6000)
    libxcb-shm.so.0 => /lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f66819d1000)
    libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f66819a7000)
    libxcb-render.so.0 => /lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007f6681996000)
    libXrender.so.1 => /lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f6681989000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f668196d000)
    libpulsecommon-15.99.so => /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-15.99.so (0x00007f66818e8000)
    libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f668189a000)
    libwayland-server.so.0 => /lib/x86_64-linux-gnu/libwayland-server.so.0 (0x00007f6681882000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f6681851000)
    libffi.so.8 => /lib/x86_64-linux-gnu/libffi.so.8 (0x00007f6681844000)
    libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f668183b000)
    libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007f668182d000)
    libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f6681825000)
    libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f668181d000)
    libsndfile.so.1 => /lib/x86_64-linux-gnu/libsndfile.so.1 (0x00007f668179e000)
    libX11-xcb.so.1 => /lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007f6681799000)
    libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007f66816d2000)
    libasyncns.so.0 => /lib/x86_64-linux-gnu/libasyncns.so.0 (0x00007f66816ca000)
    libapparmor.so.1 => /lib/x86_64-linux-gnu/libapparmor.so.1 (0x00007f66816b3000)
    libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007f6681690000)
    libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f6681678000)
    libFLAC.so.8 => /lib/x86_64-linux-gnu/libFLAC.so.8 (0x00007f668163c000)
    libvorbisenc.so.2 => /lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f6681591000)
    libopus.so.0 => /lib/x86_64-linux-gnu/libopus.so.0 (0x00007f6681531000)
    liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f6681506000)
    libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1 (0x00007f6681437000)
    liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007f6681417000)
    libcap.so.2 => /lib/x86_64-linux-gnu/libcap.so.2 (0x00007f668140c000)
    libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f66812ce000)
    libmd.so.0 => /lib/x86_64-linux-gnu/libmd.so.0 (0x00007f66812bf000)
    libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f6681299000)

Which unlike my self build isn't even linking to sdl2_sound. Not sure if it's supposed to be a static build? Regardless, it still didn't show that text it's supposed to show when running trilby notes.

ivan-mogilko commented 1 year ago

@ericoporto

@i30817 , there is something wrong in your build, I don't see the following in your log:

This line: - MIDI decoder, using a subset of TiMidity : MIDI,MID,

Is not displayed when decoder was not initialized successfully, which may also happen if it did not find timidity config.

So maybe the problem is not that it is not built correctly, but that it cannot find timidity.cfg correctly, or for some other internal reasons.

EDIT: unfortunately it seems that SDL_Sound only logs if DEBUG_CHATTER is defined, and it does not have own verbosity settings.

EDIT2: BTW, I found that my build on linux also does not have MIDI working, so I'll have to investigate this too. (Cannot tell if that's related to @i30817's problem, or this is something separate)

i30817 commented 1 year ago

I'll admit, not in all tests i had the config file (it was only in the directory of one game, and i'm assuming it fallsback to the game directory). But the firsts, and last few tests were with one.

ivan-mogilko commented 1 year ago

it was only in the directory of one game, and i'm assuming it fallsback to the game directory

If you refer to timidity.cfg, then no, it does not fallback to game dir. This is the option that we were missing, and even opened a ticket in SDL_Sound repo for this and similar purposes: https://github.com/icculus/SDL_sound/issues/69

According to the SDL_sound sources it looks in:

i30817 commented 1 year ago

Unfortunately, TIMIDITY_CFG doesn't work either, i tried it before (and i tried it again just now).

edit: copying to /etc/timidity.cfg and renaming to /etc/timidity/freepats.cfg doesn't work either

I do remember that if i installed freepats, i had ... very bad... sound in this game. But since timidity mentions that freepats is the default soundfont that could be just that by finding nothing, it's falling back to something it understands, and the error is getting the other paths to the library.

Not sure if freepats sound being terrible is another bug, pulseaudio underruns, or just a effect of a bad soundfont for the game.

If your problem is the same as mine, installing freepats soundfont might indicate it i guess. It's a 30mb download.

Makes me wish that patches.dat in the game directory still worked, which is what i did previously to all the games that required soundfonts (i used hardlinks instead of duplicating), when allegro still was handling midi.

i30817 commented 1 year ago

Also tried the idea of using TIMIDITY_CFG to point directly to the soundfonts cfg i have, instead of using the timidity.cfg with 'source /pathtosoundfont.cfg' inside.

That didn't work either. Peace out.

ericoporto commented 1 year ago

OK, I tested and confirm it is indeed working in Ubuntu.

Here's a self contained ags binary that should work: ags.tar.gz . It should generate a lot more log messages.

I confirmed that the midi decoder line is indeed shown. But if it fails to initialize because of TIMIDITY_CFG is not set, it' s not shown at all.

My question is, @i30817 , what is the value you set TIMIDITY_CFG and how did you set it?

I did export TIMIDITY_CFG=/home/myuser/timidity/timidity.cfg

Here is the test game I used: larry_test.ags.zip

I used the timidity files here. Note you have to fix the PATH in timidity.cfg as I packaged the file at the time for testing on windows.

Here is the log of it running in my linux machine: log.txt

i30817 commented 1 year ago
i3@sleipnir:~/Downloads/Trilby 3 - Trilby's Notes Special Edition$ TIMIDITY_CFG=/home/i3/Downloads/Trilby\ 3\ -\ Trilby\'s\ Notes\ Special\ Edition/timidity.cfg /home/i3/Downloads/ags 
Adventure Game Studio v3.6 Interpreter
Copyright (c) 1999-2011 Chris Jones and 2011-2023 others
ACI version 3.6.0.44

Initializing backend libs
SDL Version: 2.24.1
Initializing game data
Located game data pak: /home/i3/Downloads/Trilby 3 - Trilby's Notes Special Edition/notes se.exe
Opened game data file: ac2game.dta
Game data version: 27
Compiled with: 2.62
Startup directory: /home/i3/Downloads/Trilby 3 - Trilby's Notes Special Edition
Data directory: /home/i3/Downloads/Trilby 3 - Trilby's Notes Special Edition/
Setting up game configuration
Unable to init voice pack 'speech.vox', file not found or of unknown format.
Initializing TTF renderer
Initializing mouse: number of buttons reported is 3
Install timer
Audio driver: pulseaudio
AudioCore: opened device "Default OpenAL playback device"

TIMIDITY_CFG= /home/i3/Downloads/Trilby 3 - Trilby's Notes Special Edition/timidity.cfg

init config file: /home/i3/Downloads/Trilby 3 - Trilby's Notes Special Edition/timidity.cfg

init_with_config Timidity result rc = 0
SDL : APP: INFO: Trying to open /home/i3/Downloads/Trilby 3 - Trilby's Notes Special Edition/timidity.cfg
SDL : APP: INFO: Trying to open /etc/timidity/fluidr3_gm.cfg
SDL : APP: INFO: /etc/timidity/fluidr3_gm.cfg: line 6: bad patch option FluidR3_GM.sf2

read_config_file Timidity result rc = -1
SDL : APP: INFO: __Sound_SetError("MIDI: Could not initialise"); [NOT INITIALIZED!]
Supported sound decoders:
 - Play modules through ModPlug : 669,AMF,AMS,DBM,DMF,DSM,FAR,GDM,IT,MDL,MED,MOD,MT2,MTM,OKT,PTM,PSM,S3M,STM,ULT,UMX,XM,
 - MPEG-1 Audio Layer I-III : MP3,MP2,MP1,
 - Microsoft WAVE audio format : WAV,
 - Audio Interchange File Format : AIFF,AIF,
 - Sun/NeXT audio file format : AU,
 - Ogg Vorbis audio : OGG,
 - Creative Labs Voice format : VOC,
 - Raw audio : RAW,
 - Shorten-compressed audio data : SHN,
 - Free Lossless Audio Codec : FLAC,FLA,
Install exit handler
Initialize legacy path finder library
Game title: 'Trilby's Notes SE'
Game uid (old format): `1112392103`
Game guid: ''
Game GUI version: 105
WARNING: font 'agsfnt0.wfn' has mistakes in data format, some characters may be displayed incorrectly
WARNING: font 'agsfnt0.wfn' has mistakes in data format, some characters may be displayed incorrectly
Checking for disk space
Game native resolution: 320 x 240 (8 bit) letterbox-by-design
Graphic settings: driver: OGL, windowed: no, screen size: 0 x 0, game scale: round
Running OpenGL: 4.6
Graphics mode set: 1920 x 1080 (32-bit) fullscreen desktop
Mouse speed control: enabled, unit: 1.000000, user value: 2.000000
Touch-to-mouse motion mode: absolute
Multitasking mode set: 0
Setting up window
Multitasking mode set: 0
Initialize sprites
Engine initialization complete
Starting game
SDL : APP: INFO: MODPLUG: Unrecognized file type: mid
SDL : APP: INFO: __Sound_SetError("MODPLUG: Not a module file.");
SDL : APP: INFO: __Sound_SetError("MP3: Not an MPEG-1 layer 1-3 stream.");
SDL : APP: INFO: __Sound_SetError("WAV: Not a RIFF file.");
SDL : APP: INFO: __Sound_SetError("AIFF: Not a FORM file.");
SDL : APP: INFO: __Sound_SetError("AU: Not an .AU stream.");
SDL : APP: INFO: __Sound_SetError("VORBIS: missing capture pattern");
SDL : APP: INFO: __Sound_SetError("VOC: Wrong signature; not a VOC file.");
SDL : APP: INFO: __Sound_SetError("RAW: extension isn't explicitly "RAW".");
SDL : APP: INFO: __Sound_SetError("SHN: Not a SHN file");
SDL : APP: INFO: __Sound_SetError("FLAC: Not a FLAC stream.");
SDL : APP: INFO: __Sound_SetError("Sound format unsupported");
SDL : APP: INFO: WAV: Appears to be uncompressed audio.
SDL : APP: INFO: WAV: Accepting data stream.
SDL : APP: INFO: New sample DESIRED format: S16LSB format, 22050 rate, 1 channels.
SDL : APP: INFO: New sample ACTUAL format: S16LSB format, 22050 rate, 1 channels.
SDL : APP: INFO: On-the-fly conversion: DISABLED.
SDL : APP: INFO: WAV: Appears to be uncompressed audio.
SDL : APP: INFO: WAV: Accepting data stream.
SDL : APP: INFO: New sample DESIRED format: S16LSB format, 22050 rate, 1 channels.
SDL : APP: INFO: New sample ACTUAL format: S16LSB format, 22050 rate, 1 channels.
SDL : APP: INFO: On-the-fly conversion: DISABLED.
Quitting the game...
***** ENGINE HAS SHUTDOWN
i30817 commented 1 year ago

Bad patch option huh? What the hell.

dir /usr/share/sounds/sf2

bank 0
0 %font "FluidR3_GM.sf2" 0 0 amp=29 pan=0
1 %font "FluidR3_GM.sf2" 0 1 amp=41 pan=0
2 %font "FluidR3_GM.sf2" 0 2 amp=64 pan=0
3 %font "FluidR3_GM.sf2" 0 3 amp=32 pan=0
4 %font "FluidR3_GM.sf2" 0 4 amp=35 pan=0
5 %font "FluidR3_GM.sf2" 0 5 amp=51 pan=0
6 %font "FluidR3_GM.sf2" 0 6 amp=71 pan=0
7 %font "FluidR3_GM.sf2" 0 7 amp=65 pan=0
8 %font "FluidR3_GM.sf2" 0 8 amp=73 pan=0
9 %font "FluidR3_GM.sf2" 0 9 amp=98 pan=0

doesn't look any different.

i30817 commented 1 year ago

On your test game instead of trilby, same thing. Trying the other soundfont i have installed, timgm6mb:

SDL : APP: INFO: Trying to open /etc/timidity/timgm6mb.cfg SDL : APP: INFO: /etc/timidity/timgm6mb.cfg: line 6: bad patch option TimGM6mb.sf2

Kind of suspicious, it's the exact same error.

i30817 commented 1 year ago

With the sound font you provided a link to, changing the 'dir' using 'base dir' and using the timidity.cfg file that came with the zip:

i3@sleipnir:~/Downloads/larry_test.ags$ TIMIDITY_CFG=/home/i3/Downloads/larry_test.ags/TIMIDITY/timidity.cfg /home/i3/Downloads/ags 
Adventure Game Studio v3.6 Interpreter
Copyright (c) 1999-2011 Chris Jones and 2011-2023 others
ACI version 3.6.0.44

Initializing backend libs
SDL Version: 2.24.1
Initializing game data
Located game data pak: /home/i3/Downloads/larry_test.ags/game.ags
Opened game data file: ac2game.dta
Game data version: 26
Compiled with: 2.61
Startup directory: /home/i3/Downloads/larry_test.ags
Data directory: /home/i3/Downloads/larry_test.ags/
Setting up game configuration
Unable to init voice pack 'speech.vox', file not found or of unknown format.
Initializing TTF renderer
Initializing mouse: number of buttons reported is 3
Install timer
Audio driver: pulseaudio
AudioCore: opened device "Default OpenAL playback device"

TIMIDITY_CFG= /home/i3/Downloads/larry_test.ags/TIMIDITY/timidity.cfg

init config file: /home/i3/Downloads/larry_test.ags/TIMIDITY/timidity.cfg

init_with_config Timidity result rc = 0
SDL : APP: INFO: Trying to open /home/i3/Downloads/larry_test.ags/TIMIDITY/timidity.cfg
SDL : APP: INFO: Trying to open gravis.cfg
SDL : APP: INFO: Trying to open $basedir\INSTRUMENTS\/gravis.cfg
SDL : APP: INFO: Trying to open /home/i3/Downloads/larry_test.ags/TIMIDITY/gravis.cfg
SDL : APP: INFO: Could not open gravis.cfg

read_config_file Timidity result rc = -1
SDL : APP: INFO: __Sound_SetError("MIDI: Could not initialise"); [NOT INITIALIZED!]
Supported sound decoders:
 - Play modules through ModPlug : 669,AMF,AMS,DBM,DMF,DSM,FAR,GDM,IT,MDL,MED,MOD,MT2,MTM,OKT,PTM,PSM,S3M,STM,ULT,UMX,XM,
 - MPEG-1 Audio Layer I-III : MP3,MP2,MP1,
 - Microsoft WAVE audio format : WAV,
 - Audio Interchange File Format : AIFF,AIF,
 - Sun/NeXT audio file format : AU,
 - Ogg Vorbis audio : OGG,
 - Creative Labs Voice format : VOC,
 - Raw audio : RAW,
 - Shorten-compressed audio data : SHN,
 - Free Lossless Audio Codec : FLAC,FLA,
Install exit handler
Initialize legacy path finder library
Game title: 'Leisure Suit Larry 2'
Game uid (old format): `960365362`
Game guid: ''
Game GUI version: 105
WARNING: font 'agsfnt1.wfn' has mistakes in data format, some characters may be displayed incorrectly
Checking for disk space
Game native resolution: 320 x 200 (16 bit)
Graphic settings: driver: OGL, windowed: no, screen size: 0 x 0, game scale: proportional
Running OpenGL: 4.6
Graphics mode set: 1920 x 1080 (32-bit) fullscreen desktop
Mouse speed control: enabled, unit: 1.000000, user value: 1.000000
Touch-to-mouse motion mode: absolute
Multitasking mode set: 0
Setting up window
Multitasking mode set: 0
Initialize sprites
Engine initialization complete
Starting game
SDL : APP: INFO: MODPLUG: Unrecognized file type: mid
SDL : APP: INFO: __Sound_SetError("MODPLUG: Not a module file.");
SDL : APP: INFO: __Sound_SetError("MP3: Not an MPEG-1 layer 1-3 stream.");
SDL : APP: INFO: __Sound_SetError("WAV: Not a RIFF file.");
SDL : APP: INFO: __Sound_SetError("AIFF: Not a FORM file.");
SDL : APP: INFO: __Sound_SetError("AU: Not an .AU stream.");
SDL : APP: INFO: __Sound_SetError("VORBIS: missing capture pattern");
SDL : APP: INFO: __Sound_SetError("VOC: Wrong signature; not a VOC file.");
SDL : APP: INFO: __Sound_SetError("RAW: extension isn't explicitly "RAW".");
SDL : APP: INFO: __Sound_SetError("SHN: Not a SHN file");
SDL : APP: INFO: __Sound_SetError("FLAC: Not a FLAC stream.");
SDL : APP: INFO: __Sound_SetError("Sound format unsupported");
SDL : APP: INFO: MODPLUG: Unrecognized file type: mid
SDL : APP: INFO: __Sound_SetError("MODPLUG: Not a module file.");
SDL : APP: INFO: __Sound_SetError("MP3: Not an MPEG-1 layer 1-3 stream.");
SDL : APP: INFO: __Sound_SetError("WAV: Not a RIFF file.");
SDL : APP: INFO: __Sound_SetError("AIFF: Not a FORM file.");
SDL : APP: INFO: __Sound_SetError("AU: Not an .AU stream.");
SDL : APP: INFO: __Sound_SetError("VORBIS: missing capture pattern");
SDL : APP: INFO: __Sound_SetError("VOC: Wrong signature; not a VOC file.");
SDL : APP: INFO: __Sound_SetError("RAW: extension isn't explicitly "RAW".");
SDL : APP: INFO: __Sound_SetError("SHN: Not a SHN file");
SDL : APP: INFO: __Sound_SetError("FLAC: Not a FLAC stream.");
SDL : APP: INFO: __Sound_SetError("Sound format unsupported");
Quitting the game...
***** ENGINE HAS SHUTDOWN

That timidity file sources

source gravis.cfg source gsdrums.cfg source gssfx.cfg

which don't exist, which is weird i guess.

Commenting those, finally starts up timidity, but still no sound:


i3@sleipnir:~/Downloads/larry_test.ags$ TIMIDITY_CFG=/home/i3/Downloads/larry_test.ags/TIMIDITY/timidity.cfg /home/i3/Downloads/ags 
Adventure Game Studio v3.6 Interpreter
Copyright (c) 1999-2011 Chris Jones and 2011-2023 others
ACI version 3.6.0.44

Initializing backend libs
SDL Version: 2.24.1
Initializing game data
Located game data pak: /home/i3/Downloads/larry_test.ags/game.ags
Opened game data file: ac2game.dta
Game data version: 26
Compiled with: 2.61
Startup directory: /home/i3/Downloads/larry_test.ags
Data directory: /home/i3/Downloads/larry_test.ags/
Setting up game configuration
Unable to init voice pack 'speech.vox', file not found or of unknown format.
Initializing TTF renderer
Initializing mouse: number of buttons reported is 3
Install timer
Audio driver: pulseaudio
AudioCore: opened device "Default OpenAL playback device"

TIMIDITY_CFG= /home/i3/Downloads/larry_test.ags/TIMIDITY/timidity.cfg

init config file: /home/i3/Downloads/larry_test.ags/TIMIDITY/timidity.cfg

init_with_config Timidity result rc = 0
SDL : APP: INFO: Trying to open /home/i3/Downloads/larry_test.ags/TIMIDITY/timidity.cfg

read_config_file Timidity result rc = 0
Supported sound decoders:
 - MIDI decoder, using a subset of TiMidity : MIDI,MID,
 - Play modules through ModPlug : 669,AMF,AMS,DBM,DMF,DSM,FAR,GDM,IT,MDL,MED,MOD,MT2,MTM,OKT,PTM,PSM,S3M,STM,ULT,UMX,XM,
 - MPEG-1 Audio Layer I-III : MP3,MP2,MP1,
 - Microsoft WAVE audio format : WAV,
 - Audio Interchange File Format : AIFF,AIF,
 - Sun/NeXT audio file format : AU,
 - Ogg Vorbis audio : OGG,
 - Creative Labs Voice format : VOC,
 - Raw audio : RAW,
 - Shorten-compressed audio data : SHN,
 - Free Lossless Audio Codec : FLAC,FLA,
Install exit handler
Initialize legacy path finder library
Game title: 'Leisure Suit Larry 2'
Game uid (old format): `960365362`
Game guid: ''
Game GUI version: 105
WARNING: font 'agsfnt1.wfn' has mistakes in data format, some characters may be displayed incorrectly
Checking for disk space
Game native resolution: 320 x 200 (16 bit)
Graphic settings: driver: OGL, windowed: no, screen size: 0 x 0, game scale: proportional
Running OpenGL: 4.6
Graphics mode set: 1920 x 1080 (32-bit) fullscreen desktop
Mouse speed control: enabled, unit: 1.000000, user value: 1.000000
Touch-to-mouse motion mode: absolute
Multitasking mode set: 0
Setting up window
Multitasking mode set: 0
Initialize sprites
Engine initialization complete
Starting game
SDL : APP: INFO: Format: 1  Tracks: 11  Divisions: 192
SDL : APP: INFO: Track name: LSL2-20Theme
SDL : APP: INFO: Text: Generated by NoteWorthy Composer
SDL : APP: INFO: (Meta event type 0x58, length 4)
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: LEISURE SUIT LARRY 2
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: LEISURE SUIT LARRY 2-2
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Copyright (c)1988
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Copyright (c)1988-2
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Sierra On-Line, Inc.
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: ====================
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: FOR YOUR THIGHS ONLY
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Staff
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Staff-2
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Tempo Track
SDL : APP: INFO: Samples per delta-t: 114 (correction 55296)
SDL : APP: INFO: Samples per delta-t: 114 (correction 55296)
SDL : APP: INFO: No instrument mapped to tone bank 0, program 2 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to tone bank 0, program 24 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to tone bank 0, program 32 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to tone bank 0, program 45 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to tone bank 0, program 71 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to drum set 0, program 36 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to drum set 0, program 38 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to drum set 0, program 42 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to drum set 0, program 44 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to drum set 0, program 46 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to drum set 0, program 54 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to drum set 0, program 56 - this instrument will not be heard
SDL : APP: INFO: MIDI: Accepting data stream.
SDL : APP: INFO: New sample DESIRED format: S16LSB format, 44100 rate, 2 channels.
SDL : APP: INFO: New sample ACTUAL format: S16LSB format, 44100 rate, 2 channels.
SDL : APP: INFO: On-the-fly conversion: DISABLED.
SDL : APP: INFO: Format: 1  Tracks: 9  Divisions: 192
SDL : APP: INFO: Track name: LSL3 Pot Ledge
SDL : APP: INFO: Text: Generated by NoteWorthy Composer
SDL : APP: INFO: (Meta event type 0x58, length 4)
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Copyright (c)1989
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Copyright (c)1989-2
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Sierra On-Line, Inc.
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Sierra On-Line, Inc.-2
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: ====================
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Staff
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: PATTI, JUST SAY NO!
SDL : APP: INFO: (Meta event type 0x21, length 1)
SDL : APP: INFO: Track name: Tempo Track
SDL : APP: INFO: Samples per delta-t: 114 (correction 55296)
SDL : APP: INFO: Samples per delta-t: 153 (correction 8181)
SDL : APP: INFO: No instrument mapped to tone bank 0, program 73 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to tone bank 0, program 104 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to tone bank 0, program 117 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to drum set 0, program 60 - this instrument will not be heard
SDL : APP: INFO: No instrument mapped to drum set 0, program 61 - this instrument will not be heard
SDL : APP: INFO: MIDI: Accepting data stream.
SDL : APP: INFO: New sample DESIRED format: S16LSB format, 44100 rate, 2 channels.
SDL : APP: INFO: New sample ACTUAL format: S16LSB format, 44100 rate, 2 channels.
SDL : APP: INFO: On-the-fly conversion: DISABLED.
Quitting the game...
***** ENGINE HAS SHUTDOWN
i30817 commented 1 year ago

And btw the way, your test game crashes when larry enters the reception room at the TV studio. 'Error: String argument was null: make sure you pass a string, not an int, as a buffer'

ericoporto commented 1 year ago

game crashes when larry enters the reception room at the TV studio. 'Error: String argument was null: make sure you pass a string, not an int, as a buffer'

Thank you for this report, we need to check it out.

Also, thank you for the log messages @i30817, I think we need to wait for @ivan-mogilko, if he has any additional ideas. I will try reproduce the log messages in the meantime.

ivan-mogilko commented 1 year ago

And btw the way, your test game crashes when larry enters the reception room at the TV studio. 'Error: String argument was null: make sure you pass a string, not an int, as a buffer'

Could you please post a save made close to that location, or at least tell directions? I never played this game and don't know where the "TV studio" is.

i30817 commented 1 year ago

If you go north instead of east at the start it's 4 screens up until you reach a building with some stairs. Then enter the door there that shows a receptionist behind the glass. Well, when i wrote 'north' i actually mean 'the upper right corner' but you get it no? Follow the road.

Anway the room loads and shows but almost immediately crashes here.

ivan-mogilko commented 1 year ago

If you go north instead of east at the start it's 4 screens up until you reach a building with some stairs. Then enter the door there that shows a receptionist behind the glass. Well, when i wrote 'north' i actually mean 'the upper right corner' but you get it no? Follow the road.

Anway the room loads and shows but almost immediately crashes here.

Oh, alright, I reproduced that. Hmm yes, it looks like the script command tries to print some text into the null pointer instead of a buffer. I will have to investigate this separately.

ivan-mogilko commented 1 year ago

@i30817 in regards to LSL2, apparently the provided file has modified/repacked scripts that possibly broken something. The original game works: https://www.adventuregamestudio.co.uk/site/games/game/356-leisure-suit-larry-2-point-and-click-final-version-/

ivan-mogilko commented 1 year ago

Alright, meanwhile I've been working on resolving MIDI not playing on my linux vm. I did not use any of the downloads in this thread, nor updating SDL_Sound, but tried purely what I already had.

First of all, I said it wrong (somewhere above) that sdl_sound requires a manual install, it actually installs automatically if using its own cmake.

For some reason the Timidity component is disabled by default in its cmake. I don't know much about how to toggle options from command line, so simply modified cmakelists.txt for my purposes, and also added DEBUG_CHATTER there.

Latter allows to run ags with --lod-stdout=main:all,sdl:all --sdl-log=info and have debug messages from SDL_Sound (as they are all printed as "info" level).

My timidity pack was downloaded from the link, mentioned in our manual (it was posted by rofl0r previously in some other ticket), simply because i don't know any better.

Did export TIMIDITY_CFG=<path to timidity.cfg> and run the game. MIDI music works for me.

I might mention, that if timidity.cfg is located not in the same dir as instruments, then you have to edit "dir" command inside cfg. It seems (?) that you cannot have a relative path there if you like, at least my attempts failed (e.g. dir /instruments or dir instruments or dir ./instruments).

Hmm, well, that's all I found at the moment. I've been testing with "5 Days a Stranger (SE)" game.

i30817 commented 1 year ago

It's possible to have a relative command if you use the meta command 'dir $basedir\subdircontainingsamples

or something similar. I tried your soundfont now. That one works. Unlike the fluidsynth soundfonts or freepaths.

I kind of hate this randomness. The cfg is also completely different. The structure of the fluidsynth ones (well, first timidity.cfg pointed to another file, that's the one i posted)

This new one has a different approach and has a warning on the text:


# Timidity configuration file.
#
# This is a straight mapping of instrument to patch; it does not attempt
# to emulate a GUS configuration. It will therefore sound better than
# any of the timid{256,512,768,1024}.cfg configuration files. But if you
# want an "authentic" sounding experience or you're on a nostalgia trip
# you should probably use one of those.
#
# The instruments used are those listed in DMXGUSC.

I have to be honest, i have no clue what's going wrong with the more common soundfonts around for timidity and why they should not be used.

i30817 commented 1 year ago

At least i can confirm that selfcompiled ags works too, so the problem is likely in the soundfonts or the timidity.cfg installed by ubuntu.

I don't understand why no one else had this in the previously posted sound font (not this last one, the previous to that):

'SDL : APP: INFO: No instrument mapped to tone bank 0, program 2 - this instrument will not be heard'

i30817 commented 1 year ago

timidity.cfg not in one of the 'normal directories and just on the game directory doesn't work either, unlike the previous version of the MIDI player using allegro using patches.dat after the fixes you did to that when allegro was there.

i30817 commented 1 year ago

I honestly think it's SDL2 'refactoring' timidity may have broken compatibility with the older and more arcane file format / and or indirections in the fileformat.

If you compare the soundfont that worked here:

bank 0

0 acpiano
1 britepno
2 synpiano
3 honky

and the format of fluidsynth fluid3_gm.cfg (which can be indirected by timidity.cfg by uncommenting its corresponding 'source' line and commenting the others) :

bank 0
0 %font "FluidR3_GM.sf2" 0 0 amp=29 pan=0
1 %font "FluidR3_GM.sf2" 0 1 amp=41 pan=0
2 %font "FluidR3_GM.sf2" 0 2 amp=64 pan=0
3 %font "FluidR3_GM.sf2" 0 3 amp=32 pan=0

well... one is separate files, the other is a joined file (possibly a zip, or something else), one is using some metacommand %font and other things... i suspect this is the problem.

could also be that other soundfonts are being 'indirect' with the 'dir' and 'source' command. I already saw that nonexisted 'source' commands broke the recognition of 'support' for timidity on one of the cfgs (specifically when i had to comment 'sourcegravis.cfg' 'source gsdrums.cfg' and 'source gssfx.cfg' to get one to attempt to run (but still fail).

ericoporto commented 1 year ago

Random idea: @i30817 , can you confirm in your pat files there is only / as separator in the paths and no \ (windows separator)?

ivan-mogilko commented 1 year ago

I honestly think it's SDL2 'refactoring' timidity may have broken compatibility with the older and more arcane file format / and or indirections in the fileformat.

Well, we are using completely different sound loading library now, SDL_Sound (it's not directly a part of SDL2, but a separate lib). IMHO the problems of format parsing, and problems of not finding files may be considered SDL_Sound lib issues, and/or issues of the version of Timidity source that they are using. They may be reported as a bug or feature suggestions in their repository: https://github.com/icculus/sdl_sound We already opened one ticket there in regards to this. Maybe some of us could look into this too later and make a pr to them, when we get more spare time. For instance, I think being able to direct to a custom cfg file location is a must. Of course I don't know anything about the pat formats, so cannot imagine if it's difficult to add missing support to timidity.

The alternative would be to support MIDI loading ourselves, by embedding either that, or old allegro's code directly in the engine, and converted as necessary, and then having to maintain it altogether.

i30817 commented 1 year ago

Yeah, there are no \.

I did a small experiment with the soundfont that worked, and i'm preeeeety sure that at least the source command is broken, if not sure about the rest i mentioned in my last post.

Because i have a game tree like this:

. ├── game.ags ├── t2 │   ├── ...rest of soundfont files │   ├── timidity.cfg └── timidity.cfg

And the outer timidity is just 'souce t2/timidity.cfg'

Trying to load the outer: TIMIDITY_CFG=/home/i3/Downloads/larry_test.ags/timidity.cfg /home/i3/Downloads/ags

says it loads the inner later:


TIMIDITY_CFG= /home/i3/Downloads/larry_test.ags/timidity.cfg

init config file: /home/i3/Downloads/larry_test.ags/timidity.cfg

init_with_config Timidity result rc = 0
SDL : APP: INFO: Trying to open /home/i3/Downloads/larry_test.ags/timidity.cfg
SDL : APP: INFO: Trying to open t2/timidity.cfg

read_config_file Timidity result rc = 0

but later says:

SDL : APP: INFO: Trying to open /home/i3/Downloads/larry_test.ags/synpiano
SDL : APP: INFO: Could not open synpiano

notice the path forgetting about the subdirectory, like if the outer cfg was the right base path, not the inner one.

While loading the inner timidity.cfg loads it correctly and music plays

So, at least that is wrong. Oh well.

i30817 commented 1 year ago

I do think there is more wrong because i tried to load the 'source' files that the main timidity.cfg installed by soundfonts asks for with

TIMIDITY_CFG=/etc/timidity/fluidr3_gs.cfg /home/i3/Downloads/ags

and

TIMIDITY_CFG=/etc/timidity/fluidr3_gm.cfg /home/i3/Downloads/ags

and

TIMIDITY_CFG=/etc/timidity/timgm6mb.cfg /home/i3/Downloads/ags

and none of them worked. But now that i think about it, the same thing can be a problem because the first command of those files is:

dir /usr/share/sounds/sf2

another redirection, slightly different in that it's not a cfg file, but the same kind of operation to present the files in the file as relative to a path...

Although , the error actually mentioned in these cases for the ags that was provided in this thread is the strangely consistent:

SDL : APP: INFO: /etc/timidity/timgm6mb.cfg: line 6: bad patch option TimGM6mb.sf2

strange because it's always line 6 in all 3 sound fonts and line 6 doesn't appear special.

edit: no i lie, for gs it's line 5.

ivan-mogilko commented 1 year ago

I'm afraid there's alot of information in this thread already, but not much that we can do with this. From what I am capable to understand at this point, there may be 2 distinct problems:

  1. Not being able to find cfg in wanted locations. For example, engine cannot look for timidity.cfg in the game dir implicitly, without having TIMIDITY_CFG set.
  2. Timidity itself (integrated in SDL_Sound) fails to parse some of the cfg and/or patch syntax.

All of these issues currently relate to SDL_Sound/Timidity library. AGS engine itself does not participate in any of this.

I think we may open a ticket in their repo for at least the problem 1 (being able to tell where to look for timidity.cfg). In fact, we might even try to make a PR for them ourselves.

Regarding other, personally I don't have enough knowledge about the syntax or expected behavior, so I cannot do the same. So perhaps someone who understands this better could make respective bug/feature tickets in SDL_Sound repo, and let its author(s) and contributor(s) handle these.

Alternatives would be to either

ericoporto commented 1 year ago

I don't like the idea of telling where to look vs using SDL_rwops, because using SDL_rwops means we can actually run everything through our asset manager, so we get assets in Android, we get logging, we get the priority of where to look for things.

Telling where to look will just be inconsistent. And you already can do by leveraging SDL_setenv before SDL2_Sound is initialized. I think you also need to revert SDL_setenv when it quits, because SDL_setenv I think sets for the environment.

One thing to PR there is some better logging because it's terrible as is. Also if it's possible to use the SDL hint system instead of environment variables and have it have priority over everything and be possible to just NOT initialize it.

But it won't work consistently and you can't tell when it fails properly/why it fails properly.

ivan-mogilko commented 1 year ago

And you already can do by leveraging SDL_setenv before SDL2_Sound is initialized

Hm, this sounds like this may be used as a hotfix for desktop at least.

ericoporto commented 1 year ago

The only problem with setenv that I don't know if it's a problem or if it's a problem in some platforms is how the env is persisted after the application exits or if it's persisted at all.

ivan-mogilko commented 1 year ago

Ah, no, I remembered why this may be a bad idea: because in that case the user's env variable won't be used. We cannot ask to search in local dir, and then search in whatever user had set before running the game. This could be done only if there were a separate setting provided in SDL_Sound API; either a function or a SDL-style hint.

i30817 commented 1 year ago

Frankly, as it is now, it's unusable anyway, unless i want to make a mess/annoy myself.

To have sound here i'd either to have to remember to set the env var every time, or place the directory contents of the one soundfont that worked on the etc/timidity dir (horrible idea), or place the contents of the soundfont + timidity.cfg on the game directory root.

If i was a completely clueless user, i'd have no clue about this, so you just know almost everyone has it broken.

I'd actually prefer using the env variable as a temporary hotfix, to prevent the 'mess', if the 'hotfix' canonized a alternate relative 'timidity dir' to place in the env variable that is under the current game directory (or current directory rather, which I guess is not the same thing all the time - edit, actually in linux it kind of is, because the ags executable is not in the game directory so the only way to find the data is to start ags in the game directory).

Very annoying, especially after allegro finally working.

I suspect that SDL_audio didn't exactly test or expect this to be used yet.