Music Code Cleanup
The music code was a freaking mess because it had different methods for digital and MIDI playback; redundant variables; and unclear separation for loading, playing, stopping, and unloading.
This is all internal plumbing, no user-facing changes (other than small sound menu tweaks.) Nothing that affects netsync because audio is not shared.
Changes
- I combined all digital/MIDI methods
-
nomidimusic nodigimusic nosound
are merged into the existing variablesmidi_disabled digital_disabled sound_disabled
- I separated
S_Init
intoS_InitSfxChannels
- I clearly separated playback and loading concerns
- Internally, loading and playing a song are now called separately (
S_ChangeMusic
calls both) - Currently, stopping a song will also auto-unload it. I have plans to change this so that multiple music can be loaded at one time, but that's another MR.
-
I_PlayDigSong
=I_LoadSong
andI_PlaySong
. -
I_StopDigSong
=I_UnloadSong
andI_StopSong
.
- Internally, loading and playing a song are now called separately (
- New helper functions for music state
-
I_SongType
- Returns format of music I_SongPlaying
I_SongPaused
-
- New
s_sound
helper functions-
S_DigMusicDisabled
,S_MIDIMusicDisabled
,S_MusicDisabled
-
S_MusicPlaying
,S_MusicPaused
,S_MusicType
-
S_MusicInfo
- Returns current name, flags, and looping -
S_MusicExists
- Checks wadfiles for existing music name
-
- I ripped out SDL Mixer code in
sdl_sound.c
because it's never invoked.- The file is only used when you build with
NOMIXER=1
. The music code is hidden under#ifdef HAVE_MIXER
, and so that build never plays music.
- The file is only used when you build with
- Menu tweaks
- When toggling music, play the level music instead of the clear jingle
- When toggling digital/MIDI, play music automatically if a digital or MIDI track exists
Implementation
The only things that remain separate between digital/MIDI is toggling and volume. The Win32 MIDI volume hack is still in effect.
I conformed the other targets (DOS, DirectX/FMOD, Dummy, etc.) as best as I could. DirectX and NOMIXER=1
both build. Some targets have been unchanged because they're removed from 2.2 (like XBOX.)