Sounds.lua: Difference between revisions

From Spring
Jump to navigationJump to search
mNo edit summary
Knorke (talk | contribs)
→Default: some rework
Line 2: Line 2:




==Default==
==Location==
*missing file not crash the engine (=?)
sounds.lua is stored in the <code>gamedata\</code> directory of a Spring Game.
*not mandatory for the game(verified)
*not defaut file loaded by engine (=?)
*missing values have defaut (=?)


'''WARNING : synthax not verified ! (contain some random errors)'''
==Purpose==
 
Can be used to create ''SoundItems'' from audio files.
 
Beside simply "linking" to an audio file, ''SoundItems'' can use various tags to alter the playback of the file, ie adjust volume.
 
 
--[[DefaultsForSounds = { -- this are default settings
 
file = "ThisEntryMustBePresent.wav",
 
gain = 1.0,
 
pitch = 1.0,
 
priority = 0,
 
maxconcurrent = 16, --- some reasonable limits
 
--maxdist = FLT_MAX, --- no cutoff at all
 
},
 
--- EXAMPLE ONLY!
 
]]


These ''SoundItems'' can then be used in [[Units-UnitDefs | UnitDefs]] and [[Weapon-weaponDefs]] (what about Lua ???)


This file is not mandatory.


==Example==
===default sounds===
sounds.lua as found in <code>base\springcontent.sdz\gamedata\</code>
<pre>
--- Valid entries used by engine: IncomingChat, MultiSelect, MapPoint
--- other than that, you can give it any name and access it like before with filenames
local Sounds = {
local Sounds = {
SoundItems = {
IncomingChat = {
--- always play on the front speaker(s)
file = "sounds/beep4.wav",
in3d = "false",
},
MultiSelect = {
--- always play on the front speaker(s)
file = "sounds/button9.wav",
in3d = "false",
},
MapPoint = {
--- respect where the point was set, but don't attuenuate in distace
--- also, when moving the camera, don't pitch it
file = "sounds/beep6.wav",
rolloff = 0,
dopplerscale = 0,
},
ExampleSound = {
--- some things you can do with this file


SoundItems = {
--- can be either ogg or wav
 
file = "somedir/subdir/soundfile.ogg",
--- RESERVED FOR SPRING, DON'T REMOVE
 
IncomingChat = {
 
file = "sounds/killyu1.wav",
 
rolloff = 0.1,
 
maxdist = 10000,
 
priority = 100,
 
maxconcurrent = 1,
 
},
 
 
 
MultiSelect = {
 
file = "sounds/cestpour.wav",
 
rolloff = 0.1, --- how fast it becomes more quiet in the distance (0 means aleays the same loudness regardless of dist)
 
maxdist = 10000,--- cutoff distance
 
priority = 50,---  sounds with lwoer priority are more likely to get cut off > 0 will never be cut of (priorities can be negative)
 
maxconcurrent = 1,--- this sound will not be played more than  at a time
 
dopplerscale = 0,--- how unit / camera speed affects the sound, to exagerate it, use values > 1, 0 completely disables the effect
 
in3d = "false",--- non-3d sounds do always came out of the front-speakers (or the center one)
 
preload = false,
 
gain = 1.1,--- loudness, > 1 is louder, < 1  is more quiet, you will most likely not set it to 0
 
pitch = 0.3,--- > 1 -> high pitched, < 1 lowered
 
looptime = 0,--- you can loop it for X miliseconds


},
--- loudness, > 1 is louder, < 1  is more quiet, you will most likely not set it to 0
gain = 1,


--- > 1 -> high pitched, < 1 lowered
pitch = 1,


--- how unit / camera speed affects the sound, to exagerate it, use values > 1
--- dopplerscale = 0 completely disables the effect
dopplerscale = 1,


MapPoint = {
--- when lots of sounds are played, sounds with lwoer priority are more likely to get cut off
--- priority > 0 will never be cut of (priorities can be negative)
priority = 0,


file = "sounds/imnotgay.wav",
--- this sound will not be played more than 16 times at a time
maxconcurrent = 16,


rolloff = 0.1,
--- cutoff distance
maxdist = 20000,


maxdist = 10000,
--- how fast it becomes more quiet in the distance (0 means aleays the same loudness regardless of dist)
rolloff = 1,


priority = 100,
--- non-3d sounds do always came out of the front-speakers (or the center one)
 
--- 3d sounds are, well, in 3d
maxconcurrent = 1,
in3d = true,


--- you can loop it for X miliseconds
looptime = 0,
},
},
--- END RESERVED
--manu = {
repair = {
},
arrived = {
},
select = {
},
deactivate = {
},
activate = {
},
ok= {
},
cant= {
},
working= {
},
build= {
},
underattack = {
file = "sounds/killyu1.wav",
rolloff = 0.1,
maxdist = 10000,
priority = 100, --- higher numbers = less chance of cutoff
maxconcurrent = 3, ---how many maximum can we hear?
},
--},
--WEAPONS
},
},
}
}


return Sounds


===zero-K=


return Sounds
</pre>

Revision as of 23:42, 5 July 2011

Gamedata/Sounds.lua


Location

sounds.lua is stored in the gamedata\ directory of a Spring Game.

Purpose

Can be used to create SoundItems from audio files. Beside simply "linking" to an audio file, SoundItems can use various tags to alter the playback of the file, ie adjust volume.

These SoundItems can then be used in UnitDefs and Weapon-weaponDefs (what about Lua ???)

This file is not mandatory.

Example

default sounds

sounds.lua as found in base\springcontent.sdz\gamedata\

--- Valid entries used by engine: IncomingChat, MultiSelect, MapPoint
--- other than that, you can give it any name and access it like before with filenames
local Sounds = {
	SoundItems = {
		IncomingChat = {
			--- always play on the front speaker(s)
			file = "sounds/beep4.wav",
			in3d = "false",
		},
		MultiSelect = {
			--- always play on the front speaker(s)
			file = "sounds/button9.wav",
			in3d = "false",
		},
		MapPoint = {
			--- respect where the point was set, but don't attuenuate in distace
			--- also, when moving the camera, don't pitch it
			file = "sounds/beep6.wav",
			rolloff = 0,
			dopplerscale = 0,
		},
		ExampleSound = {
			--- some things you can do with this file

			--- can be either ogg or wav
			file = "somedir/subdir/soundfile.ogg",

			--- loudness, > 1 is louder, < 1  is more quiet, you will most likely not set it to 0
			gain = 1,

			--- > 1 -> high pitched, < 1 lowered
			pitch = 1,

			--- how unit / camera speed affects the sound, to exagerate it, use values > 1
			--- dopplerscale = 0 completely disables the effect
			dopplerscale = 1,

			--- when lots of sounds are played, sounds with lwoer priority are more likely to get cut off
			--- priority > 0 will never be cut of (priorities can be negative)
			priority = 0,

			--- this sound will not be played more than 16 times at a time
			maxconcurrent = 16,

			--- cutoff distance
			maxdist = 20000,

			--- how fast it becomes more quiet in the distance (0 means aleays the same loudness regardless of dist)
			rolloff = 1,

			--- non-3d sounds do always came out of the front-speakers (or the center one)
			--- 3d sounds are, well, in 3d
			in3d = true,

			--- you can loop it for X miliseconds
			looptime = 0,
		},
	},
}

return Sounds

===zero-K=