UFO:Alien Invasion

Archive => Bugs prior to release 2.3 => Topic started by: Halleth on January 09, 2010, 12:34:27 am

Title: [fixed] R27896 Wrong sounds of shots linked
Post by: Halleth on January 09, 2010, 12:34:27 am
After 3 weeks of break I updated UFO source and started the game. I was really surprised that sounds of assault rifle and machine gun do not match the action. Month ago assault rifle auto-fire sounded like many shots, now I hear only 2. When shooting triple shot, I hear only 1. 25 shots in machine gun return only 4 explosions.

Does anybody else have this problem?
Title: Re: R27896 Wrong sounds of shots linked
Post by: Mattn on January 09, 2010, 09:04:51 am
problem might be the S_PlaySample function - there is a check now that we don't want to replay the same samples if the last one was just 0.5s ago.

maybe this value should be decreased or the assault rifle sounds should go into one sound file.
Title: Re: R27896 Wrong sounds of shots linked
Post by: Halleth on January 09, 2010, 10:28:42 am
OK, I understand that this check can be used for example for footsteps. But in case of automatic weapons, sound should come with every shot, which means frequency much higher than 2Hz (2 times per second). I think the best idea would be to record sounds "single, triple, auto" and so on, for each weapon. Then, 0.5s period would be OK.
Title: Re: R27896 Wrong sounds of shots linked
Post by: bayo on January 09, 2010, 01:58:34 pm
Quote
to record sounds "single, triple, auto"
I think it is bad, because it is harder, than the current way. It is technically not hard to play all samples in the case of UFO:AI, there is no real time gameplay with a lot of sounds triggered at the same time.
Title: Re: R27896 Wrong sounds of shots linked
Post by: Halleth on January 09, 2010, 02:25:59 pm
OK, but all the samples should be triggered at a correct time. So 0.5s limit is artificial. Why was it introduced?
Title: Re: R27896 Wrong sounds of shots linked
Post by: Mattn on January 09, 2010, 02:35:17 pm
because e.g. the load of a savegame triggered a sound for each geoscape message - and they were played too fast after each other.
Title: Re: R27896 Wrong sounds of shots linked
Post by: Halleth on January 09, 2010, 03:48:02 pm
I think the sounds in battlescape are more important than in geoscape. I'd suggest removing 0.5s limit and find some other way for geoscape sounds... But you are the programmers so decision is up to you!
Title: Re: R27896 Wrong sounds of shots linked
Post by: Destructavator on January 09, 2010, 05:25:39 pm
It might be better to simply check if another sound effect is currently still playing, and not base it off of time (seconds, milliseconds, or otherwise).

I do know a bit of audio engineering-type work and have programmed a little sound with other sound engines in C++ before, but not the sound for this project, so I don't know how possible this really is.  (This game uses SDL mixer with C code, yes?)  The audio engines I've used have a function to check "is (sound) still playing?" and "is (any sound) currently playing?" which typically return a boolean value.

For automatic weapons, I can think of several ways (just off the top of my head) of coding the rapid fire to work properly (without mucking up the geoscape issue), but I would need to know which source files to look at and also study the API again to see exactly how the current system/methods are coded.
Title: Re: R27896 Wrong sounds of shots linked
Post by: bayo on January 10, 2010, 12:52:55 am
Quote
simply check if another sound effect is currently still playing
no, because sound can overlap each over.
Title: Re: R27896 Wrong sounds of shots linked
Post by: Destructavator on January 10, 2010, 01:04:55 am
no, because sound can overlap each over.

Huh?  Isn't that the whole point?

I'm not sure if you misunderstood me, or if I'm misunderstanding you here...

The whole thing with the timer was to avoid a bunch of sounds playing at the same time on the geoscape, resulting in loud noise, yes?

What I'm asking is if the current audio engine can sense if an older sound is still playing partway through and hasn't finished yet - and if it is can it simply cancel starting a new one on the geoscape so they don't end up overlapping.  (And then the geoscape issue is fixed without a timer, yet the sounds of weapons on the battlescape don't get messed up, so everything works properly.)

In other words, if a three-second-long beep started one second ago (and therefore has two more seconds to play) cancel starting a new beep, so that sounds don't play overlapping and pile up on the geoscape.

Most audio engines that I've seen have this functionality built-in, to avoid issues just like what was happening on the geoscape before the timer was put in.

Title: Re: R27896 Wrong sounds of shots linked
Post by: bayo on January 10, 2010, 10:09:41 am
If the game request playing sound, it must play the sound. A timer, an overlaping inhibition... is anyway an artificial fix. It must not use an "a priori" filtering, else we request it (as we request to play a sample).

For example, according to mattn reply, the problem is when we load a save game,
then it is easy to configure sound rendering for this computation only.

We can disable sound, use the current way with timer, or inhibite overlaping, thats the same.
The more important is to allow to custom the sound rendering. I dont think it is hard, but i dont know.
Title: Re: R27896 Wrong sounds of shots linked
Post by: Mattn on January 10, 2010, 11:53:45 am
should be fixed now in r27911 - feedback is welcome.
Title: Re: R27896 Wrong sounds of shots linked
Post by: Halleth on January 10, 2010, 12:09:36 pm
Fixed :) Thanks a lot!