Adding ambient Sounds to your Map: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Demagogue (talk | contribs)
Demagogue (talk | contribs)
Line 97: Line 97:
:OR
:OR


::2. As a shortcut, you can directly enter the address of the custom ambient as the value for the "s_shader" spawnarg.  So for my custom ambient, I could have just had a speaker with "s_shader"/"patently_dangerous.pk4/sound/patent/ambient_frozen.ogg".  Then you can add all the other details like "s_volume"/xx, "s_looping"/1, "s_global"/1, "s_omni"/1 directly into the speaker as spawnargs, and not have a custom soundshader at all.  Very convenient.
::2. As a shortcut, you can directly enter the address of the custom ambient as the value for the "s_shader" spawnarg.  So for my custom ambient, I could have just had a speaker with a spawnarg/value of "s_shader" / "patently_dangerous.pk4/sound/patent/ambient_frozen.ogg".  Then you can add all the other details like "s_volume"/xx, "s_looping"/1, "s_global"/1, "s_omni"/1 directly into the speaker as spawnargs, and not have a custom soundshader at all.  Very convenient.


== See also ==
== See also ==

Revision as of 22:16, 14 June 2009

written by greebo

Ok, I will try to explain how to get a nice ambient sound into your map. Note that this ambient sound can be heard everywhere in your level. If you want to have certain areas playing certain ambients, this won't do the trick for you. For that there are two different options, a speaker approach which builds off this tutorial (described at the bottom of this tutorial, Adding_ambient_Sounds_to_your_Map#Localized_Ambient_Sounds_in_one_Area_.28with_Speakers.29), and a trigger or zone approach described at Ambient Sounds, a zone approach (which also gives some pros and cons of each method at the top).

Choose your Ambient Sound

All the Dark Mod ambient sounds are saved in the /sound/ambient/ambience folder. Fire up your preferred Media Player and pick one that's suitable for your map. We will use the sound darknessfalls.ogg for this tutorial.

The according sound shaders are stored in the /sound/tdm_ambient_ambience.sndshd file. Open it with the text editor of your choice and find the name of the sound shader. Our chosen sound is defined in this block:

darknessfalls
{
     description "Made by Darkness_Falls"
     sound/ambient/ambience/darknessfalls.ogg
}

The string outside of the curly braces is the name of the sound shader. We will need it for accessing it later via DarkRadiant.

Create a Speaker

Open up your map in DarkRadiant and right-click somewhere in the orthogonal view and choose "Create Entity...":

createentityss3.jpg

Select speaker. And voilà, the newly created green box is your speaker. You can drag it anywhere you want in your map, the actual place is irrelevant to the ambient.

createdspeakerib9.jpg

Set the correct Key/Values

The following key/values have to be set:

s_shader      <Name of the sound shader to be played>
s_looping     1
s_global      1
s_omni        1
s_volume      -5

In the Entity Inspector it should look like this:

entityinspectoreo1.jpg

A short explanation what these values do:

  • s_shader is the name of the sound shader being played. Nothing special here, just beware of typos.
  • s_looping should be set if you want to repeat your sound over and over. If this is set to 0, your sound will stop after one playback.
  • s_global this the key that makes the sound ambient, so it can be heard everywhere. There is no need for s_min or s_max as the sound plays with the same volume everywhere.
  • s_omni this makes the sound play from every direction, as it is supposed to do for an ambient.
  • s_volume negative values to be subtracted from the volume of your sound 0(max) to -60(silent.) Note that the right volume heavily depends on the loudness of the actual ogg file and the nature of the ambient being played. Typical values might be -2 or --6, -8 etc. whereas -20 is barely heard. Just experiment a bit with the value until you're satisfied...

Save the Map and test it

This is all there is to say, I believe. If you have problems with hearing your chosen ambient, be sure to check for typos in both the entity keys as well as in the sound shaders.

Localized Ambient Sounds in one Area (with Speakers)

added by demagogue

To localize an ambient sound in a particular area, the easiest method is to place the speaker in the area where you want the sound. (As explained at the top of this tutorial, an alternative method is a trigger approach, described at Ambient Sounds, a zone approach. Also see the top of that tutorial for pros and cons between using speakers and using triggers. The following only discusses the speaker method).

Set up a speaker just as described above, with a few important property changes.

  • First, change s_global 0
  • Second, place the speaker in the center of where you want your sound to be localized, or anyway where you want the center of the radius to be for the source of your sound (e.g., if you're using multiple speakers).
  • Third, now you need to add a radius in which the sound will play. Add the following two properties to the speaker: s_maxdistance and s_mindistance.
Set s_maxdistance with a value to fill the area you want to hear it. This is the radius at which the volume tapers to zero. For some reason the distance is not in Doom Units but roughly 1:39.3 Doom Units, that is, 1 s_maxdistance unit = about 40 Doom units. So keep that in mind.
Set s_mindistance with a value only slightly smaller. This is the radius inside of which the volume is at its maximum (defined by s_volume). Between the max and min distance, the volume will increase from zero to s_volume with a nice fade in, or fade out if you go in the opposite direction.
To visually see the radius in Dark Radiant, there is an icon at the top of the Dark Radiant window that looks like a speaker with an X over it. Press it and you can see the maxdistance and mindistance radius. Adjust the placement of the speaker and max and min distances so that it fills the space you want covered by the ambient. Because of the "omni"/1 property, it still sounds like the ambient is coming from all directions (not the speaker), but there is still the nice fade in/fade out effect between the max and mindistances.

You should check for intrusion of the radius into other areas where they are not wanted, and you can control that to some extent with falloff at visportals and doors.

It is possible to have ambient speakers with overlapping radiuses (radii?). If the sound is the same, e.g., if the area requires more than one speaker to fill out, then the sound will be duplicated, but if you watch placement and radius, and pay attention to how the ambient sound works, it won't be too noticable. (Note: if you're having problems with either intrusion into other areas or don't like how the speaker-overlap is working to fill an area, consider using the alternative trigger method mentioned above.)

It is also possible to have ambient speakers with different sounds with slightly overlapping radiuses, and in fact that is often a good thing. As the old ambient fades out, the new one fades in, making for a nice transition.

Here is an example of three ambient sounds set up:

dpiqzm.jpg

And that's it. Once the speaker is placed, it turns itself on and off by itself when you are in the radius. Very simple. Save, dmap and run the map, then walk in and out of the area to test how the ambient works in-game.

Using Custom Ambients

I already described how to use custom ambients in the 'Zoned Approach' wiki page: Ambient_Sounds,_a_zone_approach#Tips_and_Issues, under the heading's "Custom Soundshaders" and "Custom Ambients".
When using normal speakers, the set up is basically the same, but there's a possible shortcut. Here's the set up in a nutshell, and you can read the other wiki entry I just linked for more detail:
First, to package your custom ambient, create a folder inside your .pk4 file (a .zip file renamed .pk4) named "sound", and inside that folder create a new folder with your FM's name or an abbreviated form, i.e., "your_mission's_name.pk4/sound/your_mission's_name". Put your sound file in that second folder. Remember it has to be in .ogg or .wav format.
E.g., my mission is named "Patently Dangerous" and I placed a custom ambient named "ambient_frozen.ogg" in "patently_dangerous.pk4/sound/patent/ambient_frozen.ogg". (Note, during testing, when you run the game through the console, you need to temporarily put the sound file in "darkmod/sound/your_missions_name" to hear it.)
Now to get the custom ambient playing in your speaker, you can:
1. Use a custom soundshader, which you put in the "sound" folder in your .pk4 (or "darkmod/sound" when running the game through the console). Use the name of the entry in that soundshader for your ambient in the speaker's "s_shader" spawnarg. In my case, I could have used "s_shader"/"ambient_frozen".
Read Ambient_Sounds,_a_zone_approach#Tips_and_Issues if you want more detail. Remember for the soundshader to use the .sndshd extension, a custom file name like your_mission_name.sndshd, and the proper syntax for the soundshader's entries.
OR
2. As a shortcut, you can directly enter the address of the custom ambient as the value for the "s_shader" spawnarg. So for my custom ambient, I could have just had a speaker with a spawnarg/value of "s_shader" / "patently_dangerous.pk4/sound/patent/ambient_frozen.ogg". Then you can add all the other details like "s_volume"/xx, "s_looping"/1, "s_global"/1, "s_omni"/1 directly into the speaker as spawnargs, and not have a custom soundshader at all. Very convenient.

See also