Jump to content
The Dark Mod Forums

Recommended Posts

EDIT: Don't bother reading this entire thread if you don't care to... I posted a thread in Documentation that explains this much better. The only really relevant part is the last post on adding sounds to SoundProp

 

Brief note: It looks like D3 already has a system in place for playing different footstep sounds based on the material you're walking on. Here's the code in idActor

 

void idActor::PlayFootStepSound( void ) {
const char *sound = NULL;
const idMaterial *material;

if ( !GetPhysics()->HasGroundContacts() ) {
 return;
}

// start footstep sound based on material type
material = GetPhysics()->GetContact( 0 ).material;
if ( material != NULL ) {
 sound = spawnArgs.GetString( lva( "snd_footstep_%s", gameLocal.sufaceTypeNames[ material->GetSurfaceType() ] ) );
}
if ( *sound == '\0' ) {
 sound = spawnArgs.GetString( "snd_footstep" );
}
if ( *sound != '\0' ) 
{
 StartSoundShader( declManager->FindSound( sound ), SND_CHANNEL_BODY, 0, false, NULL );
 PropSoundDirect( static_cast<const char *>( localSound ), true, false );
}
}

 

In game_local.h:

static const char *  sufaceTypeNames[ MAX_SURFACE_TYPES ];	// text names for surface types

 

In game_local.cpp:

const char *idGameLocal::sufaceTypeNames[ MAX_SURFACE_TYPES ] = {
"none",	"metal", "stone", "flesh", "wood", "cardboard", "liquid", "glass", "plastic",
"ricochet", "surftype10", "surftype11", "surftype12", "surftype13", "surftype14", "surftype15"
};

 

Conclusion:

 

When a footstep happens, D3 checks the material of the ground. Several materials are already defined, including metal, stone, wood, liquid, glass, etc...

 

However, D3 did not really record sounds for different materials and implement this. If you look in player.def, there is only one "snd_footstep" and it is linked to "player_sounds_footstep" (the default footstep sound).

 

This is a link to the soundshader, and you can see the actual soundshader files that get played in player.sndshd:

 

player.sndshd

player_sounds_footstep {

 

minDistance 1

maxDistance 30

//volume  -5

volume  -1

no_dups

 

sound/ed/player/steps/step01.wav

sound/ed/player/steps/step02.wav

sound/ed/player/steps/step03.wav

sound/ed/player/steps/step10.wav

 

}

 

player_footstep_dirt {

minDistance 1

maxDistance 15

volume  0

no_dups

 

sound/player/footsteps/dirt_01.wav

sound/player/footsteps/dirt_02.wav

sound/player/footsteps/dirt_03.wav

sound/player/footsteps/dirt_04.wav

sound/player/footsteps/dirt_05.wav

}

 

So while it looks like there are sounds recorded, and a soundshader defined for players stepping on dirt, there is no "snd_footstep_dirt" in the player.def, so this will never be called.

 

Stay tuned for the next post in this thread where I'll try and guess how we actually make use of this.

Edited by Ishtvan
Link to post
Share on other sites

[EDIT: Dammit, after writing this, I found a tutorial on the exact same topic in D3World from January! Here is the link to that, it is better in some respects than this one:

 

D3World Tutorial

http://www.doom3world.org/phpbb2/viewtopic.php?t=8503 ]

 

 

How to add different footstep sounds for different materials

 

Step 0. Sound Guys: Record the footstep sounds

Self explanatory :)

 

Step 1. Mapper/Texture Editor Guys: Write the Material File

 

-If you created a new material, make sure you set the surface type for that material to the appropriate thing (eg, Wood, Stone, etc).

 

The bad news is: It looks like parsing of material files is precompiled and we don't have the source for it, so we cannot add a new surface type keyword in addition to the existing ones. EDIT: THIS IS WRONG! You can add a surface type to the definition in GameLocal.cpp, and apparently it will be automatically parsed in the material file. So we can add as many surfaces as we want by changing that line in game_local.cpp

 

Here's the list of surfaces in vanilla D3 (from game_local.cpp) :

List of D3 Surface Types Allowed on a Material:

none, metal, stone, flesh, wood, cardboard, liquid, glass, plastic,

ricochet, surftype10, surftype11, surftype12, surftype13, surftype14, surftype15

 

How to add the surface type in a material file

Very simple: Just put the surface name on a line by itself.

Example from hell.mtr

textures/hell/qfloor
{
     stone // <--- there's the surface type!
     qer_editorimage	textures/hell/qfloor_ed
     bumpmap addnormals( textures/hell/qfloor_local.tga, heightmap
           (textures/hell/qfloor_h.tga, 5 ) )
     diffusemap  textures/hell/qfloor.tga
     specularmap  textures/hell/qfloor_s.tga
}

 

So you just put the surface type in there. I don't think it has to be at the top, that's just a coincidence.

 

Step 2. Sound Guys: Add the footstep sound to the entity def file

 

In the entity.def (or the base definition if the entity inherits sounds from another entity), you must include the key/value pair:

KEY: "snd_footstep_<surface name>"

VALUE: <the sound shader you want it to play>

 

Example:

 

To add sounds for the player stepping on wood surfaces:

 

In player.def

"snd_footstep_wood" "footstep_wood"

 

NOTE: In this case, this means we have to have a soundshader called "footstep_wood." The soundshader name doesn't have to be called footstep, but to work properly, the key on the left MUST be "snd_footstep_<surface>", where surface is one of the defined surface types.

 

Step 3. Sound Guys: Write the soundshader

Assuming a soundshader does not already exist for footsteps on the surface in question, you'll have to write the soundshader yourself.

 

There is already a lot of documentation on iddevnet, etc. on how to write soundshaders, so I'll just go over it briefly. Assuming you have recorded some wood footstep sounds and put them in sounds/footsteps/wood_01.ogg, wood_02.ogg etc.

 

In some soundshader file: (it could be in player.sndshd, or we could make our own footstep.sndshd to group all footsteps together, that's an organizational question and doesn't matter for the purposes of the example)

 

footstep_wood {
     minDistance	1
     maxDistance	15
     volume  0
     no_dups

     sound/footsteps/wood_01.ogg
     sound/footsteps/wood_02.ogg
     sound/footsteps/wood_03.ogg
     // and so on
}

 

You're done!

 

If the mapper now places the texture with surface type "wood" in their map, and the player steps on it, it will play the correct sound.

 

Appendix 1. Problem with vanilla D3

D3 knows when to play a footstep sound because in the entity .def file, there are a bunch of animation defs, and in them, it will say something like

 

Within the def file, within the def of an animation (eg anim_runforward)

frame10 leftfoot

frame15 rightfoot

 

There are different animations for running, walking etc. So D3 will play the footstep sound more frequently for running than for walking. However, in real life, running vs walking also effects the volume of your footsteps (because you're coming down harder on the ground when running).

 

As is, D3 does not change the volume to reflect which movement animation is playing (run/walk/etc). So we will have to modify PlayFootStepSound to take this into account as well. IMO, the most simple modification would be to set some movement state when we are walking/running/crouch walking, etc. And then have PlayFootStepSound check this movement state and modify the volume of the soundshader before playing it.

Edited by Ishtvan
Link to post
Share on other sites

Appendix 2. Sound Prop (or Step 4: Adding your sound to sound prop)

 

SUBJECT TO CHANGE because I'm still finalizing soundprop code

 

I'm writing sound prop to work in a very similar fashion to how actual sounds are played. This means that, just as you added "snd_footstep_wood" to the entity def, to have that sound propagated, you will add "sndpS_footstep_wood", and instead of a global soundshader for the value of this key, you put in a global propagated sound (I'm still working on how to define those). This is how you'd do it with the current soundprop build (SUBJECT TO CHANGE):

 

Add to the player.def file:

"sndpS_footstep_wood" "sndpGS_footstep_default:1,1"

 

Note: in sndpS, the S stands for "suspicious sound" as opposed to sndpE, which stand for "environmental sound." In sndpGS, the "G" stands for "global," and the "S" still stands for "suspicious sound"

 

When you call a global sound from sound prop, you can modify some values from the default. The syntax is: "sndpGS_<global sound name>:<volume multiplier>,<duration multiplier>"

 

This is so we don't have to write a bunch of definitions for different materials, AI with louder footsteps, etc, we can just modify the volume and duration of the same footstep.

 

In this example, I assumed footstep_default was the same as footstep_wood. These modifiers are optional, so you could have also written:

"sndpS_footstep_wood" "sndpGS_footstep_default" and it would work the same.

 

Supposing we want a stone footstep, that's louder and lasts slightly longer (due to reverb or something). You'd write the following:

In player.def

"sndpS_footstep_stone" "sndpGS_footstep_default:1.5,1.3"

 

So the volume of footstep_stone will be 1.5x the volume of the default footstep (in dB), and the duration will be 1.3x the duration of the default footstep (in milliseconds).

 

Side note: As I understand it, sounds are psychoacoustically perceived as being louder as the duration increases up to 200 mS, above which they sound the same (assuming the amplitude doesn't change for the whole sound duration, which is the assumption we're making for "impulse sound" sound propagation). So for our purposes, propagating a sound with duration over 200 mS will not change anything.

Edited by Ishtvan
Link to post
Share on other sites

Update: I noticed in the D3 sounds file (pak003.pk4), they have several sounds for "stoneimpact_*" and "woodimpact_*" I dont know if it's implemented yet. They're probably intended to be the sound a bullet would make, but maybe we could use some of them for arrows as well. The wood ones sound good!

Link to post
Share on other sites

What I was saying was: Soundshaders play from a list of several random sounds. D3 has a bunch of sounds, so while I know that we are working on many sounds for arrows colliding, etc, if we hear one that's already included in D3 that we like, we can include that in the "arrow on wood" soundshader too, in addition to our own sounds, as yet another random sound to play. The more the sounds slightly vary, the more convincing the game sounds, IMO.

Edited by Ishtvan
Link to post
Share on other sites

It looks like D3 uses 4 for it's standard footstep... so if you sound designers think it's okay in D3 then we could do the same.

 

Here the soundshader for D3 player footsteps. They use 4 for the deault footstep, and use some more for the "stepping on dirt" footstep, which I don't believe was ever actually used in the game...

 

From Player.sndshd (the soundshader for the player sounds)

player_sounds_footstep {

minDistance	1
maxDistance	30
//volume  -5
volume  -1
no_dups

sound/ed/player/steps/step01.wav
sound/ed/player/steps/step02.wav
sound/ed/player/steps/step03.wav
sound/ed/player/steps/step10.wav

}

player_footstep_dirt {
minDistance	1
maxDistance	15
volume  0
no_dups

sound/player/footsteps/dirt_01.wav
sound/player/footsteps/dirt_02.wav
sound/player/footsteps/dirt_03.wav
sound/player/footsteps/dirt_04.wav
sound/player/footsteps/dirt_05.wav
}

Link to post
Share on other sites
  • 5 months later...

Sorry to ask again, but I'm curious what the status is of the footstep sounds? I remember hearing that Theo recorded a bunch. Do we have them, but they're not on CVS yet?

 

The mappers are starting to make maps with carpet and wood and a variety of surfaces, and I wanted to make sure these play the correct sounds, as well as test out soundprop with them. Do we have any placeholder sounds for walking on carpet, wood, tile, etc?

Link to post
Share on other sites
  • 3 weeks later...

I'm still waiting for Spar to fix dotP before uploading any new sounds to CVS.. But if he can't get it sorted out maybe he can extract the data somehow anyway. (I'm keeping the design-doc on the dotProject site, so it's not a good idea to upload any sounds when I can't mark them as finished or see what the files should be named etc.. Will cause confusion down the road)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...