FSX Sounds effects: playing on demand (good) and stopping on demand (not so good)

#1
Is there any way to stop the sound from playing using the visibility tag, just as the visibility tag can be used to show and hide visual effect?

I have a model (a rocket) to which I attached a sound effect controller which in turn plays a looping rocket rumble sound. I have also tagged this effect with a visibility tag:
Code:
SXML = <?xml version="1.0" encoding="ISO-8859-1" ?> <FSMakeMdlData version="9.0"> <Attachpoint name="attachpt_rocketRumbleSnd_01"> <AttachedObject> <Effect effectName="Cntrl_rocket5" effectParams=""/> </AttachedObject> </Attachpoint> <Visibility name="rocket_engine_0"> </Visibility> </FSMakeMdlData>
Just for verification, I have placed a VISUAL fx using the same visibility tag.

Now, through some SimConnect magic , I can control the visibility of this effect - I can turn it on and off within my DLL app. By default, visibility switch is off and both visual fx and sound fx are invisible and inaudible. When I flip it on, the visible fx turns on AND sound fx starts playing. When I flip the visibility switch off, visual fx is gone, but the sound fx continues playing, without any possibility of stopping.

From the visible fx's proper behaviour I can see that my logic is sound... so, is there any way to stop the sound from playing using the visibility tag, just as it can be used to show and hide visual effect?
 
#2
Hi Misho:

That is an intriguing scenario.

I am not sure if playing of a looped sound file independent of *.Fx distance-based parameter values can work with visibility attributes other than as a 'pixel-size-on-screen' LOD-related value for a non-textured 3D model AttachPoint Controller *.Fx file (which, IIUC, also makes triggering an Effect 'distance-based'.)

Have you tried testing the Controller and Main *.Fx files on-ground as BGLComp-placed Effects first to see if they can be controlled and played in complete compliance with your desired criteria, via 'normal' methods without the "Visbility" SimConnect linkages to those Effects via AttachPoints on a 3D model ? :scratchch

[EDITED]

AFAIK, Effect sounds are played via the Windows DirectX DirectSound sub-system; IIUC, once the 'hand-off' to DirectX has been made by the FS rendering engine for playing of a *.WAV file, it is out of reach of SimConnect and the FS rendering engine.

SysInternals' ProcMon will show that the *.WAV files are repeatedly loaded and un-loaded during looped playing of those files via Effects.


If SimConnect can instantly stop the rendering of a SimObject via the "Visibility" mechanism cited above, possibly a custom XML Gauge or DLL Module would allow the complete control you may require, perhaps also via use of a different *.WAV player utility ? ;)


You may wish to look at Doug Dawson's sound modules for some ideas on alternate methods to play sounds linked with SimObjects: :idea:

https://www.douglassdawson.ca/


[END_EDIT]

GaryGB
 
Last edited:
#3
Hi Gary! Thanks for your insight! I haven't tried attaching sound effects to BGL files yet... I am not sure how that would help me. Yes, they do have conditional flags and they probably work (otherwise I'd hear about it in the forums:D ) but they really don't help me (I can't turn off sound by changing the season or time of day ;) )

I HAVE been successful in attaching sounds to "simple" objects, and then loading and unloading them in SimConnect as I need. That does work, the sounds stops (rather abruptly, it doesn't play to the end) when I remove the object with attached sfx. Also, after a few sounds played, I start getting annoying crackling, as if the resources are being exhausted, and this is a no-go. So, while this is working, I'm seeing that I do need a system with far more control and flexibility, and better resource management.

As far as DirectX, I've actually been more and more inclined to "roll my own" and write a DSound sub-module, something like Doug did. Actually, I've been in contact with him and he offered me his library, but unfortunately it has been compiled with a different set of sub-modules which are incompatible with mine. I've looked at the online DSound public domain examples (there are plenty) and there are a few that I can modify nicely for my purpose.

I think the FSX sfx engine, while seemingly sophisticated on paper, is rather limited to what it can do, so, I'll stop investing time in trying to have it submit to my needs, and go the "right" route. :cool:
 
#4
https://www.fsdeveloper.com/forum/t...ping-on-demand-not-so-good.443045/post-801581

Hi Gary! Thanks for your insight!

I haven't tried attaching sound effects to BGL files yet... I am not sure how that would help me. Yes, they do have conditional flags and they probably work (otherwise I'd hear about it in the forums:D ) but they really don't help me (I can't turn off sound by changing the season or time of day ;) )
Hi Misho:

What I was alluding to was that one may be able to initially fine-tune playing of a Effect sound by first placing the 'Controller' *.Fx file via BGLComp-XML ex: on-ground at a specified location stored in a saved *.FLT file.

One can then test various Effect *.Fx file parameter values and EffectParam conditional display / play values in the *.Fx placement BGLComp XML source file, while also testing various Effect 'Controller' and 'Main' *.FX file parameter values ...before linking the Controller to a 3D MDL AttachPoint and testing the SimConnect "Visibility" display control as an additional variable in the test scenario.


I understand, though, that you might have other project requirements that may compel a custom-coded solution.


But in this context, for the potential benefit of other readers of this thread who may be less likely to undertake the more advanced course of action you are likely to take, I shall still offer the following perspective with regard to further exploring use of existing and available FS Special Effects SDK methods. ;)

Although I have not yet had time to further fine-tune my proof-of-concept prototype code in a recent sub-topic recently discussed in this sub-forum with Christian Bahr (within a pre-existing thread with George Davison on Effect sounds) ...here:

https://www.fsdeveloper.com/forum/threads/sound-effects.424400/post-799825


...I believe that it is possible to ultimately achieve a fully synchronized and repeated playing of an Effect sound without a "Looping=TRUE" parameter value being used in the *.Fx coding, while also minimizing crackling or other audio anomalies which may result from dis-synchrony (and/or resource depletion) in loading / unloading of *.WAV files via Effects and the subsequent hand-off to the Windows DirectX DirectSound sub-system. :coffee:


https://www.fsdeveloper.com/forum/t...ping-on-demand-not-so-good.443045/post-801581

I HAVE been successful in attaching sounds to "simple" objects, and then loading and unloading them in SimConnect as I need. That does work, the sounds stops (rather abruptly, it doesn't play to the end) when I remove the object with attached sfx.

Also, after a few sounds played, I start getting annoying crackling, as if the resources are being exhausted, and this is a no-go. So, while this is working, I'm seeing that I do need a system with far more control and flexibility, and better resource management.

As far as DirectX, I've actually been more and more inclined to "roll my own" and write a DSound sub-module, something like Doug did. Actually, I've been in contact with him and he offered me his library, but unfortunately it has been compiled with a different set of sub-modules which are incompatible with mine. I've looked at the online DSound public domain examples (there are plenty) and there are a few that I can modify nicely for my purpose.

I think the FSX sfx engine, while seemingly sophisticated on paper, is rather limited to what it can do, so, I'll stop investing time in trying to have it submit to my needs, and go the "right" route. :cool:
With your considerable advanced knowledge of the FS rendering engine and innovation as a programmer, I am confident that you may be able to implement a potentially 'better' method for playing sounds that meets your particular project needs, while also featuring all the positional and conditional sound attributes ...as would otherwise be achievable via the FS Special Effects SDK. :wizard:

I look forward to reading in future postings, how this aspect of your project has successfully innovated a new method of enhancing and extending FS. :)

GaryGB
 
Last edited:
#5
Hi Misho:

What I was alluding to was that one may be able to initially fine-tune playing of a Effect sound by first placing the 'Controller' *.Fx file via BGLComp-XML ex: on-ground at a specified location stored in a saved *.FLT file.

One can then test various Effect *.Fx file parameter values and EffectParam conditional display / play values in the *.Fx placement BGLComp XML source file, while also testing various Effect 'Controller' and 'Main' *.FX file parameter values ...before linking the Controller to a 3D MDL AttachPoint and testing the SimConnect "Visibility" display control as an additional variable in the test scenario.
Yeah, I understand what you meant, but the effectParams section has absolutely no variables that would help me. They all relate to simulation's temporal triggers. With those, all I can say is "Please, FSX, turn off my sound at dusk" ;) ... which is of absolutely no use to me. And even if they did, they are specific to XML that produces static scenery, therefore not applicable to MDL-attached effects.

With regards to the fully synchronized and repeated playing of the sound, that's all fine, but as I specified, I need to control them stopped!

One avenue I haven't explored is, I could "hijack" events that have sounds defined in sound.cfg, and which I am not using (flaps, canopy open, gears extending, etc) and trigger those events on demand, and sounds alongside. But again, tinkering with the hacked solution vs. investing time into a full, controllable sound layer - what are the benefits vs. time invested? I'm leaning towards a proper, capable 3D sound layer.
 
#6
For what it's worth - I found out that stopping looping sfx sounds is possible through SimConnect. The trick is to momentarily transmit SOUND_OFF
event, tell server to notify when received, and when notification issued and caught, transmit SOUND_ON event to turn the sound back on. It works!

I can post code if there is any interest! ;)
 
Top