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 nosoundare merged into the existing variablesmidi_disabled digital_disabled sound_disabled - I separated
S_InitintoS_InitSfxChannels - I clearly separated playback and loading concerns
- Internally, loading and playing a song are now called separately (
S_ChangeMusiccalls 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_LoadSongandI_PlaySong. -
I_StopDigSong=I_UnloadSongandI_StopSong.
- Internally, loading and playing a song are now called separately (
- New helper functions for music state
-
I_SongType- Returns format of music I_SongPlayingI_SongPaused
-
- New
s_soundhelper 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.cbecause 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.)