• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

MSFS XML Local Var Hidden Gauge for Sounds Deployment

Messages
10,058
Country
us-arizona
Hey guys,
Does this code look right? Its not working and thought I would ask for advice.
This is for MSFS, for use in a SoundXML 'custom sound'. I am trying to create two Local Vars that will operate off of a base Local Var. Evidently we cannot attach two WAV files to 'one' Local Var, so we have to create two Local Vars and have a sound attached to each one. (Opening Door sound and Closing Door sound). 2 Doors, 4 sounds. Each 'branched out' Local Var will carry a sound on it.
Here is the first one to get working, Left Door. Do you see a flaw in my 'now forgotten' XML coding? This code will be in the Model Interior XML file.

<Component ID="LHC_DOORS_SOUNDS_LH"> <UseTemplate Name="ASOBO_GT_Update"> <FREQUENCY>30</FREQUENCY> <UPDATE_CODE> (DOOR_LH,Bool) 1 &gt; if{ (L:DOOR_LH_KEY,Bool) 0 == if{ 1 (&gt;L:DOOR_LH_KEY,Bool) 1 (&gt;L:DOOR_LH_SOUND,Bool) } } els{ 0 } (DOOR_LH,PERCENT) 5 &lt; if{ (L:DOOR_LH_KEY,Bool) 1 == (L:DOOR_LH_SOUND_OPEN,Bool) 1 == if{ 0 (&gt;L:DOOR_LH_SOUND_OPEN,Bool) 1 (&gt;L:DOOR_LH_SOUND_CLOSED,Bool) } } els{ 0 } (DOOR_LH,Bool) 0 == if{ (L:DOOR_LH_KEY,Bool) 1 == (L:DOOR_LH_SOUND_CLOSED,Bool) 1 == if{ 0 (&gt;L:DOOR_LH_KEY,Bool) 0 (&gt;L:DOOR_LH_SOUND_CLOSED,Bool) } } els{ 0 } </UPDATE_CODE> </UseTemplate> </Component>
 
Messages
242
Country
unitedkingdom
not exactly sure what you're doing but 5 quick points:

L: vars don't have units

XML "if" has zero or non-zero as a condition, so a statement "(L:mybool, bool) 1 == if{ ..." looks a bit error-prone compared to simply "(L:mybool) if{"

Testing a 'bool' for greater than 1 also seems error-prone.

Use the Behaviours SDK window to watch your L vars

I trigger sounds based on a L: var CHANGING, so the sound is triggered with a clear/consistent statement like "(L:ZZ_SOUND_DOOR_LEFT) ! (&gt;L:ZZ_SOUND_DOOR_LEFT)". I can post the sound config line that plays sound based on var change if you want that.
 
Messages
10,058
Country
us-arizona
I trigger sounds based on a L: var CHANGING, so the sound is triggered with a clear/consistent statement like "(L:ZZ_SOUND_DOOR_LEFT) ! (&gt;L:ZZ_SOUND_DOOR_LEFT)". I can post the sound config line that plays sound based on var change if you want that.
Hello B21,
I would be very grateful. I have been at it for 6 days now trying to get a dual door-opening and door-closing sound to function. I have been away from writing XML for 2 years, sadly have lost touch with it.
One of my tries at this LVar system this morning;

<Component ID="LHC_DOORS_SOUNDS_LH"> <UseTemplate Name="ASOBO_GT_Update"> <FREQUENCY>30</FREQUENCY> <UPDATE_CODE> (L:DOOR_LH,Bool) 1 &gt; if{ (L:DOOR_LH_OPEN_LVAR) ! if{ 1 (&gt;L:DOOR_LH_OPEN_LVAR) } } (L:DOOR_LH,Bool) 0 &lt; if{ (L:DOOR_LH_CLOSE_LVAR) ! if{ 1 (&gt;L:DOOR_LH_CLOSE_LVAR) } } </UPDATE_CODE> </UseTemplate> </Component>

A bit more simpler. But, didnt work. I know that it doesnt shut off the LVars (reset) but was just trying to get it to move, to do something, to fire off a sound.

<Sound WwiseData="false" WwiseEvent="custom_sound_07" FileName="door_opening_lh" ViewPoint="Inside" NodeName="Door_Inner_LH"
LocalVar="DOOR_LH_OPEN_LVAR" Continuous="false" BreakOnStop="true"/>
<Sound WwiseData="false" WwiseEvent="custom_sound_08" FileName="door_closing_lh" ViewPoint="Inside" NodeName="Door_Inner_LH"
LocalVar="DOOR_LH_CLOSE_LVAR" Continuous="false" BreakOnStop="true"/>


^^ The Sound XML section.
 
Messages
982
Country
australia
Code:
                    (L:DOOR_LH,Bool) 1 &gt;
                        if{ (L:DOOR_LH_OPEN_LVAR) !
                            if{ 1 (&gt;L:DOOR_LH_OPEN_LVAR) }
                          }
                    (L:DOOR_LH,Bool) 0 &lt;
What values are you expecting with DOOR_LH ? From this code it seems you expect DOOR_LH to be above 1 or below 0 (ie negative). Its difficult to debug code without knowing what values you are using.

I use this (it's for wwise events but I fiigure it should work for normal wav files too).

Code:
    <Sound WwiseData="true" WwiseEvent="dooropen" Continuous="false" NodeName="door_left_front_y" LocalVar="tm_Door_front_left">
      <Range LowerBound="50" />
    </Sound>
    <Sound WwiseData="true" WwiseEvent="doorclose" Continuous="false" NodeName="door_left_front_y" LocalVar="tm_Door_front_left">
      <Range UpperBound="50" />
    </Sound>

It uses one localvar, tm_Door_front_left which has a value of either 0 (closed door) or 100 (opened door) and is the same variable I use for the door animation. Using the Range commands means that when the localvar changes it's value the sound code will evaluate if it fits within the bounds.

For example, in the first line the dooropen WwiseEvent monitors the localvar tm_Door_front_left. When tm_Door_front_left is set to 100 by my modelbehavior code to open the door the value is compared against the Range LowerBound = "50" (a value I used simply because it was halfway between 0 and 100) and as it is above the LowerBound it triggers the dooropen WwiseEvent.

The second line does the opposite, when tm_Door_front_left is set to 0 this is below the Range UpperBound = "50" so it triggers the doorclose sound.

As you can see the sound.xml code uses one single localvar to trigger two different sounds based upon the value of the localvar. The sound.xml code is triggered whenever the localvar changes it's value and the Range commands determine which WwiseEvent to play. It's simple, uses the same variable as I use for the door animation and does not require any additional logic. You just need to wrap your head around what the LowerBound and UpperBound mean. In this case LowerBound means is tm_Door_front_left greater than 50 and UpperBound means is tm_Door_front_left less than 50.
 
Messages
10,058
Country
us-arizona
Code:
                    (L:DOOR_LH,Bool) 1 &gt;
                        if{ (L:DOOR_LH_OPEN_LVAR) !
                            if{ 1 (&gt;L:DOOR_LH_OPEN_LVAR) }
                          }
                    (L:DOOR_LH,Bool) 0 &lt;
What values are you expecting with DOOR_LH ? From this code it seems you expect DOOR_LH to be above 1 or below 0 (ie negative). Its difficult to debug code without knowing what values you are using.

I use this (it's for wwise events but I fiigure it should work for normal wav files too).

Code:
    <Sound WwiseData="true" WwiseEvent="dooropen" Continuous="false" NodeName="door_left_front_y" LocalVar="tm_Door_front_left">
      <Range LowerBound="50" />
    </Sound>
    <Sound WwiseData="true" WwiseEvent="doorclose" Continuous="false" NodeName="door_left_front_y" LocalVar="tm_Door_front_left">
      <Range UpperBound="50" />
    </Sound>

It uses one localvar, tm_Door_front_left which has a value of either 0 (closed door) or 100 (opened door) and is the same variable I use for the door animation. Using the Range commands means that when the localvar changes it's value the sound code will evaluate if it fits within the bounds.

For example, in the first line the dooropen WwiseEvent monitors the localvar tm_Door_front_left. When tm_Door_front_left is set to 100 by my modelbehavior code to open the door the value is compared against the Range LowerBound = "50" (a value I used simply because it was halfway between 0 and 100) and as it is above the LowerBound it triggers the dooropen WwiseEvent.

The second line does the opposite, when tm_Door_front_left is set to 0 this is below the Range UpperBound = "50" so it triggers the doorclose sound.

As you can see the sound.xml code uses one single localvar to trigger two different sounds based upon the value of the localvar. The sound.xml code is triggered whenever the localvar changes it's value and the Range commands determine which WwiseEvent to play. It's simple, uses the same variable as I use for the door animation and does not require any additional logic. You just need to wrap your head around what the LowerBound and UpperBound mean. In this case LowerBound means is tm_Door_front_left greater than 50 and UpperBound means is tm_Door_front_left less than 50.
Hey Anthony,
How does your code tell the WAV file the name to fire? I thought that the WwiseEvent="" is your event name, not the WAV file name. Is this what I have been missing? I have been including the 'File="" for telling the Wwise system to fire that particular file (WAV) to run.

<Sound WwiseData="false" WwiseEvent="custom_sound_07" [COLOR=rgb(44, 130, 201)][B]FileName="door_opening_lh"[/B][/COLOR] ViewPoint="Inside" NodeName="Door_Inner_LH" LocalVar="DOOR_LH_OPEN_LVAR" Continuous="false" BreakOnStop="true"/>
 
Last edited:
Messages
982
Country
australia
Hey Anthony,
How does your code tell the WAV file the name to fire? I thought that the WwiseEvent="" is your event name, not the WAV file name. Is this what I have been missing? I have been including the 'File="" for telling the Wwise system to fire that particular file (WAV) to run.

<Sound WwiseData="false" WwiseEvent="custom_sound_07" [COLOR=rgb(44, 130, 201)][B]FileName="door_opening_lh"[/B][/COLOR] ViewPoint="Inside" NodeName="Door_Inner_LH" LocalVar="DOOR_LH_OPEN_LVAR" Continuous="false" BreakOnStop="true"/>
I'm using a Wwise sound pack I created so the WwiseEvent is the name I used within the sound pack, the wav file is embedded as part of the sound pack. You need to build the sound pack with Wwise to do it the way I have. I've never actually used the filename method but I think the principle of using the Range parameter should work the same.
 
Messages
10,058
Country
us-arizona
Ok. That explains it. I am working outside of doing a pack presently, still in Kindergarten with Wwise. (Very impressed so far). With WwiseData="false" Events, there seems to be no way to do 2 sounds on a single LocalVar. So we are having to make LocalVars that fire off (cause to play) the WAV's we are adding. For those, you would add the file name.
You might check it out, Anthony in case you run into things you might need to use this with.

Just curious. Are you on your first Wwise Pack, or have you created a few so far?
 
Messages
982
Country
australia
Just curious. Are you on your first Wwise Pack, or have you created a few so far?
I have created two Wwise Packs, one for the Drifter and one for the Tiger Moth.

Interesting that you can't create two sounds events using the same LocalVar. It works with WwiseEvents. Can you get the the door open sound to play correctly using the Range bounds commands? If that works then I'd just write the localvar door value to two variables at the same time and use the second variable to trigger the close door sound.
 
Messages
10,058
Country
us-arizona
Right now, I have both door sounds running on top of each other. They only play on Forward. I have the secondary set as Backward and also added 'Index="1" to it and experimented with Lower and UpperBound settings till I went cross-eyed. Nothing seemed to work. Usually the secondary just stops working. This is what I have right now.
<Sound Wwisedata="false" WwiseEvent="custom_sound_03" FileName="door_opening_lh" LocalVar="DOOR_LH" Continuous="false" Direction="Forward" Units="PERCENT" ViewPoint="Inside" Index="0"> <Range LowerBound="1.0"/> </Sound> <Sound Wwisedata="false" WwiseEvent="custom_sound_04" FileName="door_closing_lh" LocalVar="DOOR_LH" Continuous="false" Direction="Backward" Units="PERCENT" ViewPoint="Inside" Index="1"> <Range LowerBound="1.0" UpperBound="100.0"/> </Sound>
I have created two Wwise Packs, one for the Drifter and one for the Tiger Moth.
Nice..! I havent seen the Drifter, but heard good things about the Tiger Moth. I hope they are doing well. I got a chance to pick up the Discus glider and am really impressed.
I found I can run a FSX Legacy soundpack 'with' a Sound.XML, editing out the engine sounds so I am using stock Asobo sound events/effects and my own engine sounds. Doing this presently on the Bucker Bu-131.

I just learned this afternoon, you can only have 12 'custom sounds' on a Sound.XML.
 
Messages
982
Country
australia
This code in the sound.xml works for me.

Code:
    <Sound WwiseData="false" WwiseEvent="custom_sound_01" FileName="door_open" Continuous="false" ViewPoint="Inside" NodeName="door_left_rear_y" LocalVar="tm_Door_rear_left">
      <Range LowerBound="50" />
    </Sound>
    <Sound WwiseData="false" WwiseEvent="custom_sound_02" FileName="door_close" Continuous="false" ViewPoint="Inside" NodeName="door_left_rear_y" LocalVar="tm_Door_rear_left">
      <Range UpperBound="50" />
    </Sound>

tm_Door_rear_left is either 0 for closed or 100 for open.
 
Messages
10,058
Country
us-arizona
Didnt work. No sounds. I replaced my own entries, made them numbers 5,6. I wonder what is blocking it...
 
Messages
982
Country
australia
Are you certain that the sound files are included in the json? If they aren't part of the file list then they won't be loaded. That's all I can think of.
 
Messages
10,058
Country
us-arizona
I build them in the Developer Builder in Inspector, complete aircraft build. Sound files, configs, XML's all get updated.
 
Messages
242
Country
unitedkingdom
apologies very slow to catch up with this thread. My sound.xml stanza to play a WAV file (cable_on.wav) once each time a simvar changes, the NodeName (gauge_radio) is the Blender object I attach the sound to:

Code:
<SimVarSounds>
... other entries

    <Sound WwiseData="false" WwiseEvent="STALL_WARNING" FileName="cable_on" ViewPoint="Inside" NodeName="gauge_radio"
        LocalVar="SOUND_CABLE_ON" Continuous="false" BreakOnStop="true"/>
</SimVarSounds>

In my html/js or XML code I can play this sound at any time with: (L:SOUND_CABLE_ON) ! (L:SOUND_CABLE_ON) (or the equivalent JS)
 
Top