Use PitchMod in sounds.lua to prevent loud explosions

Use PitchMod in sounds.lua to prevent loud explosions

Resources to get you going on your new project, or to help you over some emergent problems during your development cycle.

Moderator: Moderators

Post Reply
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Use PitchMod in sounds.lua to prevent loud explosions

Post by jK »

Put all your explosion sounds in a common directory (e.g. "sounds/explosions/") and put the following in your sounds.lua:

Code: Select all

local files = VFS.DirList("sounds/explosions/")
local t = Sounds.SoundItems
for i=1,#files do
	local fileName = files[i]
	t[fileName] = {
		file     = fileName;
		pitchmod = 0.3;
		gainmod  = 0.2;
		maxconcurrent = 8;
	}
end
PS: Explosions are so loud cause they are started in the same simFrame and so are played in sync -> resonance. PitchMod now changes the playback time (e.g. with 0.3 the sounds should have a playback time of 100-130%) and so there isn't a resonance anymore even when the sound is started multiple times in the same simframe.

PPS: THIS IS NOTHING THE ENGINE CAN DO, cause you cannot force a PitchMod globally, i.e. voices already sound extreme strange when played at 110% playback time.
8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: Use PitchMod in sounds.lua to prevent loud explosions

Post by 8611 »

Added as example to wiki:
https://springrts.com/wiki/Sounds.lua#U ... losions.3D
No idea if explosions even still do the "resonance boom noise" but the example it is interessting and seems relevant to have.
Post Reply

Return to “Game Development Tutorials & Resources”