Skip to content

Music Code Cleanup

mazmazz requested to merge public-music-cleanup into master

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 variables midi_disabled digital_disabled sound_disabled
  • I separated S_Init into S_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 and I_PlaySong.
    • I_StopDigSong = I_UnloadSong and I_StopSong.
  • 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.
  • 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.)

Merge request reports