Jump to content

In-game music player


vedan

Recommended Posts

Hi,

 

there are many awesome music collections for Doom, yet no possibility to change a song while playing.

 

BUT:

// MUSIC PLAYER ============================================================================

bool muted = FALSE;
bool fading = FALSE;
int song = -1;
int volume = 1.0;
int percent = 100;

script "SetTrack" (void) { // SetTrack
   if (song < 0) {song = 32;}
   if (song >= 33) {song = 0;}
   str songs[33][2] = {
      {"d_dm2ttl", "Doom Title"},
      {"d_dead", "The Demon's Dead"},
      {"d_doom2", "Doom 2"},
      {"d_read_m", "Text Screen"},
      {"d_stalks", "The Healer Stalks 1"},
      {"d_stlks2", "The Healer Stalks 2"},
      {"d_doom", "Doom 1"},
      {"d_countd", "Countdown to Death"},
      {"d_theda2", "In the Dark 2"},
      {"d_openin", "Opening to Hell"},
      {"d_shawn", "Shawn's got the Shotgun 1"},
      {"d_shawn2", "Shawn's got the Shotgun 2"},
      {"d_the_da", "In the Dark 1"},
      {"d_ultima", "The Ultimate Challenge"},
      {"d_count2", "Countdown to Death 2"},
      {"d_in_cit", "Into Sandy's City"},
      {"d_messag", "Message for the Archvile 1"},
      {"d_runni2", "Running From Evil 2"},
      {"d_messg2", "Message for the Archvile 2"},
      {"d_dead2", "The Demon's Dead 2"},
      {"d_tense", "Getting too Tense"},
      {"d_theda3", "In the Dark 3"},
      {"d_adrian", "Adrian's Asleep"},
      {"d_betwee", "Between Levels"},
      {"d_ddtblu", "The Dave D. Taylor Blues 1"},
      {"d_ddtbl3", "The Dave D. Taylor Blues 3"},
      {"d_stlks3", "The Healer Stalks 3"},
      {"d_ddtbl2", "The Dave D. Taylor Blues 2"},
      {"d_shawn3", "Shawn's got the Shotgun 3"},
      {"d_ampie", "Bye bye American Pie"},
      {"d_romer2", "Waiting for Romero to Play 2"},
      {"d_romero", "Waiting for Romero to Play 1"},
      {"d_evil", "Evil Incarnate"}      
   };
   print(s:"Track ", d: song + 1, s:"\n", s:songs[song][1] , s:", (", s:songs[song][0], s:")");
   SetMusic(songs[song][0]);
}

script "NextTrack" (void) { // NextTrack
   if (!fading) {
      song += 1;
      muted = FALSE;
      ACS_NamedSuspend("FadeOut", 0);
      SetMusicVolume(volume);
      ACS_NamedExecute("SetTrack", 0, 0);
   }
}

script "UnMute" (void) { // UnMute
   if (muted == FALSE) {
      fading = TRUE;
      print(s:"Music muted");
      ACS_NamedExecute("FadeOut", 0, 0);
      muted = TRUE;
   } else {
      fading = false;
      SetMusicVolume(volume);
      print(s:"Music unmuted");
      muted = FALSE;
   }
}

script "PrevTrack" (void) { // PrevTrack
   if (!fading) {
      song -= 1;
      muted = FALSE;
      ACS_NamedSuspend("FadeOut", 0);
      SetMusicVolume(volume);
      ACS_NamedExecute("SetTrack", 0, 0);
   }
}

script "FadeOut" (void) { // Fade out
   int fadevolume = volume;
   while (fading) {
      if (fadevolume > 0.0) {
         fadevolume -= 0.1;
         SetMusicVolume(fadevolume);
         Delay(1);
      } else {
         fading = false;
         break;
      }
   }
}

script "IncVolume" (void) { // Increase volume
   muted = FALSE;
   if (volume <= 1.0) {
      volume += 0.1;
      percent += 10;
      if (volume > 1.0) {
         volume = 1.0;
         percent = 100;
      }
      SetMusicVolume(volume);
      print(s:"Volume now at ", i:percent, s:"%");
   }
}

script "DecVolume" (void) { // Decrease volume
   muted = FALSE;
   if (volume > 0.0) {
      volume -= 0.1;
      percent -= 10;
      if (volume < 0.0) {
         volume = 0.0;
         percent = 0;
      }
      SetMusicVolume(volume);
      print(s:"Volume now at ", i:percent, s:"%");
   }
}

// =========================================================================================

Create a KEYCONF.txt for your custom pk3 resource file and add this:

addmenukey "PrevTrack" PrevTrack
alias PrevTrack "pukename PrevTrack"
defaultbind KP1 "PrevTrack"

addmenukey "UnMute" UnMute
alias UnMute "pukename UnMute"
defaultbind KP2 "UnMute"

addmenukey "NextTrack" NextTrack
alias NextTrack "pukename NextTrack"
defaultbind KP3 "NextTrack"

addmenukey "IncVolume" Incvolume
alias Incvolume "pukename Incvolume"
defaultbind KP+ "Incvolume"

addmenukey "DecVolume" DecVolume
alias DecVolume "pukename DecVolume"
defaultbind KP- "DecVolume"

Thanks to Enjay for his feedback.

 

Credits go to Naniyue (according to this zdoom forum entry) for the inspiration.


...and OF COURSE, I just found what I was originally looking for in the first place: Jimmy's Jukebox

Edited by vedan

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...