Chaosforge Forum

  • April 18, 2024, 02:09
  • Welcome, Guest
Please login or register.



Login with username, password and session length
Pages: 1 2 [All]

Author Topic: More music?  (Read 14644 times)

Pabbicus

  • Private FC
  • *
  • Offline Offline
  • Posts: 5
  • Lost Soul
    • View Profile
More music?
« on: October 08, 2011, 15:19 »

I love listening to 8-bit versions of my favorite music, and I had the idea that some of them could be used in DoomRL. Yay or nay?

This gave me the idea.
Logged

Malek Deneith

  • Grand Inquisitor Emeritus
  • Grand Inquisitor
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1256
    • View Profile
Re: More music?
« Reply #1 on: October 08, 2011, 15:37 »

If you have the music you'd want to see... err, hear in-game in a proper format (mp3, wav, mid, ogg should work, some other formats probably also) then just copy the file to music subfolder and then edit the relevant lua (music.lua if you're using the default midi music, you can open it up with a notepad) and change the bindings for a level of your choice. For example I, instead of:
Code: [Select]
spec3     = "music/hells_weapons.mid",have
Code: [Select]
spec3     = "newmp3/TNT - Metal.mp3",in my lua, thus changing what music plays in Hell's Armory :)
Logged
Inquisition - saving your soul, one bolter shell at a time.
Spoiler: "Hackmaster Kills" (click to show/hide)

Angles of death

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 198
  • HOLD. DEVILS. POT OF TEA!
    • View Profile
Re: More music?
« Reply #2 on: October 08, 2011, 17:13 »

That sounds surprisingly Doomy. Great music, by the way.

I say yes. We need more metal!
Logged
...........A...A....M...A.....V
......V.............@......A..>
........V....V..C....B....B..A
Take a look to the sky just before you die it's the last time he will!!!

ParaSait

  • Baffen :P
  • Elder
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1229
  • Happy Little Boozer
    • View Profile
    • MPSF
Re: More music?
« Reply #3 on: October 08, 2011, 17:17 »

Can't play any game without my trance playlist, personally. :P

Also this thread gave me the idea to use this handy tool on the game's tracks. :D Should try it sometime.
Logged
[18|7|3|0|0|0] [MED:13/43] [SPE:36/67] [ASM:11/40]

Check out my epic youtube channel!
Currently playing The Bard's Tale and System Shock 2 (coop with GrAV1t)!

Pabbicus

  • Private FC
  • *
  • Offline Offline
  • Posts: 5
  • Lost Soul
    • View Profile
Re: More music?
« Reply #4 on: October 09, 2011, 01:55 »

If you have the music you'd want to see... err, hear in-game in a proper format (mp3, wav, mid, ogg should work, some other formats probably also) then just copy the file to music subfolder and then edit the relevant lua (music.lua if you're using the default midi music, you can open it up with a notepad) and change the bindings for a level of your choice. For example I, instead of:
Code: [Select]
spec3     = "music/hells_weapons.mid",have
Code: [Select]
spec3     = "newmp3/TNT - Metal.mp3",in my lua, thus changing what music plays in Hell's Armory :)

Is there any way to add something to a sort of playlist? Say, instead of it just playing the 2-3 different tracks it plays for the random floors, it plays them at random? I'm not well-versed in DoomRL's coding, but I have played around with a bit more "advanced" games like, well, most games made by Paradox.
Logged

Malek Deneith

  • Grand Inquisitor Emeritus
  • Grand Inquisitor
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1256
    • View Profile
Re: More music?
« Reply #5 on: October 09, 2011, 11:57 »

Not at the current moment as far as I'm aware. There was a plan for an sound API rework, and one of ideas pitched for that rework was something like what you're asking about, but currently it's uncertain will said rework be done or not.
Logged
Inquisition - saving your soul, one bolter shell at a time.
Spoiler: "Hackmaster Kills" (click to show/hide)

Game Hunter

  • Programmer
  • Local Inquisitor
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1044
  • Looks like game to me.
    • View Profile
    • Channel, the Roguelike
Re: More music?
« Reply #6 on: October 09, 2011, 12:23 »

Is there any way to add something to a sort of playlist? Say, instead of it just playing the 2-3 different tracks it plays for the random floors, it plays them at random? I'm not well-versed in DoomRL's coding, but I have played around with a bit more "advanced" games like, well, most games made by Paradox.

Before, when I didn't have modding experience, I didn't think randomizing music was possible. However, now that I know how to write this sort of thing in lua, I tried constructing a function of it and, upon testing, found it to work just fine. Here's what you need to do:

Create a table for all your songs, using the same pathname that you'd use in the music configuration file. Here's an example using all the default music from randomly-generated levels:
Code: [Select]

local playlist = {
"music/11 - hangar.mid",
"music/12 - nuclear plant.mid",
"music/13 - toxin refinery.mid",
"music/14 - command control.mid",
"music/15 - phobos lab.mid",
"music/16 - central processing.mid",
"music/17 - computer station.mid",
"music/19 - military base.mid",
"music/22 - containment area.mid",
"music/24 - deimos lab.mid",
"music/26 - halls of the damned.mid",
"music/27 - spawning vats.mid",
"music/32 - slough of despair.mid",
"music/33 - pandemonium.mid",
}

The function (given below), called rand_music(music_array,song_num), takes in a playlist (replace music_array with the variable name of the playlist) and returns a randomized table of that playlist. song_num indicates how large we want the randomized playlist to be, so you can have a random playlist smaller or bigger than the input playlist itself.

Code: [Select]
local function rand_music(music_array,song_num)
local song_tot = table.maxn(music_array)
local song_count = 0
local music_list = {}
for i=1,math.ceil(song_num/song_tot) do
local loop_itr = math.min(song_tot,song_num)
song_num = song_num - song_tot
local song_list = music_array
for j=1,loop_itr do
idx = math.random(song_tot-j+1)
song = song_list[idx]
music_list[song_count] = song
table.remove(song_list,j)
song_count = song_count + 1
end
end
return(music_list)
end

Finally, we call the function using the playlist we created:

Code: [Select]
local mus = rand_music(playlist,22)

The output, in this case mus, should be called for each level that you want to include randomized music for. Ideally, you want to create a randomized playlist of the same size as the number of levels you want randomized music for. Additionally, you can create several playlists in this manner (for instance, one playlist for random levels and one for the special levels).

Attached to this post is an example music.lua file, fully commented, that includes everything mentioned above, as well as an example of the Music{} table that makes use of the randomized playlist.
Logged
I'm just a dude playing a dude disguised as another dude.

Latest LPs: Angband, Delver

thelaptop

  • Chaos Fanatic!
  • Grand Inquisitor
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 2530
    • View Profile
Re: More music?
« Reply #7 on: March 24, 2012, 19:49 »

Unlocked due to some demand on wanting to ask questions on how this can be done.
Logged
I computed, therefore I was.

Brewtal Legend

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 162
  • I am Hellbound
    • View Profile
Re: More music?
« Reply #8 on: March 24, 2012, 19:59 »

Thanks Laptop

Anyone actually use this?

I'm having trouble understanding exactly how to implement the random music.

Do I add these into my main music config?

Do I put "local mus = rand_music(playlist,22)" where the music track would ordinarily be placed? What's the "22" for?
Logged
-Legend

Game Hunter

  • Programmer
  • Local Inquisitor
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1044
  • Looks like game to me.
    • View Profile
    • Channel, the Roguelike
Re: More music?
« Reply #9 on: March 25, 2012, 12:25 »

There's a music.lua file attached to the post: for people who work best with examples, it's probably your best bet to figure it out. Otherwise:

  • Copy the rand_music function at the beginning of your music.lua file (or whichever one you use).
  • Create a array that contains all of the songs you want in the playlist. (See the first code, "local playlist = ...", as an example.)
  • In order to create the randomized playlist, call the function rand_music and output it to a local variable. The first argument is the playlist array you created, and the second argument is the length of the randomized playlist you're making (if this value is more than the actual playlist, then songs will be repeated after everything plays once).
  • For each level in the game that you wanted a song to be random, add one of the randomized playlist elements in place of what's usually there. For instance, if your call to rand_music looks like "local mus = rand_music(playlist,22)", then mus is a 22-element array, from mus[1] to mus[22], and each to-be-randomized level should have a different element from that array.

I hope this clears anything up. There are comments in the example file, as well.
Logged
I'm just a dude playing a dude disguised as another dude.

Latest LPs: Angband, Delver

Brewtal Legend

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 162
  • I am Hellbound
    • View Profile
Re: More music?
« Reply #10 on: March 31, 2012, 17:50 »

What if I want more than one list? For instance, I want to play 1 of three different songs for the title screen, random songs from one list for each of the regular levels, random songs from a different list for special levels, and a smaller list for boss levels?

Would I have to create several different rand_music functions?
Logged
-Legend

Game Hunter

  • Programmer
  • Local Inquisitor
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1044
  • Looks like game to me.
    • View Profile
    • Channel, the Roguelike
Re: More music?
« Reply #11 on: March 31, 2012, 19:22 »

What if I want more than one list? For instance, I want to play 1 of three different songs for the title screen, random songs from one list for each of the regular levels, random songs from a different list for special levels, and a smaller list for boss levels?

If you want multiple playlists, just create multiple input playlists and output them as multiple randomized playlists. For example:

Code: [Select]
local title_playlist = { song1_path, song2_path, song3_path }
local reg_playlist = { a bunch of songs }
local spec_playlist = { a bunch of other songs }
local boss_playlist = { even more songs }

local titlemus = rand_music(title_playlist, 1)
local regmus = rand_music(reg_playlist, 20)
local specmus = rand_music(spec_playlist, 12)
local bossmus = rand_music(boss_playlist, 4)

The number for specmus includes Phobos Base Entry and all 11 other special levels. Other than that, there are 20 "regular" levels (six in E1, seven each in E2 and E3), four boss levels (including HF), and the title. I think that covers everything! (Note that the "level8", "level16", and "level24" are probably never used in a normal game due to being replaced by boss levels, but you may want to include them anyway since they might be part of the music in A100 games. In this case, you'll want regmus to be 23 songs instead of 20.)
Logged
I'm just a dude playing a dude disguised as another dude.

Latest LPs: Angband, Delver

Brewtal Legend

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 162
  • I am Hellbound
    • View Profile
Re: More music?
« Reply #12 on: April 17, 2012, 13:41 »

Finally got around to trying this out.

Are interlude and  hellgate still used? Intro is the phobos base entry level right?

This is what I have right now. About to try it in a minute:

Code: [Select]
-- You can get much higher quality Doom MP3 tracks from
-- http://www.sirgalahad.org/paul/doom/
-- To use them, edit config.lua, and change music.lua to musicmp3.lua
-- MP3's need to be put in a directory named mp3.

--music_array is a table of pathnames to songs (like what you'd put in

Music{})
--song_num is the total number of songs you want to output (size of

playlist)
local function rand_music(music_array,song_num)
local song_tot = table.maxn(music_array)
local song_count = 0
local music_list = {}
--if song_num > music_array, we want to loop through
--randomization of the array more than once
for i=1,math.ceil(song_num/song_tot) do
--if song_num < music_array, we want to loop less than

the full playlist
local loop_itr = math.min(song_tot,song_num)
song_num = song_num - song_tot
--make a temporary array of music
local song_list = music_array
for j=1,loop_itr do
--pick a random song from the temporary array...
idx = math.random(song_tot-j+1)
song = song_list[idx]
--...add it to the playlist...
music_list[song_count] = song
--...and remove it from the temporary array
table.remove(song_list,j)
song_count = song_count + 1
end
end
return(music_list)
end

local title_playlist = {
"mp3/PSX_Doom_Music/doom_titlescreen.mp3",
"mp3/cdoom.mp3",
"mp3/doom3.mp3",
"DSoP_00_WelcomeToHell(Intro).mp3",
}

local reg_playlist = {
"mp3/PSX_Doom_Music/doom_01hangar.mp3",
"mp3/PSX_Doom_Music/doom_02plant.mp3",
"mp3/PSX_Doom_Music/doom_03toxinrefinery.mp3",
"mp3/PSX_Doom_Music/doom_04commandcontrol.mp3",
"mp3/PSX_Doom_Music/doom_05phoboslab.mp3",
"mp3/PSX_Doom_Music/doom_06centralprocessing.mp3",
"mp3/PSX_Doom_Music/doom_07computerstation.mp3",
"mp3/PSX_Doom_Music/doom_08phobosanomaly.mp3",
"mp3/PSX_Doom_Music/doom_09deimosanomaly.mp3",
"mp3/PSX_Doom_Music/doom_10containmentarea.mp3",
"mp3/PSX_Doom_Music/doom_11refinery.mp3",
"mp3/PSX_Doom_Music/doom_12deimoslab.mp3",
"mp3/PSX_Doom_Music/doom_13commandcenter.mp3",
"mp3/PSX_Doom_Music/doom_16hellgate.mp3",
"mp3/PSX_Doom_Music/doom_17hellkeep.mp3",
"mp3/PSX_Doom_Music/doom_18pandemonium.mp3",
"mp3/PSX_Doom_Music/doom_22limbo.mp3",
"mp3/PSX_Doom_Music/doom_20unholycathedral.mp3",
"mp3/PSX_Doom_Music/doom_21mterebus.mp3",
"mp3/PSX_Doom_Music/doom_24hellbeneath.mp3",
"mp3/PSX_Doom_Music/fdoom_01attack.mp3",
"mp3/PSX_Doom_Music/fdoom_02virgil.mp3",
"mp3/PSX_Doom_Music/fdoom_03canyon.mp3",
"mp3/PSX_Doom_Music/fdoom_04combine.mp3",
"mp3/PSX_Doom_Music/fdoom_05catwalk.mp3",
"mp3/PSX_Doom_Music/fdoom_06fistula.mp3",
"mp3/PSX_Doom_Music/fdoom_07geryon.mp3",
"mp3/PSX_Doom_Music/fdoom_08minos.mp3",
"mp3/PSX_Doom_Music/fdoom_09nessus.mp3",
"mp3/PSX_Doom_Music/fdoom_10paradox.mp3",
}

local spec_playlist = {
"mp3/e1m1.mp3",
"mp3/e1m2.mp3",
"mp3/e1m3.mp3",
"mp3/e1m4.mp3",
"mp3/e1m5.mp3",
"mp3/e1m6.mp3",
"mp3/e1m7.mp3",
"mp3/e1m8.mp3",
"mp3/e1m9.mp3",
"mp3/Hangarmageddon.mp3",
"mp3/PA01Quake_Theme.mp3",
"mp3/Animal_Acoustic.mp3",
}

local boss_playlist = {
"mp3/PSX_Doom_Music/doom_credits.mp3",
"mp3/PSX_Doom_Music/final_doom_end.mp3",
"mp3/PSX_Doom_Music/psx_main_menu.mp3",
"mp3/PSX_Doom_Music/PSX_stats_screen.mp3",
}


Music = {
start     = rand_music(title_playlist, 1),
interlude = "mp3/PSX_Doom_Music/fdoom_04combine.mp3",
bunny     = "mp3/d2end.mp3",
intro     = "mp3/DSoP_00_WelcomeToHell(Intro).mp3",
hellgate  = "mp3/PSX_Doom_Music/doom_credits.mp3",

level2    = rand_music(reg_playlist, 20),
level3    = rand_music(reg_playlist, 20),
level4    = rand_music(reg_playlist, 20),
level5    = rand_music(reg_playlist, 20),
level6    = rand_music(reg_playlist, 20),
level7    = rand_music(reg_playlist, 20),
level8    = rand_music(reg_playlist, 20),
level9    = rand_music(reg_playlist, 20),
level10   = rand_music(reg_playlist, 20),
level11   = rand_music(reg_playlist, 20),
level12   = rand_music(reg_playlist, 20),
level13   = rand_music(reg_playlist, 20),
level14   = rand_music(reg_playlist, 20),
level15   = rand_music(reg_playlist, 20),
level16   = rand_music(reg_playlist, 20),
level17   = rand_music(reg_playlist, 20),
level18   = rand_music(reg_playlist, 20),
level19   = rand_music(reg_playlist, 20),
level20   = rand_music(reg_playlist, 20),
level21   = rand_music(reg_playlist, 20),
level22   = rand_music(reg_playlist, 20),
level23   = rand_music(reg_playlist, 20),
level24   = rand_music(reg_playlist, 20),

the_chained_court = rand_music(spec_playlist, 12),
halls_of_carnage  = rand_music(spec_playlist, 12),
hells_armory      = rand_music(spec_playlist, 12),
hells_arena       = rand_music(spec_playlist, 12),
spiders_lair      = rand_music(spec_playlist, 12),
city_of_skulls    = rand_music(spec_playlist, 12),
the_wall          = rand_music(spec_playlist, 12),
unholy_cathedral  = rand_music(spec_playlist, 12),
the_mortuary      = rand_music(spec_playlist, 12),
the_vaults        = rand_music(spec_playlist, 12),
the_lava_pits     = rand_music(spec_playlist, 12),

tower_of_babel    = rand_music(boss_playlist, 4),
hell_fortress     = rand_music(boss_playlist, 4),
dis               = rand_music(boss_playlist, 4),
victory   = "mp3/Motorhead - Hellraiser.mp3",
}



Does it look right?

***Edit**
Just tried and the game crashed on start up. :(  Which part did I do wrong?
« Last Edit: April 17, 2012, 13:56 by Brewtal Legend »
Logged
-Legend

Game Hunter

  • Programmer
  • Local Inquisitor
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1044
  • Looks like game to me.
    • View Profile
    • Channel, the Roguelike
Re: More music?
« Reply #13 on: April 17, 2012, 14:39 »

You're close: recall that the rand_music function returns an entire array of songs. If you don't mind having random repeats, you're free to simply use the following for each line, replacing the playlist variable as necessary:

Code: [Select]
level2 = reg_playlist[ math.random(#reg_playlist) ]

The purpose of rand_music is to ensure that there are no repeats until the playlist runs out of possible songs. This is the way I'd prefer to have songs randomized, which is why I made it as such. Instead of calling rand_music for each and every song, you'll want to do this instead:

Code: [Select]
local title_mus = rand_music(title_playlist,1)
local reg_mus = rand_music(reg_playlist,23)
local boss_mus = rand_music(boss_playlist,4)
local spec_mus = rand_music(spec_playlist,11)

Music = {
    start = title_mus,
    ....
    level2 = reg_mus[1],
    level3 = reg_mus[2],
    ....
    level24 = reg_mus[23],
   
    the_chained_court = spec_mus[1],
    ....
}

Hopefully that gives you enough of an idea.

Are interlude and  hellgate still used? Intro is the phobos base entry level right?
"interlude" is, if I'm not mistaken, never used, so nothing to worry about there. "hellgate" is used for Phobos Anomaly (floor 8), so it should be part of the boss playlist. "intro" is, indeed, Phobos Base Entry.

Also note that "level8", "level16", and "level24" aren't used except for A100, but there's little reason not to put them in anyway.

EDIT: whoops typos
« Last Edit: April 17, 2012, 14:44 by Game Hunter »
Logged
I'm just a dude playing a dude disguised as another dude.

Latest LPs: Angband, Delver

Brewtal Legend

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 162
  • I am Hellbound
    • View Profile
Re: More music?
« Reply #14 on: April 17, 2012, 14:59 »

Ok. Thanks.
It still crashes. It makes it to the fullscreen query, but then crashes out. "Reason: invalid variant type cast"

Here is What I have now:

Code: [Select]
-- You can get much higher quality Doom MP3 tracks from
-- http://www.sirgalahad.org/paul/doom/
-- To use them, edit config.lua, and change music.lua to musicmp3.lua
-- MP3's need to be put in a directory named mp3.

--music_array is a table of pathnames to songs (like what you'd put in Music{})
--song_num is the total number of songs you want to output (size of playlist)
local function rand_music(music_array,song_num)
local song_tot = table.maxn(music_array)
local song_count = 0
local music_list = {}
--if song_num > music_array, we want to loop through
--randomization of the array more than once
for i=1,math.ceil(song_num/song_tot) do
--if song_num < music_array, we want to loop less than the full playlist
local loop_itr = math.min(song_tot,song_num)
song_num = song_num - song_tot
--make a temporary array of music
local song_list = music_array
for j=1,loop_itr do
--pick a random song from the temporary array...
idx = math.random(song_tot-j+1)
song = song_list[idx]
--...add it to the playlist...
music_list[song_count] = song
--...and remove it from the temporary array
table.remove(song_list,j)
song_count = song_count + 1
end
end
return(music_list)
end

local title_playlist = {
"mp3/PSX_Doom_Music/doom_titlescreen.mp3",
"mp3/cdoom.mp3",
"mp3/doom3.mp3",
"DSoP_00_WelcomeToHell(Intro).mp3",
}

local reg_playlist = {
"mp3/PSX_Doom_Music/doom_01hangar.mp3",
"mp3/PSX_Doom_Music/doom_02plant.mp3",
"mp3/PSX_Doom_Music/doom_03toxinrefinery.mp3",
"mp3/PSX_Doom_Music/doom_04commandcontrol.mp3",
"mp3/PSX_Doom_Music/doom_05phoboslab.mp3",
"mp3/PSX_Doom_Music/doom_06centralprocessing.mp3",
"mp3/PSX_Doom_Music/doom_07computerstation.mp3",
"mp3/PSX_Doom_Music/doom_08phobosanomaly.mp3",
"mp3/PSX_Doom_Music/doom_09deimosanomaly.mp3",
"mp3/PSX_Doom_Music/doom_10containmentarea.mp3",
"mp3/PSX_Doom_Music/doom_11refinery.mp3",
"mp3/PSX_Doom_Music/doom_12deimoslab.mp3",
"mp3/PSX_Doom_Music/doom_13commandcenter.mp3",
"mp3/PSX_Doom_Music/doom_16hellgate.mp3",
"mp3/PSX_Doom_Music/doom_17hellkeep.mp3",
"mp3/PSX_Doom_Music/doom_18pandemonium.mp3",
"mp3/PSX_Doom_Music/doom_22limbo.mp3",
"mp3/PSX_Doom_Music/doom_20unholycathedral.mp3",
"mp3/PSX_Doom_Music/doom_21mterebus.mp3",
"mp3/PSX_Doom_Music/doom_24hellbeneath.mp3",
"mp3/PSX_Doom_Music/fdoom_01attack.mp3",
"mp3/PSX_Doom_Music/fdoom_02virgil.mp3",
"mp3/PSX_Doom_Music/fdoom_03canyon.mp3",
"mp3/PSX_Doom_Music/fdoom_04combine.mp3",
"mp3/PSX_Doom_Music/fdoom_05catwalk.mp3",
"mp3/PSX_Doom_Music/fdoom_06fistula.mp3",
"mp3/PSX_Doom_Music/fdoom_07geryon.mp3",
"mp3/PSX_Doom_Music/fdoom_08minos.mp3",
"mp3/PSX_Doom_Music/fdoom_09nessus.mp3",
"mp3/PSX_Doom_Music/fdoom_10paradox.mp3",
}

local spec_playlist = {
"mp3/e1m1.mp3",
"mp3/e1m2.mp3",
"mp3/e1m3.mp3",
"mp3/e1m4.mp3",
"mp3/e1m5.mp3",
"mp3/e1m6.mp3",
"mp3/e1m7.mp3",
"mp3/e1m8.mp3",
"mp3/e1m9.mp3",
"mp3/Hangarmageddon.mp3",
"mp3/PA01Quake_Theme.mp3",
"mp3/Animal_Acoustic.mp3",
}

local boss_playlist = {
"mp3/PSX_Doom_Music/doom_credits.mp3",
"mp3/PSX_Doom_Music/final_doom_end.mp3",
"mp3/PSX_Doom_Music/psx_main_menu.mp3",
"mp3/PSX_Doom_Music/PSX_stats_screen.mp3",
}

local title_mus = rand_music(title_playlist,1)
local reg_mus = rand_music(reg_playlist,23)
local boss_mus = rand_music(boss_playlist,4)
local spec_mus = rand_music(spec_playlist,11)

Music = {
start     = title_mus,
interlude = "mp3/PSX_Doom_Music/fdoom_04combine.mp3",
bunny     = "mp3/d2end.mp3",
intro     = "mp3/DSoP_00_WelcomeToHell(Intro).mp3",
hellgate  = boss_mus[1],

level2    = reg_mus[1],
level3    = reg_mus[2],
level4    = reg_mus[3],
level5    = reg_mus[4],
level6    = reg_mus[5],
level7    = reg_mus[6],
level8    = reg_mus[7],
level9    = reg_mus[8],
level10   = reg_mus[9],
level11   = reg_mus[10],
level12   = reg_mus[11],
level13   = reg_mus[12],
level14   = reg_mus[13],
level15   = reg_mus[14],
level16   = reg_mus[15],
level17   = reg_mus[16],
level18   = reg_mus[17],
level19   = reg_mus[18],
level20   = reg_mus[19],
level21   = reg_mus[20],
level22   = reg_mus[21],
level23   = reg_mus[22],
level24   = reg_mus[23],

the_chained_court = spec_mus[1],
halls_of_carnage  = spec_mus[2],
hells_armory      = spec_mus[3],
hells_arena       = spec_mus[4],
spiders_lair      = spec_mus[5],
city_of_skulls    = spec_mus[6],
the_wall          = spec_mus[7],
unholy_cathedral  = spec_mus[8],
the_mortuary      = spec_mus[9],
the_vaults        = spec_mus[10],
the_lava_pits     = spec_mus[11],

tower_of_babel    = boss_mus[1],
hell_fortress     = boss_mus[2],
dis               = boss_mus[3],
victory   = "mp3/Motorhead - Hellraiser.mp3",
}



If Hell gate and intro are both already covered in the boss and special levels, do they need to be specified at the beginning of the file? Would Hellgate be the boss would it be the same as? Should I start Hellgate at boss_mus [1] and go to boss_mus [2] for tower of babel?

For the title music, will it go to a different song when I start a new game without exiting?

****edit***
Tried again with the console version. The console version starts and everything seems to work fine except no title music plays at all. The graphics version crashes without starting.

****Edit 2***
ok. figured out why it started in console but not graphic. It's because I had "start     = title_mus," when I started graphic version, but I changed it to "start     = title_mus[1]," before I tried console. So I can get the graphic version to start that way, but I'm still not getting any title music. Everything else seems to work fine except the title music.
« Last Edit: April 17, 2012, 16:30 by Brewtal Legend »
Logged
-Legend

Game Hunter

  • Programmer
  • Local Inquisitor
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1044
  • Looks like game to me.
    • View Profile
    • Channel, the Roguelike
Re: More music?
« Reply #15 on: April 17, 2012, 18:52 »

Well derp dee derp to me. In the rand_music function, song_count should be initialized at 1 instead of 0. With song_count starting at 0, the the first song to be indexed doesn't actually occur (since there is no zeroth element in lua). Change the 0 to a 1 and everything should work out okay.

The title_mus[1] thing is my fault, too: I should have remembered that arrays still have to be referenced accordingly even if there's only one element in them.
Logged
I'm just a dude playing a dude disguised as another dude.

Latest LPs: Angband, Delver

Brewtal Legend

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 162
  • I am Hellbound
    • View Profile
Re: More music?
« Reply #16 on: April 17, 2012, 20:36 »

ok. Just tried it. I do get title music now but it is always the same one. the cdoom.mp3 listed second in the title_playlist. I restarted and exited the game 20 something times in a row and it has yet to change.

Also, haven't tried it yet but, the mortem screen music should be randomizable too right?
« Last Edit: April 17, 2012, 22:14 by Brewtal Legend »
Logged
-Legend

Game Hunter

  • Programmer
  • Local Inquisitor
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1044
  • Looks like game to me.
    • View Profile
    • Channel, the Roguelike
Re: More music?
« Reply #17 on: April 18, 2012, 07:29 »

I do get title music now but it is always the same one. the cdoom.mp3 listed second in the title_playlist. I restarted and exited the game 20 something times in a row and it has yet to change.
Unfortunately I don't know what the issue is, here. You may have stumbled upon the predictability of a random seed that has yet to be initialized elsewhere...considering that the playlists with more than one song seem to randomize just fine, you could try to increase the song_num variable for the title playlist and, if that doesn't work, accordingly increase the index called (like title_mus[3]).

Also, haven't tried it yet but, the mortem screen music should be randomizable too right?
The music that plays when the mortem appears depends on when you see it. It's either going to be via "victory" (when you win) or "bunny" (when you don't). (In modules it could possibly be changed during the mortem itself, and is otherwise linked to the circumstances of the map, as the mortem appears regardless of victory or even quitting.)
Logged
I'm just a dude playing a dude disguised as another dude.

Latest LPs: Angband, Delver

shark20061

  • Programmer
  • Elder Chaos Guard
  • Captain
  • *
  • *
  • Offline Offline
  • Posts: 266
    • View Profile
Re: More music?
« Reply #18 on: April 18, 2012, 12:42 »

(In modules it could possibly be changed during the mortem itself, and is otherwise linked to the circumstances of the map, as the mortem appears regardless of victory or even quitting.)

Quitting doesn't show the mortem in modules, similar to quitting in the regular game.
Logged
Hell Knight Warrant Officer (0.9.9.4)  [26!/8/3/1/0]

Mancubus 2nd Lieutenant (0.9.9.6)  [22/12/3/0/0]
M:16 S:43 (126) A:17

Brewtal Legend

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 162
  • I am Hellbound
    • View Profile
Re: More music?
« Reply #19 on: April 18, 2012, 14:23 »

Just tried changing the song_num variable and I still only get the same song playing over and over. Although, that song that plays is different depending on what number I use for the song_num variable. I tried 1-4.

I tried increasing the index too and it made no difference.

When I mentioned the mortem screen, I was talking about the "bunny" one. Would I have to use a specific tag like with the other ones? Like boss_playlist/mus, spec_playlist/mus, etc.

***Edit***
I actually just played through till hell's arena about 10 times in a row and dying on purpose just to check. It doesn't seem any of the levels are playing music randomly. :(  Not sure why I thought it did work now. Maybe because I am using ambient psx soundtrack so it's harder to tell. The songs that play are coming from the correct playlist arrays but are not randomizing.

Here's the config:

Code: [Select]
-- You can get much higher quality Doom MP3 tracks from
-- http://www.sirgalahad.org/paul/doom/
-- To use them, edit config.lua, and change music.lua to musicmp3.lua
-- MP3's need to be put in a directory named mp3.

local function rand_music(music_array,song_num)
local song_tot = table.maxn(music_array)
local song_count = 1
local music_list = {}
for i=1,math.ceil(song_num/song_tot) do
local loop_itr = math.min(song_tot,song_num)
song_num = song_num - song_tot
local song_list = music_array
for j=1,loop_itr do
idx = math.random(song_tot-j+1)
song = song_list[idx]
music_list[song_count] = song
table.remove(song_list,j)
song_count = song_count + 1
end
end
return(music_list)
end


local title_playlist = {
"mp3/PSX_Doom_Music/doom_titlescreen.mp3",
"mp3/cdoom.mp3",
"mp3/doom3.mp3",
"mp3/DSoP_00_WelcomeToHell(Intro).mp3",
}

local reg_playlist = {
"mp3/PSX_Doom_Music/doom_01hangar.mp3",
"mp3/PSX_Doom_Music/doom_02plant.mp3",
"mp3/PSX_Doom_Music/doom_03toxinrefinery.mp3",
"mp3/PSX_Doom_Music/doom_04commandcontrol.mp3",
"mp3/PSX_Doom_Music/doom_05phoboslab.mp3",
"mp3/PSX_Doom_Music/doom_06centralprocessing.mp3",
"mp3/PSX_Doom_Music/doom_07computerstation.mp3",
"mp3/PSX_Doom_Music/doom_08phobosanomaly.mp3",
"mp3/PSX_Doom_Music/doom_09deimosanomaly.mp3",
"mp3/PSX_Doom_Music/doom_10containmentarea.mp3",
"mp3/PSX_Doom_Music/doom_11refinery.mp3",
"mp3/PSX_Doom_Music/doom_12deimoslab.mp3",
"mp3/PSX_Doom_Music/doom_13commandcenter.mp3",
"mp3/PSX_Doom_Music/doom_16hellgate.mp3",
"mp3/PSX_Doom_Music/doom_17hellkeep.mp3",
"mp3/PSX_Doom_Music/doom_18pandemonium.mp3",
"mp3/PSX_Doom_Music/doom_22limbo.mp3",
"mp3/PSX_Doom_Music/doom_20unholycathedral.mp3",
"mp3/PSX_Doom_Music/doom_21mterebus.mp3",
"mp3/PSX_Doom_Music/doom_24hellbeneath.mp3",
"mp3/PSX_Doom_Music/fdoom_01attack.mp3",
"mp3/PSX_Doom_Music/fdoom_02virgil.mp3",
"mp3/PSX_Doom_Music/fdoom_03canyon.mp3",
"mp3/PSX_Doom_Music/fdoom_04combine.mp3",
"mp3/PSX_Doom_Music/fdoom_05catwalk.mp3",
"mp3/PSX_Doom_Music/fdoom_06fistula.mp3",
"mp3/PSX_Doom_Music/fdoom_07geryon.mp3",
"mp3/PSX_Doom_Music/fdoom_08minos.mp3",
"mp3/PSX_Doom_Music/fdoom_09nessus.mp3",
"mp3/PSX_Doom_Music/fdoom_10paradox.mp3",
}

local spec_playlist = {
"mp3/e1m1.mp3",
"mp3/e1m2.mp3",
"mp3/e1m3.mp3",
"mp3/e1m4.mp3",
"mp3/e1m5.mp3",
"mp3/e1m6.mp3",
"mp3/e1m7.mp3",
"mp3/e1m8.mp3",
"mp3/e1m9.mp3",
"mp3/Hangarmageddon.mp3",
"mp3/PA01Quake_Theme.mp3",
"mp3/Animal_Acoustic.mp3",
}

local boss_playlist = {
"mp3/PSX_Doom_Music/doom_credits.mp3",
"mp3/PSX_Doom_Music/final_doom_end.mp3",
"mp3/PSX_Doom_Music/psx_main_menu.mp3",
"mp3/PSX_Doom_Music/PSX_stats_screen.mp3",
}

local title_mus = rand_music(title_playlist,1)
local reg_mus = rand_music(reg_playlist,23)
local boss_mus = rand_music(boss_playlist,4)
local spec_mus = rand_music(spec_playlist,11)

Music = {
start     = title_mus[1],
interlude = "mp3/PSX_Doom_Music/fdoom_04combine.mp3",
bunny     = "mp3/d2end.mp3",
intro     = "mp3/DSoP_00_WelcomeToHell(Intro).mp3",
hellgate  = boss_mus[1],

level2    = reg_mus[1],
level3    = reg_mus[2],
level4    = reg_mus[3],
level5    = reg_mus[4],
level6    = reg_mus[5],
level7    = reg_mus[6],
level8    = reg_mus[7],
level9    = reg_mus[8],
level10   = reg_mus[9],
level11   = reg_mus[10],
level12   = reg_mus[11],
level13   = reg_mus[12],
level14   = reg_mus[13],
level15   = reg_mus[14],
level16   = reg_mus[15],
level17   = reg_mus[16],
level18   = reg_mus[17],
level19   = reg_mus[18],
level20   = reg_mus[19],
level21   = reg_mus[20],
level22   = reg_mus[21],
level23   = reg_mus[22],
level24   = reg_mus[23],

the_chained_court = spec_mus[1],
halls_of_carnage  = spec_mus[2],
hells_armory      = spec_mus[3],
hells_arena       = spec_mus[4],
spiders_lair      = spec_mus[5],
city_of_skulls    = spec_mus[6],
the_wall          = spec_mus[7],
unholy_cathedral  = spec_mus[8],
the_mortuary      = spec_mus[9],
the_vaults        = spec_mus[10],
the_lava_pits     = spec_mus[11],

tower_of_babel    = boss_mus[2],
hell_fortress     = boss_mus[3],
dis               = boss_mus[4],
victory   = "mp3/Motorhead - Hellraiser.mp3",
}




Did I not copy something over from your example correctly or forgot to edit? Sorry, I really don't know anything about lua script.
« Last Edit: April 18, 2012, 15:41 by Brewtal Legend »
Logged
-Legend

shark20061

  • Programmer
  • Elder Chaos Guard
  • Captain
  • *
  • *
  • Offline Offline
  • Posts: 266
    • View Profile
Re: More music?
« Reply #20 on: April 18, 2012, 18:53 »

The code looks good, so I guess really the only thing to try would be to set the seed.

Code: [Select]
math.randomseed(some_number)

Speaking of which, what does DoomRL use for the random seed?  Since I can't seem to get a time function...
« Last Edit: April 18, 2012, 18:59 by shark20061 »
Logged
Hell Knight Warrant Officer (0.9.9.4)  [26!/8/3/1/0]

Mancubus 2nd Lieutenant (0.9.9.6)  [22/12/3/0/0]
M:16 S:43 (126) A:17

Brewtal Legend

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 162
  • I am Hellbound
    • View Profile
Re: More music?
« Reply #21 on: April 18, 2012, 20:15 »

The code looks good, so I guess really the only thing to try would be to set the seed.

Code: [Select]
math.randomseed(some_number)

Speaking of which, what does DoomRL use for the random seed?  Since I can't seem to get a time function...

Not sure how exactly or where to use the random seed in the code.
Logged
-Legend

shark20061

  • Programmer
  • Elder Chaos Guard
  • Captain
  • *
  • *
  • Offline Offline
  • Posts: 266
    • View Profile
Re: More music?
« Reply #22 on: April 18, 2012, 20:41 »

It would be one of the first lines.

some_number is the Seed number: The random number generator uses that to get the first random number, and thus create the random nature.  Problem is, there's no way to access a constantly changing number (like the current time), so Game Hunter (or any other dev) will need to shed a little light as to what could be done.
« Last Edit: April 18, 2012, 20:44 by shark20061 »
Logged
Hell Knight Warrant Officer (0.9.9.4)  [26!/8/3/1/0]

Mancubus 2nd Lieutenant (0.9.9.6)  [22/12/3/0/0]
M:16 S:43 (126) A:17

tehtmi

  • Programmer
  • Local Inquisitor
  • Lieutenant Colonel
  • *
  • *
  • Offline Offline
  • Posts: 458
    • View Profile
Re: More music?
« Reply #23 on: April 18, 2012, 22:23 »

I don't think there's currently any way to get any random/varying data in lua from the config file.  We are seeding the random number generator that the rest of DoomRL uses, but not the random number generator accessible from the config file.

Here's a work-around for you: seed the random number generator from a batch file!
Many of us already run DoomRL from a batch file.  Try using this instead:
Code: [Select]
mode con lines=25 cols=80
mode con cp select=437
ECHO math.randomseed(tonumber((string.gsub("%TIME%", "%%D+", ""))) or error("Random seed failed!")) > random.lua
doomrl -console
(Modify as appropriate for graphics mode.)

Then add this one line to the top of your config.lua:
Code: [Select]
dofile "random.lua"

Then you should be good to go.  math.random will be seeded by your system time.  (And yes, crappy seed + crappy RNG will lead to crappy random numbers, but it should be fine for our purposes.  You could also use %RANDOM%, but that's too crappy even for me.)

(Non-windows users should be able to use a similar approach in the shell script, etc)
Logged

Brewtal Legend

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 162
  • I am Hellbound
    • View Profile
Re: More music?
« Reply #24 on: April 19, 2012, 16:21 »

I tried out the batch file work around. And though I did get different song results when starting it up different times, They wouldn't change while playing. As in unless I exited the program after every death, then the songs would be the same for every level when I started a new game without exiting.
Logged
-Legend

shark20061

  • Programmer
  • Elder Chaos Guard
  • Captain
  • *
  • *
  • Offline Offline
  • Posts: 266
    • View Profile
Re: More music?
« Reply #25 on: April 19, 2012, 19:18 »

That's because the config script only runs once per load.  There might be a way to make it randomize every game...
Logged
Hell Knight Warrant Officer (0.9.9.4)  [26!/8/3/1/0]

Mancubus 2nd Lieutenant (0.9.9.6)  [22/12/3/0/0]
M:16 S:43 (126) A:17

tehtmi

  • Programmer
  • Local Inquisitor
  • Lieutenant Colonel
  • *
  • *
  • Offline Offline
  • Posts: 458
    • View Profile
Re: More music?
« Reply #26 on: April 19, 2012, 19:44 »

That's because the config script only runs once per load.

This is true.

Quote
There might be a way to make it randomize every game...

I believe all the music ID's are translated into numbers right when the config script is loaded, and the config environment is pretty well isolated from the main game, so I'd be (pleasantly) surprised if this was possible.
Logged

Brewtal Legend

  • Second Lieutenant
  • *
  • Offline Offline
  • Posts: 162
  • I am Hellbound
    • View Profile
Re: More music?
« Reply #27 on: April 21, 2012, 15:35 »

I would assume it could be possible since Ao100 loads level music randomly.
Logged
-Legend
Pages: 1 2 [All]