Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Test Builds => Topic started by: m!m on October 08, 2017, 11:28:54 am

Title: Sound set test builds
Post by: m!m on October 08, 2017, 11:28:54 am
Some time ago, there was a request for "advanced" sound effects (http://www.hard-light.net/forums/index.php?topic=81311.msg1635805) which would allow to specify multiple sound files for a single sound.tbl entry. I even wrote an implementation of that feature but for some reason it never got merged and that was a good thing. The code was so horribly written that I refuse to even look at it now. So, now I decided that it may be a good time to revisit that problem but with a better solution than the one I used originally.

Test builds are available here: http://swc.fs2downloads.com/builds/test/soundSets/

Even if you are not a modder who might use this feature you can still try the builds above to test if the normal sound playback still works.

If you are a modder who might use this feature then you will need some documentation on how this new feature works. The new sound set syntax is based on the existing SCP syntax (http://www.hard-light.net/wiki/index.php/Sounds.tbl#SCP_Syntax) so if you already use this then it should be easy to use this new feature. Other than the feature described in the original thread, these sound sets do not use a separate section in the sounds table and can be used in all sections documented in the sounds.tbl wiki page.

You start your sound entry as usual with $Name to give your sound a name. Then you can add as many sounds as you like with separate +Entry parameters (but there has to be at least one entry):
Code: [Select]
$Name: TestSet
+Entry: L_Sidearm.wav
+Entry: L_Scalpel.wav
+Entry: L_Flail2.wav
+Entry: L_Prom_R.wav
+Entry: L_Prom_S.wav

This is a complete sound entry that will use the default values for all entries but you probably want to change those. Every option listed here must come in the exact sequence they are listed here but you can omit an option and it will use a default value.

+Cycle type: This specified how the next entry of the various sound entries is selected. Possible values are sequential and random. These types do exactly what their names suggest. The first uses the sounds sequentially one after another and the second type selects a random sound entry every time the sound is played. The way the sequential mode works at the moment is that one sound entry only has a single global index counter so if two sources use the same sound effect then the first source will use sound 1, the second will use sound 2 and if source one wants to play the sound again it will use sound 3 of the list.

+Preload: Same as with the usual SCP syntax

+Volume: Specifies the volume of the sound but now this accepts a range of possible values from which a random value will be chosen every time the sound is played. The syntax is a list of floating point numbers like this:
Code: [Select]
+Volume: (0.4 0.6)
This will cause the sound to use 40% to 60% volume.

+3D Sound, +Priority, +Limit: Same as with the usual SCP syntax.

+Pitch: This is another new addition to the sound sets which lets you specify the pitch of the sound. This is also a random range like volume:
Code: [Select]
+Pitch: (0.5 2.0)
The values must be greater than zero and 1.0 will use the original sound without changing the pitch. What these values mean is quite technical so I would suggest trying different values and checking how they sound like.

Here is an example of a full sound set table:
Code: (soundSets-snd.tbm) [Select]
#Game Sounds Start

$Name: TestSet
+Entry: L_Sidearm.wav
+Entry: L_Scalpel.wav
+Entry: L_Flail2.wav
+Entry: L_Prom_R.wav
+Entry: L_Prom_S.wav

+Cycle type: sequential
+Preload: False
+Volume: (0.4 0.6)
+3D Sound:
+Attenuation start: 50
+Attenuation end: 400
+Priority: Medium-Low
+Limit: 8
+Pitch: (0.5 2.0)

#Game Sounds End

Let me know if you find any bugs or if the existing behavior should be changed in any way. The current implementation and table syntax is not set in stone so if you have a suggestion for how this could be improved please let me know here.
Title: Re: Sound set test builds
Post by: AdmiralRalwood on October 08, 2017, 05:03:53 pm
Nice work! :yes:
Title: Re: Sound set test builds
Post by: Spoon on October 10, 2017, 04:14:08 am
This looks amazing, this should improve the soundscape a lot. (Now I can stop having multiple substitute weapon entries just to have sound variation)

But I dont think you uploaded the right build here? I've been trying the fs2_open_3_8_1_soundSets_x64_SSE2 one, but it gives me:
Error: sounds.tbl(line 1314):
Error: Missing required token: [+Preload:]. Found [+Entry: Light laser.ogg] instead.
Title: Re: Sound set test builds
Post by: m!m on October 10, 2017, 04:17:57 am
I am pretty sure that those builds are correct since that error message would look very different if the build didn't support sound sets.

What is your entire table? Maybe you found a bug in the parsing code.
Title: Re: Sound set test builds
Post by: Spoon on October 10, 2017, 05:49:16 am
I am pretty sure that those builds are correct since that error message would look very different if the build didn't support sound sets.
Actually, thats how those error messages always look when a build doesn't support some table feature. I would know, I've had a very long history of running into these things  :p
And I even checked with another build just to be sure, and it gave me that exact same error message.

What is your entire table? Maybe you found a bug in the parsing code.


Code: [Select]
$Name: 330
+Filename: Light laser.ogg
+Entry: Light laser.ogg
+Cycle type: sequential
+Preload: no
+Volume: (0.55 0.65)
+3D Sound:
        +Attenuation start: 250
        +Attenuation end: 1200
+Priority: High
+Limit: 10 ; VX-02 fired
+Pitch: (0,8 1,2)
I've tried a bunch of different variations, removing and adding bits. But any of the new features throw up an error. I don't think its a parsing code bug.
Title: Re: Sound set test builds
Post by: m!m on October 10, 2017, 05:56:26 am
+Filename: is not valid if you want to create a sound set and is only still supported for backwards compatibility. +Entry effectively replaces +Filename with the slight difference that you can have multiple entries :p

Actually, thats how those error messages always look when a build doesn't support some table feature. I would know, I've had a very long history of running into these things  :p
And I even checked with another build just to be sure, and it gave me that exact same error message.
The +Filename triggers the "old" parsing code so that explains why you see the same message in both builds. I only looked at the new parsing code so that explains why I didn't understand where that error was coming from.

So, just remove the +Filename line and it should work.
Title: Re: Sound set test builds
Post by: Spoon on October 10, 2017, 07:06:25 am
+Filename: is not valid if you want to create a sound set and is only still supported for backwards compatibility. +Entry effectively replaces +Filename with the slight difference that you can have multiple entries :p

Actually, thats how those error messages always look when a build doesn't support some table feature. I would know, I've had a very long history of running into these things  :p
And I even checked with another build just to be sure, and it gave me that exact same error message.
The +Filename triggers the "old" parsing code so that explains why you see the same message in both builds. I only looked at the new parsing code so that explains why I didn't understand where that error was coming from.
Aaah okay then!

So, just remove the +Filename line and it should work.
It werks!

Boy, does adding a wide pitch range make for... interesting sound effects  :lol:
But even just a slight pitch change, already makes a stream of pew pew sounds, sound more diverse. I'm going to be messing with these sound sets for a while.


(Also, has it always been possible to use letters instead of numbers for $Name: ?  :nervous: Because that sure would have been more easy to organize tables with, rather than these dumb numbers! :P I always assumed  :v: had sounds.tbl indexed with numbers for some hardcoded reason)

(Also also, damnit m!m, stop adding all these neat features that will delay WoD's release even more! :P )
Title: Re: Sound set test builds
Post by: m!m on October 10, 2017, 07:10:34 am
(Also, has it always been possible to use letters instead of numbers for $Name: ?  :nervous: Because that sure would have been more easy to organize tables with, rather than these dumb numbers! :P I always assumed  :v: had sounds.tbl indexed with numbers for some hardcoded reason)
It has been like that for some time already. It's documented on the wiki (http://www.hard-light.net/wiki/index.php/Sounds.tbl#.24Name:).

(Also also, damnit m!m, stop adding all these neat features that will delay WoD's release even more! :P )
I only have to fix a minor issue until I have a working setup of basic impact decals so I guess I'm looking forward to seeing the release of WoD in 2030 :p
Title: Re: Sound set test builds
Post by: Spoon on October 10, 2017, 07:58:14 am
.
Title: Re: Sound set test builds
Post by: Spoon on October 10, 2017, 10:06:46 am
After adding a bunch of sound sets, I can only add that this is fantastic  :yes:


However, I ran in a game breaking bug, that is most likely not directly related to this particular soundset feature. But it happens in this build.
Ingame messages are bugging out (using Axem's message script). It gets stuck on the first message that plays, and never plays anything after that. I dont know if this is specific to this particular build, or just something that got introduced with recent nightlies. (It's always kind of a hassle for me to test these things with WoD, since I have to comment out multilock in weapon entries, and now with these sound sets, I have an extra thing to comment out before I can run a 'regular' build.)

Edit: Actually tested with BP, latest nightly has no issues, this build also causes the messages in BP to freeze after the first one.
Since message length is tied to sound file length, it might actually be related to this sound change?
Title: Re: Sound set test builds
Post by: Kiloku on October 10, 2017, 11:02:31 am
I just left Audio class at college (Game Dev course) where the prof was talking about pitch shifting a single repeating sound randomly makes it  have great variation. Then I get home to this thread! Awesome!
Title: Re: Sound set test builds
Post by: m!m on October 10, 2017, 11:03:35 am
Edit: Actually tested with BP, latest nightly has no issues, this build also causes the messages in BP to freeze after the first one.
Since message length is tied to sound file length, it might actually be related to this sound change?
Thank you for this information. That should make it much easier to find the issue. I'm currently working on the decal stuff but I'll fix this issue ASAP.

EDIT: I found an issue where an assertion was triggered when a voice file was played. I updated the test branch and new builds should be available relatively soon. Until those are compiled, could you rerun your test with a debug build (I assume that you were using a release build since playing any voice file would crash the engine)? The bug I fixed is consistent with the issue you reported so hopefully I fixed the right issue...
Title: Re: Sound set test builds
Post by: Spoon on October 10, 2017, 12:07:31 pm
Running the debug build, this assert error pops up on the first message played

Code: [Select]
ASSERTION: "pitch > 0.0f" at ds.cpp:1280
 Pitch may not be less than zero!

Assert: "pitch > 0.0f"
File: ds.cpp
Line: 1280
Pitch may not be less than zero!

ntdll.dll! ZwWaitForSingleObject + 10 bytes
KERNELBASE.dll! WaitForSingleObjectEx + 156 bytes
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
kernel32.dll! BaseThreadInitThunk + 13 bytes
[...]
[ This info is in the clipboard so you can paste it somewhere now ]


Use Debug to break into Debugger, Exit will close the application.

Int3(): From C:\projects\fs2open-github-com\code\osapi\dialogs.cpp at line 355
ntdll.dll! ZwWaitForSingleObject + 10 bytes
KERNELBASE.dll! WaitForSingleObjectEx + 156 bytes
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
fs2_open_3_8_1_soundSets_x64_SSE2-FASTDBG.exe! <no symbol>
kernel32.dll! BaseThreadInitThunk + 13 bytes
ntdll.dll! RtlUserThreadStart + 33 bytes
Title: Re: Sound set test builds
Post by: m!m on October 10, 2017, 12:09:23 pm
Good, that's the one I fixed.

EDIT: The builds have finished so you can try the new builds to to check if that fixed the issue.
Title: Re: Sound set test builds
Post by: m!m on October 16, 2017, 11:46:57 am
@Spoon: Did the newest build fix the Assertion/sound issue?
Title: Re: Sound set test builds
Post by: Spoon on October 16, 2017, 03:07:07 pm
@Spoon: Did the newest build fix the Assertion/sound issue?
Oh ****, sorry for not reporting back on that! Yes it has been fixed :yes:
As far as I can tell, all of the sound set features seems to work properly now.
Title: Re: Sound set test builds
Post by: m!m on October 16, 2017, 03:09:39 pm
Thank you for testing. If everything works right then I'll start bothering people on Discord until I get a code review :p
Title: Re: Sound set test builds
Post by: m!m on November 04, 2017, 09:07:19 am
The changes have been merged and will appear in the next nightly build (whenever that may be since the nightly script cannot create new posts at the moment).
Title: Re: Sound set test builds
Post by: m!m on November 06, 2017, 07:13:09 am
I added the documentation for this feature to the wiki: http://wiki.hard-light.net/index.php/Sounds.tbl
Title: Re: Sound set test builds
Post by: Bryan See on December 10, 2017, 11:17:49 am
Excuse me, what about music?
Title: Re: Sound set test builds
Post by: m!m on December 10, 2017, 11:18:42 am
This has nothing to do with music.
Title: Re: Sound set test builds
Post by: Bryan See on December 10, 2017, 11:36:32 am
Thanks for that. I'll probably make a request for such elsewhere.
Title: Re: Sound set test builds
Post by: Spoon on March 13, 2018, 01:47:27 pm
I ran into what I think is a bug, kind of an odd case.

When assigning a turret rotation sound in ships.tbl, for example:

Code: [Select]
$Subsystem:                     gunturret-6, 25, 20
$Alt Subsystem Name: Heavy Turret
    $Default PBanks:            ( "VX-181 Heavy Pulse" "Type-3 Beehive round" )
$Turret Base RotationSnd: 321
$Target Priority:        ( "cruisers" "corvettes" "capitals" "super caps" "bombers" "fighters" )
$Flags: ( "check hull" "no subsystem targeting" "target requires fov" "fire on target" "salvo mode" "reset when idle" )
$animation: triggered
$type: initial
+relative_angle: 80, 0, 0 

And the sound its referencing is retail formatted, or uses the +Filename: formating
For example:
Code: [Select]
$Name: 321
+Filename: Turretrotation.ogg
+Preload: no
+Volume: 0.55
+3D Sound:
        +Attenuation start: 450
        +Attenuation end: 1500
+Priority: Medium-High
+Limit: 4

It will play just fine ingame.

However, when using the +Entry: format, the sound won't play.
This for example:
Code: [Select]
$Name: 321
+Entry: Turretrotation.ogg
+Cycle type: sequential
+Preload: no
+Volume: (0.85 0.90)
+3D Sound:
        +Attenuation start: 450
        +Attenuation end: 1500
+Priority: Medium-High
+Limit: 4
+Pitch: (0.95 1.05)
Won't work.
Title: Re: Sound set test builds
Post by: AdmiralRalwood on March 14, 2018, 08:19:00 am
At a glance, it looks like volume/pitch ranges have issues with always returning 0 for min/max value, which could screw up a number of relevant pieces of code.
Title: Re: Sound set test builds
Post by: m!m on March 14, 2018, 09:03:46 am
The turret rotation sound code used the persistent object sound system so my first guess is that sound sets do not work well with that. I'll try to reproduce and fix this when I have some free time.
Title: Re: Sound set test builds
Post by: Spoon on March 29, 2018, 06:53:08 am
Not that this is a high priority issue or anything (I dont mean to come across as nagging), but has anyone looked into this yet?
Title: Re: Sound set test builds
Post by: m!m on March 29, 2018, 06:54:39 am
I built a test setup and I can reproduce the bug but at the moment I have no idea what might be causing this.
Title: Re: Sound set test builds
Post by: m!m on March 29, 2018, 07:27:38 am
I fixed the bug and opened a pull request for it: https://github.com/scp-fs2open/fs2open.github.com/pull/1671
Title: Re: Sound set test builds
Post by: Spoon on March 29, 2018, 01:07:19 pm
"I found the bug, but don't know how to fix it atm"
*30 minutes later*
"Fixed it"
 :lol: :yes: