Jump to content

Footsteps too loud.


Deadlyforce
 Share

Recommended Posts

I could not get it to work. Kept getting a nil value error using it in the FPSPlayer.lua

Well you can only lower the volume of a source. The footsteps are just being played as a sound and not a source.

But you can make some minor additions to the script to use a source to play the footstep sounds.

In the Script:Start function:

...

...

self.sound.footsteps.concrete.step[4] = Sound:Load("Sound/Footsteps/Concrete/step4.wav")

self.sound.footsteps.concrete.jump = Sound:Load("Sound/Footsteps/Concrete/jump.wav")

self.source = Source:Create() --add this

 

and in the Script:UpdateFootsteps() function, change the end of the code to look like this:

...

...

if t-self.lastfootsteptime>repeatdelay then

self.lastfootsteptime = t

local index = math.random(1,4)

--self.sound.footsteps.concrete.step[index]:Play() --commented out

self.source:SetSound(self.sound.footsteps.concrete.step[index]) --added

self.source:SetVolume(0.05) --added

self.source:Play() -- added

end

 

Keep in mind you will need to create sources for the other sounds being played for Jump, damage, etc... if you want to control their volume.

  • Upvote 2

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

All this is in the API. It's rather well documented, although some of the names of things are a little confusing. I can't say for Macklebee, but I just read the API to find an example, then use the example in my own code. It's also partly experience. I learnt everything by experimenting and looking at examples.

Link to comment
Share on other sites

Keep in mind you will need to create sources for the other sounds being played for Jump, damage, etc... if you want to control their volume.

 

You don't necessarily need to have multiple sources. You could just use the SetSound function and change which sound to play. Not sure if this would cut off the sound if there was already one playing though.

Link to comment
Share on other sites

You don't necessarily need to have multiple sources. You could just use the SetSound function and change which sound to play. Not sure if this would cut off the sound if there was already one playing though.

True, but that is exactly why I suggested to make multiple sources. If its ambient music and only one should play in any given area or time then yes you can use the same source. But one source for all of your sounds will result in cutoff and only one sound playing at a time.

window = Window:Create()

context = Context:Create(window)

 

sound = {}

sound[1] = Sound:Load("Sound/Ambient/submarineroom03.wav")

sound[2] = Sound:Load("Sound/Doors/fdn_door_automatic_servo_driven_close_short_05.wav")

sound[3] = Sound:Load("Sound/Machinery/fdn_lift_apartments_lift_travelling.wav")

 

choice = 1

source = Source:Create()

source:SetSound(sound[choice])

source:Play()

 

while window:KeyDown(Key.Escape)==false do

if window:Closed() then return false end

 

if window:KeyHit(Key.Space) then

choice = choice + 1

if choice>3 then choice = 1 end

source:SetSound(sound[choice])

source:Play()

end

 

Time:Update()

context:Sync(true)

end

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

  • 3 months later...

Coding isn't exactly my forte, but I really want to learn. I'm confused.

 

So, self.source = Source:Create()

Must be added to every sound loaded, or just once, because it's one player controller that emits the sound?

Does anyone have a modified FPSPlayer.lua I can look over and perhaps learn from?

Ubuntu 14.04 / 64bit. Dell XPS430, Intel Core 2 Quad Q8300 @ 2.50GHz, 4Gb Ram, Radeon HD 6670, Leadwerks Pro edition (Steam).

Link to comment
Share on other sites

Hey! I actually managed to make it work all by my lonesome. Posting the script here for reference.

 

Had to remove the [index] from the jump sound, but I assume that's because there's only a single sound for that event(?)

FPSPlayer.lua

Ubuntu 14.04 / 64bit. Dell XPS430, Intel Core 2 Quad Q8300 @ 2.50GHz, 4Gb Ram, Radeon HD 6670, Leadwerks Pro edition (Steam).

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...