-
Notifications
You must be signed in to change notification settings - Fork 160
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
Comments
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... |
Why would not it work there? |
because it will require a soundfont :/ |
How does it work on other systems now? |
Well, you can verify on Windows itself: TIMIDITY.zip extract this zip in Windows, place it so you have the following structure 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. |
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 : 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. |
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. |
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. |
Added a simple article to the manual: https://github.com/adventuregamestudio/ags-manual/wiki/MIDI-playback |
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.)
The text was updated successfully, but these errors were encountered: