swars
swars copied to clipboard
Tension music does not play
As far as I know, this is a known issue with the port and has always been the case, since the vexillium version.
This needs investigating - MIDI playback is not functional in the port. Maybe there's a working MIDI playback in Magic Carpet HD? Then similar solution could be used for SW Port.
This would be easier if we had sound library separated from the rest: https://github.com/mefistotelis/swars/issues/20
The playback from Magic Carpet is based on SDL_mixer; SW Port uses OpenAL. But it looks like playing XMI files using OpenAL is an issue which was also solved already. One interesting discussion is here: https://github.com/Interrupt/systemshock/issues/14
Examples for converting XMI to MIDI and playing via SDL_Mixer:
https://github.com/turican0/remc2/blob/development/remc2/engine/AIL_stub.cpp#L6141 https://github.com/TinyRetroWarehouse/SR/blob/59d0b5311498b7254dd0d61871cf3edf402a7aa9/games/Warcraft/SR-War/Warcraft-music-midiplugin2.c#L205 https://github.com/TinyRetroWarehouse/SR/blob/master/games/Albion/SR-Main/Albion-music-midiplugin.c#L889
Example of synthesizing XMI via AdlMIDI and playing via SDL_Mixer: https://github.com/Interrupt/systemshock/compare/master...adlmidi-xmi
Example of synthesizing XMI via WildMIDI and using OpenAL: https://github.com/afritz1/OpenTESArena/blob/458a284844883496d64e163708a5197e71c733ee/OpenTESArena/src/Media/AudioManager.cpp#L123
Here is a project with support of a lot different ways of synthesizing, either on OS driver or by software; if by software, it uses SDL to play: https://github.com/exult/exult/blob/master/audio/midi_drivers/XMidiFile.h
The plan:
- Rewrite all AIL API functions related to playing MIDIs
- Prepare OpenAL part of the playback (sound sources, buffers, etc), play a generated tone or sample as a test
- Add MIDI software synth library to build system (WildMIDI or AdlMIDI)
- Implement directing MIDI data buffers to SW synth lib, and sending output to OpenAL
- Fix volume, tempo and general state control for the MIDI sequences
Current status: (1) is done.
Status update: (2) is done.
(3) is done. Though WildMIDI requires external music samples to work, which adds another point:
4b. Include selected PAT instruments in SW conf
Done with 4 and 4b.
The track doesn't loop though, so stops after one play.
The track now loops, volume changes properly.
The original code provided some variation to the danger music by enabling various effects, changing tempo and pitch based on some playback parameters. But these were barely audible anyway, so not going to implement that as part of this issue.
Also more / better matching instruments could be added, but that doesn't require programming, just messing with midipats.cfg
.
So, all done.