Too many same sound spawns are allowed on selecting the ... - Page 2

Too many same sound spawns are allowed on selecting the ...

Discuss your problems with the latest release of the engine here. Problems with games, maps or other utilities belong in their respective forums.

Moderator: Moderators

Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: Too many same sound spawns are allowed on selecting the ...

Post by Auswaschbar »

Some rework
soundfiles can no longer be palyed, instead only SoundItems are played.

You can now specify SoundItems like this:

Code: Select all

--- 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 = {
			file = "sounds/beep4.wav",
		},
		MultiSelect = {
			file = "sounds/button9.wav",
		},
		MapPoint = {
			file = "sounds/beep6.wav",
		},
		MyAwesomeSouns = {
			file = "sounds/booooom.wav",
			gain = 2.0, --- for uber-loudness
			pitch = 0.2, --- bass-test
			priority = 15, --- very high
			maxconcurrent = 1, ---only once
			maxdist = 500, --- only when near
		},
		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
		},
	},
}

return Sounds
Priority has the following effect:
When there are not enought sources, then the sound with the lowest priority is stopped (if its 0 or below). This has the effect that sounds with positive priority are never stopped at all.

SoundItems are accessed like normal wav-files has been before. If you access a raw sound file now, a SoundItem with the defaults is created for you.

Additionally, multiple SoundItems can use on single file with different settings, this is very efficient, they only use 1 shared buffer.

Please note that here are also the previously introduced enginesounds. These are put into springcontent.sdz, and not having them in a mod will not fail. So without sounds.lua, you will have the exact behaviour as in 0.78.2.1 except the crash when those files are not present.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Too many same sound spawns are allowed on selecting the ...

Post by Argh »

First off, that's capital work!

I had no idea you'd get here this fast. Now I'm going to have to see if I can get a working EXE and start playing around!

May I ask a few questions before I do, though?

1. How does this affect the current COB call to play a sound? I.E., is that COB callout via GET going to be changed, or will it behave like it always has, but now it's referencing a SoundItem? Sorry in advance... I'm using that throughout P.U.R.E., I'd like to know if major problems are going to happen ASAP, obviously.

2. Name collisions. Does it matter, if the table entry is the same as the name of the file (other than .wav)?

3. From your answer, I'm guessing that old-skool backwards compatibility will be maintained, by building the table automatically, so that older games do not crash or lack functional sound.

How can we print that file out? That would provide an easy path to utilizing the advanced features for all of us lazy game designers... because I wouldn't have to type out the initial entries by hand. I have... meh, I have 235 sound files in P.U.R.E., a few more in World Builder... and I expect that to grow before RC4 is (finally) released. We're talking hours and hours of labor here, if I have to type it all out by hand.

Anything to help automate it would be... nice. If it's already building this table... just tell me how I'd print it back out with Echo.

Also... if we build a file... it will override the auto-build, correct? Or will that get appended? If so, what happens, when, say, a Weapon calls for a sound?

Do I need to make sure it's using the new entry, and if I get my initial list built by printing out the table that's auto-generated... if it's appending stuff, just to be safe, it'll be using some new name (i.e., "HugeBoom01" already exists in the game's tables, therefore name HugeBoom.wav with a new entry, "HugeBoom02")?

Sorry, I'm sure that the above won't be entirely clear, but basically I would like, ideally, to print out the sounds currently in the game... add any new ones manually... and I don't want the custom values to get overridden by Spring, if it auto-builds based on the contents (and sub-contents) of /Sounds.

Also, /Sounds has been supporting multiple directory levels for some time now, just FYI, I'm already using that for Unit replies, etc., so make sure the parser takes that into account, when building the file. You've probably already done all that, but I thought I'd just ask and make sure...

4. Can we have a Lua callout to PlaySoundItem(string name, {params})? Pretty please? Then you wouldn't have to hard-code doing stuff like random pitch-shifts... you're probably way ahead of me there, but I thought I'd go ahead and make that a formal request anyhow.

5. Can we pre-load sounds via a param? Certain things cause a fairly noticeable drive-hit, it'd be really nice to store them in RAM. Not everything, mind you, that would be crazy, just certain things that we want to have immediately available.

6. Looping? Pleeeeeeeease? Doing it in COB is fail, sounds cannot often be made to fit very precise framelengths, and doing it in Lua would get veeeeeery expensive and very time-consuming to maintain, because Lua can't read the length (in absolute time) of a soundfile. So we'd have to get that information manually from sound editors, hand-enter it, etc., which seems like a massive bother, when the engine can read that and store it for us. Just askin', man- you've already done more than I was hoping for anyhow, this is a major step up.
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: Too many same sound spawns are allowed on selecting the ...

Post by Auswaschbar »

Argh wrote:1. How does this affect the current COB call to play a sound? I.E., is that COB callout via GET going to be changed, or will it behave like it always has, but now it's referencing a SoundItem? Sorry in advance... I'm using that throughout P.U.R.E., I'd like to know if major problems are going to happen ASAP, obviously.
When you make a COB sound call, it will:
1) check if you have specified a SoundItem with the exact name $x, if yes, play it
2) if no, behave like before (so play a wav, maybe with "sounds/$x.wav" appended)
Argh wrote:2. Name collisions. Does it matter, if the table entry is the same as the name of the file (other than .wav)?
You can do that, and spring will play the Item instead of the wav.
Argh wrote:3. From your answer, I'm guessing that old-skool backwards compatibility will be maintained, by building the table automatically, so that older games do not crash or lack functional sound.
Yes, when not doing anything, you get the same behaviour as before (with the little change that all sounds have Maxconcurrency=16)
Argh wrote:How can we print that file out? That would provide an easy path to utilizing the advanced features for all of us lazy game designers... because I wouldn't have to type out the initial entries by hand. I have... meh, I have 235 sound files in P.U.R.E., a few more in World Builder... and I expect that to grow before RC4 is (finally) released. We're talking hours and hours of labor here, if I have to type it all out by hand.

Anything to help automate it would be... nice. If it's already building this table... just tell me how I'd print it back out with Echo.
I will definitely do something like this, so wait until you edit all by hand. (TODO1)
Argh wrote:Also... if we build a file... it will override the auto-build, correct? Or will that get appended? If so, what happens, when, say, a Weapon calls for a sound?
For clarification: there will be no auto-build table. If you call for a sound you don't have specified a SoundItem for, it will load the regular wav-file like it has been before, and simply assign default values. It does not matter if you have SoundItems for other sounds.
Argh wrote:Do I need to make sure it's using the new entry, and if I get my initial list built by printing out the table that's auto-generated... if it's appending stuff, just to be safe, it'll be using some new name (i.e., "HugeBoom01" already exists in the game's tables, therefore name HugeBoom.wav with a new entry, "HugeBoom02")?
To keep it simple, the auto-generated (and only spring-internal) names for the SoundItems are the same as their filenames. ANd names need to be unique, if you make another entry with the same name, the old one will be overwritten. (TODO2: print warning / done)
Argh wrote:Also, /Sounds has been supporting multiple directory levels for some time now, just FYI, I'm already using that for Unit replies, etc., so make sure the parser takes that into account, when building the file. You've probably already done all that, but I thought I'd just ask and make sure...
The parser is not interested in directory names. It will generate a SoundItem once you call for a sound from lua, cob, tdf, so it takes the name from you. It doesn't even matter if its in "sounds/", you can specify any place you want.
Argh wrote:4. Can we have a Lua callout to PlaySoundItem(string name, {params})? Pretty please? Then you wouldn't have to hard-code doing stuff like random pitch-shifts... you're probably way ahead of me there, but I thought I'd go ahead and make that a formal request anyhow.
First, lua can already play sounditems. Creating new sound items on the fly in mid-game is not good, because it need to invoke whole lua-parser-stuff. But it will be usefull to create a new SoundItem from a lua-callin (TODO3: lua callin SoundItem generation).
Argh wrote:5. Can we pre-load sounds via a param? Certain things cause a fairly noticeable drive-hit, it'd be really nice to store them in RAM. Not everything, mind you, that would be crazy, just certain things that we want to have immediately available.
Agreed (TODO4 / done).
edit: some sounds are already preloaded. if you type "/debuginfo sound" ingame, you will see the number of SoundItems, SoundSources, SoundBuffers (1 buffer per wav-file) and the size of all buffers currently loaded.
Argh wrote:6. Looping? Pleeeeeeeease? Doing it in COB is fail, sounds cannot often be made to fit very precise framelengths, and doing it in Lua would get veeeeeery expensive and very time-consuming to maintain, because Lua can't read the length (in absolute time) of a soundfile. So we'd have to get that information manually from sound editors, hand-enter it, etc., which seems like a massive bother, when the engine can read that and store it for us. Just askin', man- you've already done more than I was hoping for anyhow, this is a major step up.
Agreed (TODO5 / done).

Random thought 1: much todo, may take some time
Random thought 2: should make some propper documentation somewhere
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: Too many same sound spawns are allowed on selecting the ...

Post by Auswaschbar »

Code: Select all

--- Valid entries: IncomingChat, MultiSelect, MapPoint
local Sounds = {
	SoundItems = {
		IncomingChat = {
			file = "sounds/beep4.wav",
			preload, --- you got it
			looptime = "1000", --- in miliseconds, can / will be stopped like regular items
		},
		MultiSelect = {
			file = "sounds/button9.wav",
		},
		MapPoint = {
			file = "sounds/beep6.wav",
		},
	},
}

return Sounds 
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Too many same sound spawns are allowed on selecting the ...

Post by SpliFF »

Auswaschbar wrote: Random thought 2: should make some propper documentation somewhere
I'm writing a mod howto/guide atm. If you just put all your notes in this thread I'll combine it all into something coherent. My plan is to then include the mod guide in the spring source Documentation/ folder and also linked via the wiki so it can be easily found.
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: Too many same sound spawns are allowed on selecting the ...

Post by Auswaschbar »

Just added ogg/vorbis support for Sounds, behaves just like regular wav files.
This includes:
  • loadable from anywhere inside VFS (map, mod, or content archive
  • can be called from anywhere, COB, LUA, sounds.lua
  • respects all parameters from SoundItem-definition
Please keep in mind they are decompressed and kept in RAM after the first usage (or after loading with preload), so you should not make the decompressed size too large.

edit: it is not meant to be used for music.
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Too many same sound spawns are allowed on selecting the ...

Post by SpliFF »

i tried to run ca-r3812 without otacontent on linux using spring-git latest and got the old beep9.wav missing error (spring aborts). I thought this update or a previous one had fixed the whole missing sounds issue for good? Maybe i misunderstand what was done but can't this be resolved via a patch and updated springcontent? A don't believe a missing beep really qualifies as a fatal error.
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: Too many same sound spawns are allowed on selecting the ...

Post by Auswaschbar »

SpliFF wrote:i tried to run ca-r3812 without otacontent on linux using spring-git latest and got the old beep9.wav missing error (spring aborts). I thought this update or a previous one had fixed the whole missing sounds issue for good? Maybe i misunderstand what was done but can't this be resolved via a patch and updated springcontent? A don't believe a missing beep really qualifies as a fatal error.
works for me
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Too many same sound spawns are allowed on selecting the ...

Post by Argh »

Wonderful! I'll test it when I have a working EXE, this is going to be great!
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: Too many same sound spawns are allowed on selecting the ...

Post by TradeMark »

slogic wrote:You know, as much i select the same unit as much a new select sound will be spawned in the game. My soundcard blows up with distortions. Again, is this a feature or not? I think sound should be blocked until the previous one is finished playing. I would like to point: this issue is concerning a single unit selection only.
ive had such problem, but not by selecting unit...

i fixed it by setting the "global sound volume" in game settings to 50, which was on 100 by default.
TheThinker
Posts: 46
Joined: 02 Jun 2008, 21:34

Re: Too many same sound spawns are allowed on selecting the ...

Post by TheThinker »

Hey everyone. I'm quite pleased that Argh and others are working on this audio problem.

I'm an Ubuntu Jaunty user and strangely the Spring engine (at least on the CA mod anyway) has performance issues with sound sources above 1! Quite sad, since this hasn't happened before with the previous engines of spring. I've thought long and hard if it is PulseAudio getting in the way, so I'm just going to see if there's a way to disable or remove it. Does anyone concur with this idea?
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Too many same sound spawns are allowed on selecting the ...

Post by lurker »

Argh is whatnow? He did write a nice description of the new audio features, at least.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Too many same sound spawns are allowed on selecting the ...

Post by Argh »

I certainly didn't code it- that was all Auswaschbar's brilliant work, not mine.

I merely proposed some specifications and did some testing while it was being built, and then documented the resulting work when I put it to use.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Too many same sound spawns are allowed on selecting the

Post by Jools »

Auswaschbar wrote:
Argh wrote:4. Can we have a Lua callout to PlaySoundItem(string name, {params})? Pretty please? Then you wouldn't have to hard-code doing stuff like random pitch-shifts... you're probably way ahead of me there, but I thought I'd go ahead and make that a formal request anyhow.
First, lua can already play sounditems. Creating new sound items on the fly in mid-game is not good, because it need to invoke whole lua-parser-stuff. But it will be usefull to create a new SoundItem from a lua-callin (TODO3: lua callin SoundItem generation).
Is this still topical? It would actually be good to have a callin for playing a SoundItem from lua, since Spring.PlaySoundFile sometimes just plays the wav-sound and skips the other parameters defined in sounds.lua.
Auswaschbar wrote:
Argh wrote:5. Can we pre-load sounds via a param? Certain things cause a fairly noticeable drive-hit, it'd be really nice to store them in RAM. Not everything, mind you, that would be crazy, just certain things that we want to have immediately available.
Agreed (TODO4 / done).
edit: some sounds are already preloaded. if you type "/debuginfo sound" ingame, you will see the number of SoundItems, SoundSources, SoundBuffers (1 buffer per wav-file) and the size of all buffers currently loaded.
How does /debuginfo sound work? I don't get any output.
Post Reply

Return to “Help & Bugs”