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

3.6.0: solution for playing MIDI on Windows #1649

Closed
ivan-mogilko opened this issue May 3, 2022 · 9 comments
Closed

3.6.0: solution for playing MIDI on Windows #1649

ivan-mogilko opened this issue May 3, 2022 · 9 comments
Milestone

Comments

@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented May 3, 2022

From what I can tell, SDL_Sound initializes MIDI decoder only if it can load up timidity.cfg. It may look into standard path, or a path taken from enviroment variable, which we could perhaps set ourselves or through config, but that's not the point. The biggest issue is that this requires users/players to have something extra installed along with the engine or game to be able to hear midi music.

What are the potential workarounds here? What kind of data does timidity.cfg contain (I have no knowledge of that, so need to research this myself first)? Does it depend on system, or there could be a universal config? May it be a clever move to provide timidity.cfg as an embedded resource along with the windows engine exe?
(BTW, it seems like SDL_Sound does not support passing a custom rwops with this config, so currently it requires a config file on disk... unless there's a way to make it read from memory which I missed.)

@ivan-mogilko ivan-mogilko added this to the 3.6.0 milestone May 3, 2022
@ericoporto
Copy link
Member

ericoporto commented May 24, 2022

The biggest issue is that this requires users/players to have something extra installed along with the engine or game to be able to hear midi music.

Windows has two MIDI APIs and has a MIDI playback device. We could use it, but this means the sound won't be played by whatever is the current SDL2 audio device on Windows. This was how allegro accomplished MIDI playback on Windows.

Also this may frustrate developers that use MIDI instead one of the tens of possible other mod audio formats when they are going to port their game to any other system and realize their music doesn't work there...

@ivan-mogilko
Copy link
Contributor Author

Also this may frustrate developers that use MIDI instead one of the tens of possible other mod audio formats when they are going to port their game to any other system and realize their music doesn't work there...

Why would not it work there?

@ericoporto
Copy link
Member

because it will require a soundfont :/

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented May 24, 2022

How does it work on other systems now?

@ericoporto
Copy link
Member

ericoporto commented May 24, 2022

Well, you can verify on Windows itself: TIMIDITY.zip

extract this zip in Windows, place it so you have the following structure C:\TIMIDITY\instruments, where instruments contains a bunch of .pat files. Now play some game with midi or just use your own midi file, here's one: prepare_your_swords.mid.zip

Problem is, I need to find some other Timidity compatible standalone sound player - VLC plays midi using FluidSynth sf2 soundfont, a different format. Using one timidity based music player would make it possible to verify if the sound font file is alright or not.

Edit: I can reproduce the weird sound using only SDL_sound and SDL2, using the playsound_simple little program that comes with it...

Edit2: ok, I can't reproduce if I upgrade the SDL2 sound version... So it's time to upgrade it! Opened #1668 , please verify.

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Jun 10, 2022

Well, you can verify on Windows itself: TIMIDITY.zip

This technically works, although in the few old ags games I tried some instruments were not playing at all (necessary data not present?).

UPDATE: okay, I got much better results using the patches from this comment by @rofl0r :
#367 (comment)
(e.g. link http://www.gamers.org/pub/idgames/music/dgguspat.zip)

i'm not educated enough in this topic to compare files, so was judging by the sounds in game. I guess in the end it is a matter of gathering and maintaining a good "instruments" folder.

@ericoporto
Copy link
Member

ericoporto commented Jun 13, 2022

When MIDI timidity config and soundfont RW_ops gets implemented in SDL_sound (icculus/SDL_sound#69) it would be possible for a game to ship it's own "instruments" theoretically.

@ivan-mogilko
Copy link
Contributor Author

Alright, so, after experimenting, it's established that you have to have timidity config and sound patches (instrument bank) either installed in the system (path depends on a system) or inside the current working dir (game dir normally). There's no other way currently.

This is a regression for the Windows engine, but this brings it in compliance with the rest of the ports.

I think this must be documented in the manual, after which this issue may be closed.

@ivan-mogilko
Copy link
Contributor Author

Added a simple article to the manual: https://github.com/adventuregamestudio/ags-manual/wiki/MIDI-playback

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

No branches or pull requests

2 participants