Skip to content

MusicPlus feature: Post Jingle music resume

mazmazz requested to merge public-musicplus-jingle into next

Resume music after a jingle, with jingle length taken into account. Can play multiple jingles and the game will remember the resume position of each one.

Video

Implementation

  • A section in s_sound is devoted to music_stack, a next/prev chain of musicstack_t structs that store music, position, and powerup status.
  • Public methods S_RetainMusic() and S_RecallMusic() work the magic
  • The idea is:
    • The level music is always first (oldest) on the stack.
    • When playing a jingle, register that entry on the stack.
    • When P_RestoreMusic is called, check the stack in order of jingle priority: Super, Invincibility, Speed Shoes.
    • If none of those statuses are in effect, then go down the entire stack from newest to oldest.
    • When a matching entry is in effect, play that music.
  • For the resume skipping to work (old_position + jingle_length), the game must know the song length, which SDL Mixer cannot retrieve. Instead, the music is tagged with LENGTHMS=xxxxx as a workaround.
    • If this tag is missing and the length is not known, then music resumes to the old position without skipping

Music Length Tagger

In order to work properly, music must be tagged with LENGTHMS=. Use this utility to automatically tag music in a given WADfile.

musicplus-demo on Windows does not need this because it uses SDL Mixer X to tell song length. This branch, all other branches, and Linux, need this tag.

Edited by mazmazz

Merge request reports

Loading