project-navigation
Personal tools

Author Topic: [fixed] R27896 Wrong sounds of shots linked  (Read 3715 times)

Offline Halleth

  • Rookie
  • ***
  • Posts: 52
    • View Profile
[fixed] R27896 Wrong sounds of shots linked
« 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?
« Last Edit: January 10, 2010, 12:09:52 pm by Halleth »

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: R27896 Wrong sounds of shots linked
« Reply #1 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.

Offline Halleth

  • Rookie
  • ***
  • Posts: 52
    • View Profile
Re: R27896 Wrong sounds of shots linked
« Reply #2 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.

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: R27896 Wrong sounds of shots linked
« Reply #3 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.

Offline Halleth

  • Rookie
  • ***
  • Posts: 52
    • View Profile
Re: R27896 Wrong sounds of shots linked
« Reply #4 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?

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: R27896 Wrong sounds of shots linked
« Reply #5 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.

Offline Halleth

  • Rookie
  • ***
  • Posts: 52
    • View Profile
Re: R27896 Wrong sounds of shots linked
« Reply #6 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!

Offline Destructavator

  • Combination Multiple Specialty Developer
  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1908
  • Creater of Scorchcrafter, knows the zarakites...
    • View Profile
Re: R27896 Wrong sounds of shots linked
« Reply #7 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.

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: R27896 Wrong sounds of shots linked
« Reply #8 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.

Offline Destructavator

  • Combination Multiple Specialty Developer
  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1908
  • Creater of Scorchcrafter, knows the zarakites...
    • View Profile
Re: R27896 Wrong sounds of shots linked
« Reply #9 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.

« Last Edit: January 10, 2010, 01:10:07 am by Destructavator »

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: R27896 Wrong sounds of shots linked
« Reply #10 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.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: R27896 Wrong sounds of shots linked
« Reply #11 on: January 10, 2010, 11:53:45 am »
should be fixed now in r27911 - feedback is welcome.

Offline Halleth

  • Rookie
  • ***
  • Posts: 52
    • View Profile
Re: R27896 Wrong sounds of shots linked
« Reply #12 on: January 10, 2010, 12:09:36 pm »
Fixed :) Thanks a lot!