Music


(Diego) #1

I’ve been thinking about incorporating music into my next map similar to what you might find in a singleplayer mission. It wouldn’t be a single song that loops throughout the level. I want to script it up so that the different stages of gameplay have different ambient and action music tracks (about 6-8 tracks of various lengths). Of course, this presents some potential issues on how to implement it.

Since you can’t loop global sounds, I could manually loop them through scripting. I did this on Mission Two with some sound effects, but I haven’t tried it before with long music files. I’ve ruled out using target_speakers, the music key/value pair in the worldspawn, and the playsound command. So, I’m planning on using the togglespeaker command with the .sps file and loop it manually in the script with various wait statements. I would attach the sound to it’s own script mover to try to limit the impact this might have on the rest of the script.

Obviously, some people just woudn’t want the music in there, or would want the ability to turn it off. I have that covered. And I would also probably put all the music in a separate .pk3 file so it would not have to be downloaded with the main map since my .pk3 files are usually big enough as it is.

I was wondering if anyone had any idea what kind of impact this might have with performance or gamestate. Or if you have a better way to incorporate global audio tracks that I am not aware of.


(macbeth) #2

FPS prolly


(dutchmeat) #3

I recommend you talk to Marcus Wilkinson, which has made a very cool interactive music system.
http://www.marcuswilkinson.com/index.php?page=ims


(IndyJones) #4

i don’t think it has any noticable impact on fps… maybe on first load (game may freeze for a sec or two, happens very often when u destroy objective etc… buffering)


(acQu) #5

having 6 sounds just looped and just hiding 5 streams from beeing hearable will have probably more impact then having 6 speakers up and only one of them is activated.

so i think ‘yes’ it will have an impact. question is if its noticable and how you set up your speakers.

i suggest a stress test: create an empty room and insert about 1000 speakers with looped settings (hope it wont cause memory crash :wink: ) and then see. you could easily create 1000 speakers by just copy and pasting the content of your .sps file and then just change origins.

[edit] meh. i think stress test will only work if you have 1000 multiple stream files, maybe just rename like

testmusic1.wav
testmusic2.wav

while all these wavs contain the same stream. engine wont realize i think.


(acQu) #6

having 6 sounds just looped and just hiding 5 streams from beeing hearable will have probably more impact then having 6 speakers up and only one of them is activated. the problem is that if you hide a looped sound it will most likely still have an impact. probably just a counter for every looped sound.

maybe create a stress test…


(ailmanki) #7

afaik long wav files can cause fps issues, dunno I suppose cpu lag…


(acQu) #8

having 6 sounds just looped and just hiding 5 streams from beeing hearable will have probably more impact then having 6 speakers up and only one of them is activated.

the problem is that if you hide a looped sound it will most likely still have an impact. probably just a counter for every looped sound.

maybe create a stress test…


(Diego) #9

[QUOTE=.NM;231579]having 6 sounds just looped and just hiding 5 streams from beeing hearable will have probably more impact then having 6 speakers up and only one of them is activated.

the problem is that if you hide a looped sound it will most likely still have an impact. probably just a counter for every looped sound.

maybe create a stress test…[/QUOTE]

I wouldn’t be hiding the sounds. I would use the togglespeaker command to turn them on and off. So only one speaker would be active at a time. And since you can’t loop global sounds, I would be using scripting with wait statements to toggle the sound on again after each completion.

But I will certainly test it out first.


(UJERebel) #10

Make sure when you have lags, the music AND wait command are both halted, otherwise, 10 sounds at a time after big lag


(acQu) #11

[QUOTE=Diego;231588]I wouldn’t be hiding the sounds. I would use the togglespeaker command to turn them on and off. So only one speaker would be active at a time. And since you can’t loop global sounds, I would be using scripting with wait statements to toggle the sound on again after each completion.

But I will certainly test it out first.[/QUOTE]

are you sure you cant loop global sounds ? i thought you can, you just have to set it in the ingame-speakermenu i thought.

and btw.: by looking at cg_sound.c i can certainly see that all sound you will have in your map will certainly be precached, means loaded in the cache. if it stays there is another thing :wink:

didnt have a closer look so far. but most of the sound stuff should be client side.


(acQu) #12

[QUOTE=Diego;231588]I wouldn’t be hiding the sounds. I would use the togglespeaker command to turn them on and off. So only one speaker would be active at a time. And since you can’t loop global sounds, I would be using scripting with wait statements to toggle the sound on again after each completion.

But I will certainly test it out first.[/QUOTE]

are you sure you cant loop global sounds ? i thought you can, you just have to set it in the ingame-speakermenu i thought.

and btw.: by looking at cg_sound.c i can certainly see that all sound you will have in your map will certainly be precached, means loaded in the cache. if it stays there is another thing. didnt have a closer look so far. but most of the sound stuff should be client side.