Using the Update component in a non-aircraft simobject - Trigger sound using Lvar

Hello to all! First time posting here.

I am trying to accomplish what seems like a simple task but failing so far.

I have a static simobject (Landmark) to which I would like to assign sounds to be played at specific time of day. Local Time is an E: (Environment variable) and so far I’ve managed to use it to trigger animations or effects. Sound however needs SimVars, or alternatively Lvars.

So I thought, why not define an Lvar and use it to grab the value of E: LOCAL TIME in it and use it as the simulation variable to trigger the sound in the sound.xml.

Searching the known sites I found a suggestion to use the update component in the Behaviors. So my code looks like this:

<Behaviors>
<Include ModelBehaviorFile="Asobo\\Generic\\FX.xml"/>
<Include Path="Asobo\\Generic.xml"/>
<!--Setting sound Lvar-->
<Component ID="GRAB_LOCAL_TIME">
<UseTemplate Name="ASOBO_GT_Update">
<FREQUENCY>18</FREQUENCY>
<UPDATE_CODE>
(E:LOCAL TIME, Seconds) (&gt;L:Sound1)
</UPDATE_CODE>
</UseTemplate>
</Component>

and the sound.xml entry like this:

<SimVarSounds>
<Sound WwiseData="true" WwiseEvent="eng_intake_whistle" Continuous="true" LocalVar="Sound1">
<Range LowerBound="84600" UpperBound="84840"/>
</Sound>
</SimVarSounds>

Normally this would trigger the sound every day at 23:30 and play it for 4 minutes. This never happens. Using the “Behavior” tool in the sim dev mode I check the value of the Lvar and it is always 0. If I manually set it to 84600 in the tool the sound does trigger.

The model is for 2024 and I understand that the above shows 2020 templates but they should normally work. I have tried also with the 2024 update template “Asobo_Update_Template” instead of “ASOBO_GT_Update” and it did not make a difference. I need to stick to 2020 templates as I am using some 2020 effects templates too.

I have seen the “ASOBO_GT_Update” used in modelbehavior files of aircraft cockpits so I’m starting to think it may not work in a “Landmark” simobject, but that would be strange.

Any help or suggestion would be deeply appreciated.

As I haven’t seen any reply yet, I’m wondering if the method I am trying is correct or if there is another way to make sounds trigger based on local time value.

Hey @Dimus2394,
The only way I have found to do it is to use a Scenarii (World Script) to set your Lvar, then you can call this in your soundai.xml. Last I checked, there was still a bug in 2024 that causes this to not update if in Avatar mode, but it will update as soon as you get back into the aircraft. Just a small limitation that hopefully gets fixed eventually!

Hopefully this points you in the right direction. These are separate examples, but I was just demonstrating the layout. You’ll have to adapt the RPN and Lvars to what you want, but I included an example for how to set up the Lvars in sound as well.

World Script (Place this once in the scenery):

<?xml version="1.0" encoding="utf-8" ?>
<SimBase.Document Type="MissionFile" version="1,0" id="{09613A6F-4539-4996-A1F3-722F9D7D1956}">
	<Title>Dynamic Controller</Title>
	<Filename>ESD_CTRL_Dynamic.xml</Filename>

	<WorldBase.Flight>
		<SimMission.Calculator InstanceId="{5E90243B-456D-4CD0-B490-FD61A7620362}" id="ESD_CTRL">
			<CalculatorActions>

				<!-- Show/Play during Dawn, Day, or Dusk, but not while Raining or Snowing. -->
				<CalculatorAction>
					<CalculatorFormula>
						(E:TIME OF DAY, Enum) 2 &lt;= (A:AMBIENT PRECIP STATE, mask) 2 ==
						and d (L:ESD_DawnDuskNoWX) !=
						if{ (&gt;L:ESD_DawnDuskNoWX) }
					</CalculatorFormula>
				</CalculatorAction>

			</CalculatorActions>
		</SimMission.Calculator>
	</WorldBase.Flight>
</SimBase.Document>

soundai.xml

<?xml version="1.0" encoding="utf-8" ?>

<SoundInfo Version="0.1">

    <WwisePackages>
        <MainPackage Name="ESD_ElectricHum_AI"/>
    </WwisePackages>
	
	<SimVarSounds>
		<Sound WwiseEvent="ElectricHum" WwiseData="true" NodeName="Light1" LocalVar="ESD_Lights" Units="bool">
			<Range LowerBound="1"/>
		</Sound>
	</SimVarSounds>
    
</SoundInfo>
1 Like

Wow! You are my savior!

That totally worked! I just replaced the code with mine and got it to grab LOCAL TIME to my Lvar. Now I’m able to simply use its value in the soundai.xml to trigger a series of sounds with one second accuracy.

I have not yet investigated worldscripts and this opens a whole new window of opportunities for me. Many thanks again!!!

1 Like

Glad it worked for you! It definitely opens up a lot of possibilities. You can also have multiple of the CalculatorAction blocks in the same document if you wanted to add additional Lvars for other features.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.