IPB

Welcome Guest ( Log In | Register )

Ingame Soundtracks, no vehicle required
MasterChiefRulZ
post Jul 26 2013, 08:08 AM
Post #1


You know the drill...
Group Icon

Group: Mr. Admin
Posts: 10,383
Joined: 31-December 03
From: Home
Member No.: 48



So yeah I was thinking of adding an ingame soundtrack feature to my BF2 mod. As stated in the description, not where it's a vehicle radio, but an actual ingame soundtrack that plays as I do. Similar in nature to other favorite FPS singleplayer games (and even MP) where an occasional track plays adding a nice touch of ambiance. I've got a collection of different ingame music from old fav FPS games, as well as movie soundtracks, and of course my favorite performing artists for a nice variety of audible flavors.

Now who wants the same music playing in a map over and over again? Not many I imagine, and neither do I. The idea is to have multiple tracks setup to play per map, and the game pick them at random and play them. Now just getting this idea from concept to working feature is, as usual, my dilemma.

First I took code from JONES map "Pripiyat" which is a CoD4 Singleplayer remake that features an ingame soundtrack, which works quite nicely, but alas it runs just the one soundtrack. Found this in the server.zip of said map, in the AmbientObjects.con file.



CODE
rem ************ AmbientSounds ************

rem [SoundObjectTemplate: Pripiyat_Global]
ObjectTemplate.create Sound Pripiyat_Global
ObjectTemplate.activeSafe Sound Pripiyat_Global
ObjectTemplate.modifiedByUser "Robert"
ObjectTemplate.isNotSaveable 1
ObjectTemplate.lowSamples 2147483647
ObjectTemplate.mediumSamples 2147483647
ObjectTemplate.soundFilename "levels/pripiyat/music/ambient_pripiyat.ogg"
ObjectTemplate.loopCount 0
ObjectTemplate.is3dSound 0
ObjectTemplate.stopType 0
ObjectTemplate.volume 0.4
ObjectTemplate.pitch 1
ObjectTemplate.pan 0.5
ObjectTemplate.reverbLevel 0
ObjectTemplate.position 2/47.069/-13.383
ObjectTemplate.minDistance 500
ObjectTemplate.soundRadius 500

Sound.addTrigger Pripiyat_Global

if v_arg1 == BF2Editor

Object.create Pripiyat_Global
Object.absolutePosition 2.000/47.069/-13.383
Object.rotation 0.000/0.000/0.000
Object.layer 1

endIf



I then proceeded to pluck code from a randomized sound event to make this soundtrack the same, I chose the grenade explosion sound file setup.


CODE
ObjectTemplate.modifiedByUser dsu
ObjectTemplate.createdInEditor 1
ObjectTemplate.soundFilename "common/material/impact/handgranade/handgrenade_01.wav,common/material/impact/handgranade/handgrenade_02.wav,common/material/impact/handgranade/handgrenade_03.wav,common/material/impact/handgranade/handgrenade_04.wav,common/material/impact/handgranade/handgrenade_05.wav,common/material/impact/handgranade/handgrenade_06.wav,common/material/impact/handgranade/handgrenade_07.wav,common/material/impact/handgranade/handgrenade_08.wav"
ObjectTemplate.loopCount 1
ObjectTemplate.is3dSound 1
ObjectTemplate.stopType 1
ObjectTemplate.volume 1
ObjectTemplate.pitch 1
ObjectTemplate.reverbLevel 1
ObjectTemplate.pitchEnvelope 0/1/0.9/1.1/1/1/0/0.9/1.1/
ObjectTemplate.minDistance 9
ObjectTemplate.halfVolumeDistance 20
ObjectTemplate.soundRadius 1




My current Frankenstein code bit looks like this (as setup in my test map "Gulf of Oman")...



CODE
rem ************ AmbientSounds ************

rem [SoundObjectTemplate: Gulf_of_Oman_Global]
ObjectTemplate.create Sound Gulf_of_Oman_Global
ObjectTemplate.activeSafe Sound Gulf_of_Oman_Global
ObjectTemplate.modifiedByUser "MCR"
ObjectTemplate.isNotSaveable 1
ObjectTemplate.lowSamples 2147483647
ObjectTemplate.mediumSamples 2147483647
ObjectTemplate.soundFilename "common/sound/levelambients/Gulf_of_Oman/One.ogg,common/sound/levelambients/Gulf_of_Oman/Two.ogg,common/sound/levelambients/Gulf_of_Oman/Three.ogg"
ObjectTemplate.loopCount 0
ObjectTemplate.is3dSound 0
ObjectTemplate.stopType 0
ObjectTemplate.volume 1
ObjectTemplate.pitch 1
ObjectTemplate.pan 0.5
ObjectTemplate.reverbLevel 0
rem ObjectTemplate.position 2/47.069/-13.383
ObjectTemplate.minDistance 300000
ObjectTemplate.soundRadius 300000

Sound.addTrigger Gulf_of_Oman_Global

if v_arg1 == BF2Editor

Object.create Gulf_of_Oman_Global
rem Object.absolutePosition 2.000/47.069/-13.383
Object.rotation 0.000/0.000/0.000
Object.layer 1



Not hearing anything though... Any suggestions? Anyone else already done this and care to share?


--------------------
Go to the top of the page
 
+Quote Post
2 Pages V   1 2 >  
Start new topic
Replies (1 - 14)
imtheheadhunter
post Jul 26 2013, 03:03 PM
Post #2


Debug assertion failed! Text:people == stupid!
Group Icon

Group: Mr. Admin
Posts: 1,005,138
Joined: 8-March 06
From: The freaking Twilight zone!
Member No.: 1,609



DICE might have beaten you to this. In the common/sound/gamesounds.con there is this towards the bottom of the file.

rem -----------------------------------------------------------------------
rem ----------------------------- INGAME MUSIC ----------------------------
rem -----------------------------------------------------------------------

beginRem
Sound.addSound music
ObjectTemplate.soundFilename
ObjectTemplate.loopCount 0
ObjectTemplate.is3dSound 0
ObjectTemplate.volume 0.2
ObjectTemplate.pan 0.5
ObjectTemplate.reverbLevel 0
endRem

If it works as ingame music like you want, I don't know, I've never tried it.

QUOTE
Not hearing anything though...


Just a stupid idea....but you did encode your .ogg files with the bf2 sound tools, right? You do know for sure the sounds themselves work in bf2?


--------------------
Go to the top of the page
 
+Quote Post
MasterChiefRulZ
post Jul 26 2013, 05:51 PM
Post #3


You know the drill...
Group Icon

Group: Mr. Admin
Posts: 10,383
Joined: 31-December 03
From: Home
Member No.: 48



QUOTE
you did encode your .ogg files with the bf2 sound tools, right? You do know for sure the sounds themselves work in bf2?

Yeah. Renamed and dropped one of my .ogg files into the JONES Pripiyat map and replaced his .ogg with my own, and the sound file worked beautifully.

When trying to use it elsewhere (Gulf of Oman) I'm not having any luck... I first tried mounting my .ogg files like any other ambient sound in Gulf of Oman and no go, then switched to JONES' method he used in Pripiyat... Still nothing. uhm.gif Went combing through his map files looking for maybe a line of code I might have missed somewhere in the process, can't find anything else.

In my recent attempts I decided to try and relocate the sound, thinking that maybe it was too far out as opposed to the position JONES used in his own map. So I copied a location file for somewhere near the middle of the map, still not hearing anything even with the sound radius and mindistance set to 1000000. headscratch.gif


--------------------
Go to the top of the page
 
+Quote Post
MasterChiefRulZ
post Jul 27 2013, 12:01 AM
Post #4


You know the drill...
Group Icon

Group: Mr. Admin
Posts: 10,383
Joined: 31-December 03
From: Home
Member No.: 48



UPDATE:

Forget it, instead of having an ambient sound I just went the route of attaching soundtracks as an effect to an object and playing them that way. tongue.gif Works great, random tracks are played and I can set it up either to keep playing through the tracks or just pick one and play once per round. Once I get everything sorted and the bugs worked out I'll post the details for anyone interested.


--------------------
Go to the top of the page
 
+Quote Post
JONES
post Jul 27 2013, 03:25 AM
Post #5


Graphic Artist/Map Designer (retired)
*****

Group: Soldiers
Posts: 1,331
Joined: 5-February 06
From: Paintball Field
Member No.: 1,511



QUOTE (MasterChiefRulZ @ Jul 27 2013, 08:01 AM) *
UPDATE:

Forget it, instead of having an ambient sound I just went the route of attaching soundtracks as an effect to an object and playing them that way. tongue.gif Works great, random tracks are played and I can set it up either to keep playing through the tracks or just pick one and play once per round. Once I get everything sorted and the bugs worked out I'll post the details for anyone interested.


Could you give me an exact example with the con/tweak files used for this object attached soundeffect?
I tried to do this once with a custom radio model but failed, it never played ingame for some reason, you would help me alot biggrin.gif
Go to the top of the page
 
+Quote Post
MasterChiefRulZ
post Aug 1 2013, 11:19 AM
Post #6


You know the drill...
Group Icon

Group: Mr. Admin
Posts: 10,383
Joined: 31-December 03
From: Home
Member No.: 48



QUOTE (JONES @ Jul 27 2013, 05:25 AM) *
QUOTE (MasterChiefRulZ @ Jul 27 2013, 08:01 AM) *
UPDATE:

Forget it, instead of having an ambient sound I just went the route of attaching soundtracks as an effect to an object and playing them that way. tongue.gif Works great, random tracks are played and I can set it up either to keep playing through the tracks or just pick one and play once per round. Once I get everything sorted and the bugs worked out I'll post the details for anyone interested.


Could you give me an exact example with the con/tweak files used for this object attached soundeffect?
I tried to do this once with a custom radio model but failed, it never played ingame for some reason, you would help me alot biggrin.gif

Sure. I'm not at my PC atm, currently housesitting for someone on vacation ("baby" sitting their pets as well). In a few days I'll post what I have. smile.gif


--------------------
Go to the top of the page
 
+Quote Post
MasterChiefRulZ
post Aug 3 2013, 04:42 PM
Post #7


You know the drill...
Group Icon

Group: Mr. Admin
Posts: 10,383
Joined: 31-December 03
From: Home
Member No.: 48



UPDATE:

To answer JONES' previous question, I chose an object that was present to every BF2 map I could think of, the flag poles. Flag poles have a sound effect, so I cloned them, replaced 1 flagpole in a given map, and edited the cloned flag pole's sound it emanated to be my soundtracks.. I clone create a new flagpole for every map so I can have various but specific soundtracks for each map if I desire. Nothing fancy, just the usual adapting to the game engine's rules to reach the desired result. smile.gif


The following sound carries throughout the entire map, so if you want to use a radio theme you'll probably want to tone down the distance it carries.

UPDATE to CODE posted here.

CODE
rem *** Generated with Bf2Editor.exe [created: 2005/4/21 20:21]
rem *** Gulf of Oman 32 size ***
rem ****************************
GeometryTemplate.doNotGenerateLightmaps 1
GeometryTemplate.lightmapOverride 0
GeometryTemplate.compressVertexData 1
GeometryTemplate.maxTextureRepeat 16
ObjectTemplate.activeSafe Bundle flagpole_Gulf_of_Oman
ObjectTemplate.creator DPA-1:dpa
ObjectTemplate.modifiedByUser han
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.geometry flagpole_Gulf_of_Oman
ObjectTemplate.setCollisionMesh flagpole_Gulf_of_Oman
ObjectTemplate.mapMaterial 0 Metal_solid 21
ObjectTemplate.mapMaterial 1 Rock_or_concrete 78
ObjectTemplate.mapMaterial 2 Roap 10
ObjectTemplate.hasMobilePhysics 0
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.physicsType Mesh
rem -------------------------------------
ObjectTemplate.addTemplate flagpole_Gulf_of_Oman_SFXBundle
rem -------------------------------------

ObjectTemplate.create EffectBundle flagpole_Gulf_of_Oman_SFXBundle
ObjectTemplate.modifiedByUser han
ObjectTemplate.createdInEditor 1
ObjectTemplate.floaterMod 0
ObjectTemplate.hasMobilePhysics 0
rem -------------------------------------
ObjectTemplate.addTemplate S_flagpole_Gulf_of_Oman_SFXBundle_Start
rem -------------------------------------
ObjectTemplate.setStartOnEffects 0
ObjectTemplate.setStopOnEffects 0
ObjectTemplate.timeToLive CRD_NONE/-1/0/0
ObjectTemplate.randomAgeFactor CRD_NONE/1/0/0
ObjectTemplate.startAtCreation 1
ObjectTemplate.speedFromPhysics 0

ObjectTemplate.activeSafe Sound S_flagpole_Gulf_of_Oman_SFXBundle_Start
ObjectTemplate.modifiedByUser han
ObjectTemplate.soundFilename "common/sound/levelambients/gulf_of_oman/One.ogg"
ObjectTemplate.loopCount 1
ObjectTemplate.is3dSound 0
ObjectTemplate.stopType 1
ObjectTemplate.volume 0.65
ObjectTemplate.pitch 1
ObjectTemplate.reverbLevel 0
ObjectTemplate.minDistance 0.01
ObjectTemplate.halfVolumeDistance 30



The above method allows for one sound to play one time.


If you change this line..

CODE
ObjectTemplate.loopCount 1


with the 1 to a 0...

CODE
ObjectTemplate.loopCount 0


then the sound will replay over and over continuously.

If you take this line..

CODE
ObjectTemplate.soundFilename "common/sound/levelambients/gulf_of_oman/One.ogg"


and change it like this...

CODE
ObjectTemplate.soundFilename "common/sound/levelambients/gulf_of_oman/Two.ogg,common/sound/levelambients/gulf_of_oman/Three.ogg,common/sound/levelambients/gulf_of_oman/One.ogg"


the game will chose one of the 3 tracks to play instead of just the one, in my testing the first sound is the most commonly chose by the engine. If you have it set to continuously loop whichever track the game chooses will loop over and over without choosing any others.

Using sound editing software you can have myriad methods of setting this up, with multiple tracks per sound file, spacing between each or whatever. Really great for Singleplayer styled ambient music for your Singleplayer or Co-op gaming. biggrin.gif


At one time I considered adding music via triggered situations, like adding to the Commander statements such as... "We're running low on reinforcements" and have exciting crescendo themed music kick in after that statement by simply adding it to that specific Commander sound file, but then decided against it as it could possibly conflict with other music (like the round ending music). Lots of cool "mood setting" sound ideas when you think about how stuff like this could be implemented.


--------------------
Go to the top of the page
 
+Quote Post
bobthedinosaur
post Aug 3 2013, 09:51 PM
Post #8


Dictator
******

Group: Soldiers
Posts: 2,228
Joined: 4-March 11
From: A Cold Place
Member No.: 7,896



Didn't the CQB mod have some drums that would always play in the back ground? I wonder if that was a mod or a map played sound.


--------------------
Not doing modding right now, so please don't ask.
Go to the top of the page
 
+Quote Post
MasterChiefRulZ
post Aug 5 2013, 12:09 PM
Post #9


You know the drill...
Group Icon

Group: Mr. Admin
Posts: 10,383
Joined: 31-December 03
From: Home
Member No.: 48



QUOTE (bobthedinosaur @ Aug 3 2013, 11:51 PM) *
Didn't the CQB mod have some drums that would always play in the back ground? I wonder if that was a mod or a map played sound.

Played CQB many times (though not recently), can't remember hearing drum sounds.


--------------------
Go to the top of the page
 
+Quote Post
MasterChiefRulZ
post Aug 26 2013, 12:14 PM
Post #10


You know the drill...
Group Icon

Group: Mr. Admin
Posts: 10,383
Joined: 31-December 03
From: Home
Member No.: 48



UPDATE:

Discovered a bug with my previous settings for sound, would crash a game when the map restarted. Don't set the sound radius high, keep it low, and keep the 3d sound option to NO and the sound will still play throughout the map without crashing on restart. smile.gif Code example below...



ObjectTemplate.activeSafe Sound S_flagpole_Abandoned_Village_SFXBundle_Start
ObjectTemplate.modifiedByUser han
ObjectTemplate.soundFilename "common/sound/levelambients/Abandoned_Village/AbanVill1.ogg,common/sound/levelambients/Abandoned_Village/AbanVill2.ogg,common/sound/levelambients/Abandoned_Village/AbanVill3.ogg"
ObjectTemplate.loopCount 0 <---------------------------------set this to zero or if sound is long it will cause memory overload
ObjectTemplate.is3dSound 0 <------------------------------
ObjectTemplate.stopType 1
ObjectTemplate.volume 0.4
ObjectTemplate.pitch 1
ObjectTemplate.reverbLevel 0
ObjectTemplate.pitchEnvelope 0/1/0.9/1.1/1/1/0/0.97/1.04/
ObjectTemplate.volumeEnvelope 0/1/0/1/1/1/0/0.95/1/
ObjectTemplate.minDistance 0.01
ObjectTemplate.halfVolumeDistance 30 <------------------------------
ObjectTemplate.soundRadius 5



I'm so glad it's working. I originally got the idea watching one of Enemysniper's youtube videos showing off his work and some gameplay, and he had the BF3 theme playing in the video. Now I can add that (and more) directly ingame, really sets the mood for some action! uzismile.gif


EDIT:ACK! Still bugged. doh.gif See post #12 below.


--------------------
Go to the top of the page
 
+Quote Post
clivewil
post Aug 26 2013, 08:45 PM
Post #11


meh.
Group Icon

Group: Mr. Admin
Posts: 2,008,262
Joined: 24-July 07
From: Perth, Western Australia
Member No.: 3,545



QUOTE
and keep the 3d sound option to NO

that's also a useful trick i use for checking whether bots are using a particular weapon - changing the Fire 3D sound to 3d = 0 means you can hear it all over the map, if they use the weapon


--------------------
Go to the top of the page
 
+Quote Post
MasterChiefRulZ
post Aug 27 2013, 10:06 PM
Post #12


You know the drill...
Group Icon

Group: Mr. Admin
Posts: 10,383
Joined: 31-December 03
From: Home
Member No.: 48



UPDATE TO THE UPDATE

Seems I'm too quick to claim victory, as further testing continues to present the memory allocation bug. With the code set to this for the sound...

CODE
ObjectTemplate.setStartOnEffects 0
ObjectTemplate.setStopOnEffects 0
ObjectTemplate.timeToLive CRD_NONE/-1/0/0
ObjectTemplate.randomAgeFactor CRD_NONE/1/0/0
ObjectTemplate.startAtCreation 1
ObjectTemplate.speedFromPhysics 0
ObjectTemplate.activeSafe Sound S_flagpole_Kubra_Dam64_SFXBundle_Start
ObjectTemplate.modifiedByUser han
ObjectTemplate.soundFilename "common/sound/levelambients/Kubra_Dam/Four.ogg,common/sound/levelambients/Kubra_Dam/Five.ogg,common/sound/levelambients/Kubra_Dam/Six.ogg"
ObjectTemplate.loopCount 1
ObjectTemplate.is3dSound 0
ObjectTemplate.stopType 0
ObjectTemplate.volume 0.5
ObjectTemplate.pitch 1
ObjectTemplate.reverbLevel 0
ObjectTemplate.minDistance 3
ObjectTemplate.halfVolumeDistance 1.5



I can run the same map multiple times and the soundtracks play fine. If I go to switch to a different map by setting up a map list (via Co-Op mode LAN) the game crashes with the memory allocation error during loading the new map (or map size). Note I'm using BF2 version 1.4, which only allows use of 2 gigs of my RAM. I don't use 1.5 (unless a mod I download requires it) due to the broken Commander AI and incompatibility with the Unlocks App.


I've been studying imtheheadhunter's radios, which can be observed broadcasting 4 different ogg files simultaneously (Tunisia for example), and allow for different maps in rotation for any gametype you please without crashes. Yet my set of oggs just refuse to cooperate.

I've tried...

* Reducing file size of soundfiles to as low as 12khz 16 bit mono before converting to ogg.
* Splitting up soundtracks in Zips to further limit filesize.
* Experimented with the sound code (like posted above) emulating every working source I can find.

Still getting buggered crashes at map switch. At least it works, sort of, so long as we keep playing the same map (multiple rounds). Not very operable for over the internet, but doable for Singleplay or LAN (just requires a quick restart of BF2 for switching maps). So in it's current state this code post is only recommended for Singleplayer, and Co-op LAN if you're willing to restart BF2 between maps. This hasn't been fully tested in actual LAN play with multiple computers (yet), but it works in the Co-op mode playing solo following the above guidelines.


Anyone have any suggestions?


--------------------
Go to the top of the page
 
+Quote Post
imtheheadhunter
post Aug 28 2013, 04:16 AM
Post #13


Debug assertion failed! Text:people == stupid!
Group Icon

Group: Mr. Admin
Posts: 1,005,138
Joined: 8-March 06
From: The freaking Twilight zone!
Member No.: 1,609



Have you tried, using my radios with your sounds? Or your sounds with my radios? Have you been able to encode them with the bf2 sound tools? If not, upload your .wavs and I'll try encoding them for you.


--------------------
Go to the top of the page
 
+Quote Post
MasterChiefRulZ
post Aug 28 2013, 08:50 AM
Post #14


You know the drill...
Group Icon

Group: Mr. Admin
Posts: 10,383
Joined: 31-December 03
From: Home
Member No.: 48



QUOTE
Have you tried, using my radios with your sounds? Or your sounds with my radios?

No, but that's a good thought. I had originally tested my sounds in JONES Pripiyat map, back when I was trying to use the ambient sound code, but not your radios (which is the method I'm emulating now). Makes sense to test it there.

QUOTE
Have you been able to encode them with the bf2 sound tools?

Yes. I attempted working with those tools again and I got it to work, still getting the same results though.



EDIT:

After testing ingame using your radios I noticed two things.

1) It works. I was able to do multiple rounds, and even stop the Co-op server and start up again without the memory crash.
2) It's loud. Despite using your default settings for your radios my ogg sounds were broadcasting through the entire map. The oggs were renamed so no chance of it bleeding off my other code elsewhere.

This leads me to believe that my coding or mounting system with the flags is causing the crashes. Been mounting the oggs in the common client.zip (ambient sounds) but will try elsewhere. I'm wondering why my oggs are audible throughout the map instead of just close to the radios like yours (again, using your settings on your radios)?


--------------------
Go to the top of the page
 
+Quote Post
imtheheadhunter
post Aug 28 2013, 04:09 PM
Post #15


Debug assertion failed! Text:people == stupid!
Group Icon

Group: Mr. Admin
Posts: 1,005,138
Joined: 8-March 06
From: The freaking Twilight zone!
Member No.: 1,609



Are the sounds stereo? If they are, that's why. Stereo sounds can not fade with distance in bf2.


--------------------
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 19th September 2017 - 04:24 PM