Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Maverick_BB110CB on November 23, 2015, 06:32:41 pm

Title: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 23, 2015, 06:32:41 pm
Hi guys,

Trying to get help with what I thought was a problem of my computer/installation I stumbled upon something that might actually be an issue of the game itself. I noticed this behavior years ago when I first played FSopen but I didn't care much, until recently when it annoyed me enough to start looking for a solution. So here's the thing:

When your ship's hull gets hit by enemy lasers (because your shields are down) you should hear a sound. In original retail FS1 it sounded like this: https://tinyurl.com/ncdndbq (https://tinyurl.com/ncdndbq).
In FSopen and all mods I've played so far (FSport, STR, BP AoA) when your hull gets hit you can't hear a thing. You hear only the shields.

After a few guys gave me some directions on IRC a did a little 'research" to find this:

In retail FS2 you get a sound for both shields and hull but they both sound exactly the same.
So I checked all the .vp's and it looks like this:

Retail FreeSpace 1 - freespace.vp
s_hit_2.wav - sound for shields
l_hit.wav - sound for hull

FreeSpace Open - sparky_fs2.vp
s_hit_2.wav - sound for shields - different from FS1 but seems correct
l_hit.wav - exactly the same as s_hit_2.wav

FreeSpace Port - fsport3_5.vp
s_hit_2.wav - sound for shields - same as retail FS1
l_hit.wav - file is missing

This would explain why I can't hear any sound for hull in FSport and STR but it doesn't explain why I can't hear it in FSopen main campaign.
And here is where I have 2 theories, both of which might be true at the same time actually:

1. Volition made a mistake while putting the wav's together - assigning 2 filenames to 1 actual sound while loosing the sound that sould be named l_hit.wav

2. FSopen doesn't trigger a sound when the hull is hit at all, meaning the l_hit.wav, even though present, is actually unused.


Now I don't know much about coding but I have a feeling that this can be quite easily checked in the code.

Hope I've put this together comprehensively enough. And ofcourse, it might be that I'm totally wrong and the whole thing works differently than I imagine :)
Title: Re: Sound of player's hull being hit missing
Post by: AdmiralRalwood on November 23, 2015, 07:33:06 pm
I actually looked into this last night, and the answer is "neither of those things"; the source is trying to play the sound, and l_hit.wav being missing from FSPort doesn't matter as it can still see the l_hit.wav from FS2. In fact, there are two hull-hit sounds: l_hit.wav and m_hit.wav (for laser hull hits against the player and missile hull hits against the player, respectively).

However, these two sounds happen to be two sounds that the sounds.tbl comments describe as 3D sounds but actually are defined as 2D sounds (but with extraneous min/max distance information defined, which only matters for 3D sounds). The source tries to play them as 3D sounds, which should be doomed to failure: as long as the hit position isn't the exact location of the camera, the distance between where the sound is trying to play and where the player is listening from should always be >0, which means that it will never work with a 2D sound.

Here's the bizarre part: the relevant code has not, as far as I can tell, been changed since the original Volition source code release. This should never have worked. If it's working with the retail executable, that means something very screwball is going on here.
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 23, 2015, 08:27:09 pm
Well, quite frankly, it is possible that I'm wrong about the sound playing in retail FS2. I tried playing the exact same mission with exact same difficulty and doing exactly the same things in both retail executable and FSopen with no mods. And there was a difference. In retail I always heard the sound more times before getting killed and I heard it even after the respective shield quadrant was down. So basically I kept hearing it until I got killed. In FSopen it got quiet after the respective shield quadrant was down.

But there could be at least 100 reasons for this.  Maybe the AIs in retail are shooting differently in some way? They could be, for example, hitting the remaining quadrants. Or maybe the FSopen engine plays the sounds differently - it waits for the sound to end before it can be played again?
I don't know but what I mean is - there is no way I can be 100% sure that what I heard was actually the l_hit.wav playing and not the s_hit_2.wav. So yes, maybe the retail doesn't work correctly too and I just had a feeling that it does.

But one question remains: You think Volition intentionally used one identical sound under two filenames, where each is used for a different action?
Title: Re: Sound of player's hull being hit missing
Post by: AdmiralRalwood on November 23, 2015, 08:36:28 pm
Or maybe the FSopen plays the sounds differently - it waits for the sound to end before it can be played again?
Well, it has a bit of code whereby two impact sounds can't play within 50 milliseconds of each other... but, again, that code hasn't changed since the Volition source.

If you want to be 100% sure that what you hear is actually the l_hit.wav sound, all you have to do is provide a different l_hit.wav file. Or a different s_hit_2.wav file, I guess.
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 23, 2015, 09:11:23 pm
Uuuhm, how exactly could I do that? I had to implement my "advanced hacking skills" just to be able to look into the .vp's :D

Sorry for stupid questions. It's just that I don't know much about modding or coding really.
Title: Re: Sound of player's hull being hit missing
Post by: Dragon on November 24, 2015, 12:10:02 am
It's simple, really. There should be a "data" folder in your FS2 folder. It has the same folder structure as the VPs (if some of the folders are not present, you can create them). Anything you put in there, with the same filename and location as a retail asset, will be loaded instead of that asset. Using mod folders is recommended for serious modding, but for testing purposes, sticking a replacement sound in the main FS2 data folder should work.
Title: Re: Sound of player's hull being hit missing
Post by: AdmiralRalwood on November 24, 2015, 02:36:32 am
Using mod folders won't work with the retail executable, which is the thing that needs testing.
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 24, 2015, 03:50:37 pm
So I learned how to replace the files using VPmage (and demaged my installation in the process :D ). Actually it wasn't so complicated after all.
I replaced both l_hit.wav and s_hit_2.wav with two very distinct sounds so that I can easily tell what's playing. Aaand...

I'm sorry, I was wrong. The retail FS2 does not play the l_hit.wav when the hull is hit. It's quiet, same as FSopen.
s_hit_2.wav is played correctly but that wasn't the issue.

So, is there any way to fix this?
Title: Re: Sound of player's hull being hit missing
Post by: Galemp on November 24, 2015, 04:14:27 pm
And implement m_hit.wav while we're at it.
Title: Re: Sound of player's hull being hit missing
Post by: AdmiralRalwood on November 24, 2015, 04:19:28 pm
It might be as simple as fixing the sounds.tbl entries; now that I know retail didn't handle it differently, I don't have to look for other causes.
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 24, 2015, 04:30:20 pm
And implement m_hit.wav while we're at it.

Actually, you're right. That one seems to be not working correctly as well.
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 26, 2015, 09:23:47 pm
So I educated myself further and managed to come up with something to fix this.

First I tried deleting the parameters of 3D sound for l_hit.wav and m_hit.wav in sounds.tbl but that didn't work. So I opened sounds.tbl from retail Freespace 1 and just copied the parameters from there. Works like a charm :)

So a made a small "lhitfix01-snd.tbm" file which looks like this and put it in <freespace 2 root dir>\data\tables:

Code: [Select]
#Game Sounds Start

$Name: +nocreate 36
    +Filename: l_hit.wav
    +Preload: no
    +Volume: 1.00
    +3D Sound:
        +Attenuation start: 30
        +Attenuation end: 100

$Name: +nocreate 37
    +Filename: m_hit.wav
    +Preload: no
    +Volume: 1.00
    +3D Sound:
        +Attenuation start: 30
        +Attenuation end: 100

#Game Sounds End

Works also with all mods I could quickly try.

Aditionally, I replaced the l_hit.wav in sparky_fs2.vp with the one from retail Freespace 1. Now everything is as it should be (for me at least).

I guess this is not exactly a standard way or the most efficient, but it works for me :)
Title: Re: Sound of player's hull being hit missing
Post by: Dragon on November 27, 2015, 12:03:18 pm
Wait, is the sound table modular now? I've been wishing for it back when I was actively modding FS2... :)
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 27, 2015, 12:15:09 pm
Wait, is the sound table modular now? I've been wishing for it back when I was actively modding FS2... :)

According to wiki it is. I wasn't sure about the syntax though but after few hours of searching I found these two topics:

http://www.hard-light.net/forums/index.php?topic=81311.0 (http://www.hard-light.net/forums/index.php?topic=81311.0)

http://www.hard-light.net/forums/index.php?topic=89343.0 (http://www.hard-light.net/forums/index.php?topic=89343.0)
Title: Re: Sound of player's hull being hit missing
Post by: X3N0-Life-Form on November 27, 2015, 01:34:40 pm
Wait, is the sound table modular now? I've been wishing for it back when I was actively modding FS2... :)
It's been for a while now :)
Title: Re: Sound of player's hull being hit missing
Post by: Goober5000 on November 27, 2015, 04:31:13 pm
So I educated myself further and managed to come up with something to fix this.

First I tried deleting the parameters of 3D sound for l_hit.wav and m_hit.wav in sounds.tbl but that didn't work. So I opened sounds.tbl from retail Freespace 1 and just copied the parameters from there. Works like a charm :)

So a made a small "lhitfix01-snd.tbm" file which looks like this and put it in <freespace 2 root dir>\data\tables:

Are you saying that the reason l_hit and m_hit didn't work is that they had the wrong parameters in sounds.tbl?
Title: Re: Sound of player's hull being hit missing
Post by: AdmiralRalwood on November 27, 2015, 08:08:55 pm
They've had the wrong parameters from the beginning. They're the two sounds we have a special exemption in the code for; because otherwise they'd generate "Unexpected extra value" warnings (because they're 2D sounds that specify 3D sound min/max distance, which retail parsing just ignored).
Title: Re: Sound of player's hull being hit missing
Post by: Goober5000 on November 27, 2015, 11:28:46 pm
Ah, I see exactly what you mean.  Okay, new PR opened: https://github.com/scp-fs2open/fs2open.github.com/pull/474
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 28, 2015, 08:48:10 am
Are you saying that the reason l_hit and m_hit didn't work is that they had the wrong parameters in sounds.tbl?

So it seems. Because changing them fixed the problem :)
Maybe there are also some issues in the code but that's way beyond my understanding.
Title: Re: Sound of player's hull being hit missing
Post by: Goober5000 on November 28, 2015, 12:48:00 pm
Yep, all that's necessary is to change the column that has 0 for 2D sound to 1 for 3D sound.  That PR has code changes to do this automatically for those two retail sounds.
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 28, 2015, 02:13:31 pm
Yep, all that's necessary is to change the column that has 0 for 2D sound to 1 for 3D sound.

That much I figured but I used the SCP syntax which uses a slightly different way to define what is and what is not a 3D sound.

That PR has code changes to do this automatically for those two retail sounds.

Does that mean that the code will make some changes to sounds.tbl and that my .tbm file is no longer needed?
Title: Re: Sound of player's hull being hit missing
Post by: Dragon on November 28, 2015, 03:30:17 pm
No and yes, respectively. The code will not alter the table itself, but will treat the sounds in a special way that will fix the problem. So no need for the table-side fix.
Title: Re: Sound of player's hull being hit missing
Post by: jg18 on November 28, 2015, 06:29:38 pm
Hmm, I wonder how the newly re-added sounds affect enhanced sound.

Maverick_BB110CB, could you try something for me?

As the instructions here (http://hard-light.net/wiki/index.php/Enhanced_sound) describe, could you get the OpenAL32.dll from here (http://www.mediafire.com/download/csdkp5psozmq2b1/OpenAL32.dll) and put it in your FreeSpace2 folder? It's the OpeNAL Soft (http://kcat.strangesoft.net/openal.html) audio driver, version 1.16, admittedly a bit out of date since the latest is now 1.17. You could get 1.17 instead if you like.

Then as long as you're using a nightly build made after June 1 of this year, try playing again and see how it sounds.

Enhanced sound increases the number of audio channels from 32 to 128, and it increases the concurrent playback limits for those two sounds to 3 instead of the retail limit of 1. ("Concurrent playback limit" is a limit on how many instances of the sound can play at the same time.)

Depending on how the result sounds, we could increase or decrease that limit of 3.

Thanks!


Also, I would never be a backseat admin, but I thought I'd note that fixing sounds that have been broken since retail seems like quite an achievement and a significant contribution to the community....
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 28, 2015, 09:31:20 pm
Hmm, I wonder how the newly re-added sounds affect enhanced sound.

Maverick_BB110CB, could you try something for me?

As the instructions here (http://hard-light.net/wiki/index.php/Enhanced_sound) describe, could you get the OpenAL32.dll from here (http://www.mediafire.com/download/csdkp5psozmq2b1/OpenAL32.dll) and put it in your FreeSpace2 folder? It's the OpeNAL Soft (http://kcat.strangesoft.net/openal.html) audio driver, version 1.16, admittedly a bit out of date since the latest is now 1.17. You could get 1.17 instead if you like.

Then as long as you're using a nightly build made after June 1 of this year, try playing again and see how it sounds.

Enhanced sound increases the number of audio channels from 32 to 128, and it increases the concurrent playback limits for those two sounds to 3 instead of the retail limit of 1. ("Concurrent playback limit" is a limit on how many instances of the sound can play at the same time.)

Depending on how the result sounds, we could increase or decrease that limit of 3.

Thanks!


Also, I would never be a backseat admin, but I thought I'd note that fixing sounds that have been broken since retail seems like quite an achievement and a significant contribution to the community....

I already have the OpelAL Soft 1.17, I just don't use it as I don't like the way it sounds. It adds a wild reverb to most sounds and the whole thing sounds like you were sitting in an elevator shaft or something. Maybe it's about some settings but I didn't find any? But if not for this I'd certainly use it because the surround effect is definitely appealing.

Anyway, I tried and it sounds pretty much OK I think. Didn't notice any significant change.
I tried on headphones. Tomorrow I'll try yet on 5.1 but I don't expect anything different.

And I'd like to note that I would probably never be able to do this if the guys on IRC and here wouldn't have pointed me in a right direction. So, big thanks to everyone involved :)
Title: Re: Sound of player's hull being hit missing
Post by: jg18 on November 28, 2015, 10:45:39 pm
I already have the OpelAL Soft 1.17, I just don't use it as I don't like the way it sounds. It adds a wild reverb to most sounds and the whole thing sounds like you were sitting in an elevator shaft or something. Maybe it's about some settings but I didn't find any? But if not for this I'd certainly use it because the surround effect is definitely appealing.

Anyway, I tried and it sounds pretty much OK I think. Didn't notice any significant change.
I tried on headphones. Tomorrow I'll try yet on 5.1 but I don't expect anything different.
The reverb effect sounds like EFX might be turned on. Check in the launcher that the "Enable EFX" checkbox under Audio is unchecked. You can also confirm in a debug log (fs2_open.log) that EFX is not enabled. Instructions on generating and finding the log can be foudn here (http://www.hard-light.net/forums/index.php?topic=56279.msg1180359#msg1180359). The log will also confirm which audio playback device is being used and whether enhanced sound is turned on. You might as well also check that the playback device that the game is using matches the one you select in the launcher.

Which build of FS2 Open are you using?

With these two soudns, enhanced soudn will only make a difference if your hull is getting hit multiple times in a short timespan, which might not happen in practice *shrug*
Title: Re: Sound of player's hull being hit missing
Post by: AdmiralRalwood on November 29, 2015, 01:17:59 am
With these two soudns, enhanced soudn will only make a difference if your hull is getting hit multiple times in a short timespan, which might not happen in practice *shrug*
On top of that, the code has a hardcoded timer for weapon impact sounds that prevent two of them from being told to play within 40 milliseconds of each other, completely separate from (and vastly pre-dating, since it's :v:-original) the enhanced sound code.
Title: Re: Sound of player's hull being hit missing
Post by: jg18 on November 29, 2015, 02:05:00 am
Oh yeah, I forgot about that timer. Any idea why it was put there? Maybe to make better use of the 16 audio channels available to :v: at the time? Or because having lots of impact sounds play close to one another soudns bad or is confusing or something?

Whatever the reason, maybe we should reduce or eliminate the timer if enhanced soudn is enabled?

EDIT: Reading your signature again makes me wonder if there even was a good reason...
Title: Re: Sound of player's hull being hit missing
Post by: zookeeper on November 29, 2015, 04:23:50 am
Oh yeah, I forgot about that timer. Any idea why it was put there? Maybe to make better use of the 16 audio channels available to :v: at the time? Or because having lots of impact sounds play close to one another soudns bad or is confusing or something?

Probably both. It might not sound bad if the sounds are spatially separated enough, but generally simply playing the exact same sound several times with only a small delay between them sounds awful.
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 29, 2015, 06:54:09 am
So i tried on 5.1, not much difference. The only drawback is that s_hit and l_hit come mostly from the rear speakers and are a bit less loud which makes them a little harder to notice. Which shouldn't be because they are that kind of 'Oh ****, I'm in trouble!!' sounds.

With these two soudns, enhanced soudn will only make a difference if your hull is getting hit multiple times in a short timespan, which might not happen in practice *shrug*

I was playing Surrender, Belisarius! - when you shoot Alpha 2 you get shot pretty rapidly, even on easy difficulty. Sometimes the sound even plays multiple times during 1 second. But I don't think it sounds bad, currently set limits seem to be working just fine.

The reverb effect sounds like EFX might be turned on. Check in the launcher that the "Enable EFX" checkbox under Audio is unchecked. You can also confirm in a debug log (fs2_open.log) that EFX is not enabled. Instructions on generating and finding the log can be foudn here (http://www.hard-light.net/forums/index.php?topic=56279.msg1180359#msg1180359). The log will also confirm which audio playback device is being used and whether enhanced sound is turned on. You might as well also check that the playback device that the game is using matches the one you select in the launcher.

Tried with EFX off but the crazy reverb is still there.
Here's my log, if it's any good to you:
http://pastebin.com/5WTFXudy (http://pastebin.com/5WTFXudy)

Which build of FS2 Open are you using?

Currently this one - fs2_open_3_7_3_SSE_20151126_040c1f3
Title: Re: Sound of player's hull being hit missing
Post by: jg18 on November 29, 2015, 12:57:14 pm
Oh yeah, I forgot about that timer. Any idea why it was put there? Maybe to make better use of the 16 audio channels available to :v: at the time? Or because having lots of impact sounds play close to one another soudns bad or is confusing or something?

Probably both. It might not sound bad if the sounds are spatially separated enough, but generally simply playing the exact same sound several times with only a small delay between them sounds awful.
Why have concurrent playback limits greater than 1, then?

So i tried on 5.1, not much difference. The only drawback is that s_hit and l_hit come mostly from the rear speakers and are a bit less loud which makes them a little harder to notice. Which shouldn't be because they are that kind of 'Oh ****, I'm in trouble!!' sounds.

I was playing Surrender, Belisarius! - when you shoot Alpha 2 you get shot pretty rapidly, even on easy difficulty. Sometimes the sound even plays multiple times during 1 second. But I don't think it sounds bad, currently set limits seem to be working just fine.
Okay, I guess things work fine as is with the timer, then. Not sure why it's  playing out of the rear speakers.

Tried with EFX off but the crazy reverb is still there.
Here's my log, if it's any good to you:
http://pastebin.com/5WTFXudy (http://pastebin.com/5WTFXudy)
Thanks for the log. EFX is indeed enabled.
Code: [Select]
EFX version: 1.0
  Max auxiliary sends: 4
If EFX is disabled, then the line should instead say
Code: [Select]
EFX enabled: NO

You're using wxLauncher? Which version?
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 29, 2015, 01:28:15 pm
Okay, I guess things work fine as is with the timer, then. Not sure why it's  playing out of the rear speakers.

First I thought that it's because the hit is actually happening behind the position of the camera. But then I noticed that the sound comes from behind even when my front shield quadrant is being hit.

You're using wxLauncher? Which version?

Uuuuhm, is it possible that the actual version of the launcher is not displayed anywhere?  :confused:  I just can't find it. Not even in the .exe file properties.
But I think it's the latest one because I installed it just a few days ago. I was using the old launcher 5.5g before.
Title: Re: Sound of player's hull being hit missing
Post by: zookeeper on November 29, 2015, 02:02:32 pm
Why have concurrent playback limits greater than 1, then?

I was referring only to the timer delay that was mentioned. Of course you want to allow concurrent playback, but it can still make sense to have have a timer so that another instance of the same sound can't start before the previous one has played for at least X milliseconds.

Of course, I don't know whether that timer really has benefits in practise or not, or whether it could just as well be removed. It might very well be that the timer was primarily intended to save channels, and it helps in preventing a silly aural effect so incredibly rarely that it's not worth the cost in code complexity. Not to mention the problem if it prevents a mod from doing something intentionally.
Title: Re: Sound of player's hull being hit missing
Post by: Goober5000 on November 29, 2015, 05:27:25 pm
Also, I would never be a backseat admin, but I thought I'd note that fixing sounds that have been broken since retail seems like quite an achievement and a significant contribution to the community....

An astute observation.  I've awarded Maverick a Gold Star.  It's not every day that a new member tracks down and pinpoints the root cause of a retail bug. :yes:
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on November 29, 2015, 05:46:01 pm
Woow, thanks!! :)
But some credit should definitely go also to AdmiralRalwood and others.
Title: Re: Sound of player's hull being hit missing
Post by: Echelon9 on December 01, 2015, 11:45:01 pm
Well done Maverick.
Title: Re: Sound of player's hull being hit missing
Post by: jr2 on December 02, 2015, 10:08:49 am

You're using wxLauncher? Which version?

Uuuuhm, is it possible that the actual version of the launcher is not displayed anywhere?  :confused:  I just can't find it. Not even in the .exe file properties.
But I think it's the latest one because I installed it just a few days ago. I was using the old launcher 5.5g before.

Open up

%APPDATA%\wxlauncher\wxlauncher.log

That will list the version in the first line, I believe the build of the FSO .exe being polled in the second line, and the date and time of the current wxLaucnher run in the third line.
Title: Re: Sound of player's hull being hit missing
Post by: Maverick_BB110CB on December 02, 2015, 03:24:28 pm
Open up

%APPDATA%\wxlauncher\wxlauncher.log

That will list the version in the first line, I believe the build of the FSO .exe being polled in the second line, and the date and time of the current wxLaucnher run in the third line.

Oh, I'm sorry, I forgot to write it here. Niffiwan gave me exactly these instructions on IRC that same day. My version is 0.10.1.