Soundmap?

Blitz3D Forums/Blitz3D Programming/Soundmap?

t3K|Mac(Posted 2005) [#1]
Hi!

I am currently coding a teambased, tactical FPS-Shooter (no arcade style), but i face a problem with sound. how do i create "soundmaps" for each map? the player walks on grass, stone, wood and therefore different running sounds should be played (depending on which texture the player is).
i have no idea about creating a "soundmap". maybe this is the false approach? helpless at the moment ;) maybe some of you have a great idea on how to solve this problem easily.

so long,

Mac


Neochrome(Posted 2005) [#2]
how about using pivots with a radius, if a play gets close to one of these pivots, it changes the sound fx?
i did this it works well, but dont try to do complex levels or if you do, try to make the pivots with a low radius do detailed sound fx


t3K|Mac(Posted 2005) [#3]
sounds good. i'll try this one... thanks for the hint.


KuRiX(Posted 2005) [#4]
You can do soundmaps, they are great. You can do them in the sameway as shadowmaps, etc...

You make a 2D bitmap with color for every zone (green = grass, gray = asphalt, etc...). Then you must know the size of the 3d map and the size of the 2d map (both width and depth) and make a relation so one point in the 3d map is one point in the 2d map. After you test the rgb color of the x,y calculated in the 2d map and you use it.

I do this for my racing game, to get the shadows of the lightmap and the slip factor of the terrain and it works perfect!

Good Luck!


t3K|Mac(Posted 2005) [#5]
ahh nice one... and easy ;) sometimes solutions are so easy.. *shameonme*


JoshK(Posted 2005) [#6]
Associate a group of sound effects with each texture. When the player collides, check to see the texture name of the collided surface, then play the appropriate sound effect. This approach is the best.


t3K|Mac(Posted 2005) [#7]
seems good, but not good enough. what about multitexturing? there you have merged textures... dont think it will work this way...


John Blackledge(Posted 2005) [#8]
This is the essence of what I use:
;-----------------------------
Function PlayerDetCollText()
;-----------------------------
Local collcnt
Local SURFACE_Level,BRUSH_Level,TEX_Level
Local success = 0

	If (EntityCollided(hEntPlayer,TYPE_TERRAIN)) 
		DetCollTextName$ = "TERRAIN"
	Else
		collcnt = CountCollisions(hEntPlayer)
		If collcnt>0
			SURFACE_Level = CollisionSurface(hEntPlayer, collcnt) 
			If SURFACE_Level > 0
				BRUSH_Level = GetSurfaceBrush(SURFACE_Level) 
				TEX_Level = GetBrushTexture(BRUSH_Level) 
				DetCollTextName$ = Upper$(TextureName$(TEX_Level) )
				FreeBrush(BRUSH_Level) 
				FreeTexture(TEX_Level) 
				success = 1
			EndIf
		EndIf
	EndIf

Return success
End Function

DetCollTextName$ gives me the texture name of what I'm walking on.
Then I have a lookup list of texturenames > sound files.
The appropriate sound file is 'marked' for next use, and is then played after a timer-count has expired.


KuRiX(Posted 2005) [#9]
The problem is that this can only be used with blitz collision system. I use ODE for physics and collisions, so the soundmap must be used.

Otherway the texture method is good.


Banshee(Posted 2005) [#10]
Doesn't the GetBurshTexture() make a seperate instance of the texture in memory by copying it though? I thought it worked that way because you have to manually re-apply it to the entity to register any changes.

I may very well be wrong as I have not used the command much, but I think your putting a lot of CPU time into copying a texture that you are only then only reading the name of, which is quite an expensive way of doing things isn't it?


John Blackledge(Posted 2005) [#11]
@Kuriz: ODE? Yes, you're right this does use the Blitz collision method. I can't help you there.

@Becky: As you say, but if I use FreeBrush(BRUSH_Level) and FreeTexture(TEX_Level) then everything's ok; this is based on one of Mark Sibly's bits of code.

If fact my footsteps sound is based on a timer (let's say, every half second?). On the timeout this code is called, so CPU loss is kept to a minimum. Even so, if I deactivate the code I can't detect any difference in performance.

It _does_ seem like a very wasteful way to get a texture name (under 'my' feet) - to have to create and destroy a brush to do that.
If anyone can think of a better way then I'm open to ideas.


Banshee(Posted 2005) [#12]
You have the memory address of the entity already from the variable that holds it's handle so you just need to work out the offset to where the texture name is stored. It'll probably be different for every different mesh (depending upon the b3d internal format) but a quick for..next loop should be able to find it.

I would have thought that would be more efficient, at least, on a technical level. As you say though, but as you say it depends upon how much optimisation your program needs as to whether it's worth the extra hassle...