Interrupt / systemshock

Shockolate - A minimalist and cross platform System Shock source port.
GNU General Public License v3.0
811 stars 66 forks source link

Play music #185

Closed donnierussellii closed 6 years ago

donnierussellii commented 6 years ago

This work is based on Interrupt's adl-mark-2 branch and my multithreaded ReadXMI code, which is based on SSPLAYER ( https://wenchy.net/old/shock.html ).

The music ai is preserved from master, with tweaked adl code added in and a rewritten/cleaned up setup.c for looping title and credits music.

This reads midi messages from XMI files (and track numbers from BIN files), sends the messages to adlmidi, which fills a stream buffer that is sent to SDL audio. Buffer size is 2048. 4096 causes uneven notes.

Added code to repeat shorter pieces while longer superchunk plays.

Note that setup.c is heavily edited, but care was taken.

Interrupt commented 6 years ago

This is sounding a lot better! I think we can merge this in soon. A few issues I noticed:

donnierussellii commented 6 years ago

Totally forgot the volume ducking. It seems to work now.

Interrupt commented 6 years ago

The AppVeyor CI build is failing for some reason on this PR, the error is:

C:/projects/systemshock/src/Libraries/adlmidi/chips/dosbox/dbopl.cpp:1584:65: error: 'INT16_MAX' was not declared in this scope
   out[i] = static_cast<Bit16s>(DBOPL_CLAMP(out32[i], INT16_MIN, INT16_MAX));

Doing some searching online it sounds like we may need to specifically add -D__STDC_LIMIT_MACROS to the cmake DCMAKE_CXX_FLAGS

Interrupt commented 6 years ago

I'm sure there is more we can do to make the music playback even better, but for now this is a solid start! ✨ 🎧 ✨