Chaosforge Forum

  • October 06, 2024, 07:17
  • Welcome, Guest
Please login or register.



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

Author Topic: More music?  (Read 16212 times)

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