• 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.

FSXA PLaying Sounds in series

Messages
278
Country
ca-britishcolumbia
Hi
I was wondering if using Doug Dawsons sound gauge if you can have sounds play in series. I am currently working to add sounds to an GPU/APU gauge and when I start the apu i get the starter sound with the running sound. What I would like is to have the starter play then immediatly after the running sound plays.

Thanks Greg

Blue is the running sound and red is the starter sound

Code:
Area Left="127" Top="24" Width="18" Height="28">
<Cursor Type="Hand"/>
<Tooltip>Start APU</Tooltip>
<Click>1 (>L:dsd_fsx_sound_id_32,number) 1 (>L:APU Run,bool) 
1 (>K:APU_STARTER) [COLOR="red"]1 (>L:dsd_fsx_sound_id_29,number)[/COLOR] 
1 (>K:APU_GENERATOR_SWITCH_SET) 
[COLOR="blue"]2 (>L:dsd_fsx_sound_id_20,number)</[/COLOR]Click>
</Area>
 
Last edited:

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
You will need to script a timer that will play the starter for xx seconds (you will need to check the .wav file to find out how long it is), then start the "running" sound at the end of that number of seconds.

Shutdown is easier since all you need to do is stop the "running" loop, then fire off the shutdown .wav file.
 
Messages
278
Country
ca-britishcolumbia
Once again, Thanks for the direction Bill

Ok attempted to create a timer after searching through the forums came up with below. Unfortuantly it doesn't work and I'm at a loss why.

When the start button is activated it plays the "START" sound then loops it. No "RUN" sound is ever played and when shut down you get the "STOP" sound followed by one more start up sound. I'm assuming the last is played becuase it had already started to loop again. So is this close or am I completly out in left field here and need to re-think the approach?

Thanks Greg

The element the I assume is giving it the timer.
Code:
<Element>
<Select>
<Value>(L:APU Run,bool) (L:APUSTART,bool) ! and 
if{ 1 (>L:dsd_fsx_sound_id_29,number) (E:LOCAL TIME, seconds) 25 + (>L:STARTTIMER,enum) }</Value>
</Select>
</Element>

The mouse click.
Code:
<Area Left="127" Top="24" Width="18" Height="28">
<Cursor Type="Hand"/>
<Tooltip>Start APU</Tooltip>
<Click>1 (>L:dsd_fsx_sound_id_32,number) 1 (>L:APU Run,bool) 1 (>K:APU_STARTER) 
1 (>K:APU_GENERATOR_SWITCH_SET)  
[COLOR="Blue"](L:STARTTIMER,enum) (E:LOCAL TIME, seconds) &lt; 
(L:APUSTART,bool) and if{ 2 (>L:dsd_fsx_sound_id_20,number) }</Click>
</Area>[/COLOR]
 
Last edited:

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Since I'm not familiar with Doug's sound module, I can't offer much help with that...

...but, is there a "single-shot" function? IOW, play once only then stop? If so, that's what you need to use for the starter sound file. Only the "running" sound should be looped playback.

However, in general here's how to implement a timer delay function. While waiting for the timer to expire, you do nothing at all if{ }:

In the mouse section, when clicked you initialize the timer's length like this:

(E:LOCAL TIME,seconds) desired_time_delay + (>L:MyTimeDelay,enum)

In your <Element> or <Update> section, you check the timer like this:

(L:MyTimeDelay,enum) (E:local time, seconds) &gt;
if{ }
els{ do whatever you want done here }

As a practical example, I have quite a few three position, center OFF toggle switches that're spring loaded. IOW, click up or down, switch returns to center off automatically...

In my <Update> section, I have the "reset script" like this:

Code:
          <!-- RESET GRND PWR SWITCH -->
          (L:B737_GRND_Pwr, enum) 0 !=
          if{
          (L:Reset,enum) (E:local time, seconds) &gt;
          if{ }
          els{ 0 (>L:B737_GRND_Pwr, enum) }
          }

In the mouse click section, I have this:
Code:
        (L:B737_GRND_Pwr, enum) -1 == if{ 0 (>L:B737_GRND_Pwr_ON,enum) (E:LOCAL TIME,seconds) 0.5 + (>L:Reset,enum) 1 (>L:XMLSND5,bool) }
        (L:B737_GRND_Pwr, enum) -1 == (L:B737_APU_PwrSwitch, enum) 0 == and if{ 0 (>K:APU_GENERATOR_SWITCH_SET) (>K:APU_OFF_SWITCH) 0 (>L:B737_APU_Bus1_Tied,enum) 0 (>L:B737_APU_Bus2_Tied,enum) }
        (L:B737_GRND_Pwr, enum) 1 == if{ (>K:APU_STARTER) 1 (>K:APU_GENERATOR_SWITCH_SET) 1 (>L:B737_APU_Bus1_Tied,enum) 1 (>L:B737_APU_Bus2_Tied,enum) 1 (>L:B737_GRND_Pwr_ON,enum) (E:LOCAL TIME,seconds) 0.5 + (>L:Reset,enum) 1 (>L:XMLSND5,bool) }
 
Last edited:

ddawson

Resource contributor
Messages
862
Country
canada
In the code you've posted, I don't see where you set (L:APUSTART,bool) to a non-zero value.
When the start sound finishes, the gauge sets the control variable back to zero. The 'if' statement in your Select tag then succeeds again and restarts the sound, hence the "looping" you hear.
You have put the code to start the "run" portion of your sound in the mouse click. It needs to be in the Select section, as it needs to continually test for when to start the "run" sound.

Doug
 
Messages
278
Country
ca-britishcolumbia
I'm at a complete loss

Thanks to you both for your support and guidance, But for the life of me can't wrap my head around this. I have the "Run" sound that instantly plays with the start up in the background. It is apparent my timer does not work and curious what am I doing wrong. Any suggestions greatly appreaciated.

Thanks again Greg

The Elements:
Code:
<Element>
<Select>
<Value> (L:APU Run,bool) and if{ 1 (>L:APUSTART,enum) } 
els{ 0 (>L:APUSTART,enum) }</Value>
</Select>
</Element>
   
<Element>
<Select>
<Value>(L:APU Run,bool) 0 != if{ (>L:APUSTART,enum) 
(E:LOCAL TIME,seconds) &gt; if{ } 
els{ 2 (>L:dsd_fsx_sound_id_20,number) }}</Value>
</Select>
</Element>

The Mouse Click:
Code:
<Area Left="127" Top="24" Width="18" Height="28">
<Cursor Type="Hand"/>
<Tooltip>Start APU</Tooltip>
<Click>1 (>L:dsd_fsx_sound_id_32,number) 1 (>L:APU Run,bool) 
1 (>K:APU_STARTER) 1 (>K:APU_GENERATOR_SWITCH_SET) 1 (>L:dsd_fsx_sound_id_29,number) 
(E:LOCAL TIME, seconds) 25 + (>L:APUSTART,enum)</Click>
</Area>
 

ddawson

Resource contributor
Messages
862
Country
canada
You've got a couple of syntax errors going on there...
In your first select tag,
(L:APU Run,bool) and <!-- And what... -->
I'm guessing the interpreter is assuming a 0 and therefore failing the 'if' statement on each update.

In your second select tag,
if{
(>L:APUSTART,enum)

You're using the assignment operator, but I think you just want the existing L:Var value. You probably want to lose the > character.

You can really make your own life a lot easier if you build yourself a plain text gauge that will display the values of the L:Vars you are working with ( A: and G: as well, for that matter.) You probably know what values you expect to see in each of these variables. If you can see which ones aren't getting there, you will have a much better idea of what is going wrong with your code. The attached gauge will display all the currently active L:Vars, in pages of 20; click on the face of the gauge to scroll through the pages.

Also, XML is hard enough to read as it is. Please keep it to one statement/command/assignment per line. Use the Enter key:
Code:
<Element>
<Select>
<Value>
(L:APU Run,bool) and 
if{
1 (>L:APUSTART,enum) 
} 
els{ 
0 (>L:APUSTART,enum) 
}
</Value>
</Select>
</Element>


<Element>
<Select>
<Value>
(L:APU Run,bool) 0 != 
if{ 
(>L:APUSTART,enum) 
(E:LOCAL TIME,seconds) &gt; if{ } 
els{ 
2 (>L:dsd_fsx_sound_id_20,number) 
}
}
</Value>
</Select>
</Element>


<Area Left="127" Top="24" Width="18" Height="28">
<Cursor Type="Hand"/>
<Tooltip>Start APU</Tooltip>
<Click>
1 (>L:dsd_fsx_sound_id_32,number) 
1 (>L:APU Run,bool) 
1 (>K:APU_STARTER) 
1 (>K:APU_GENERATOR_SWITCH_SET) 
1 (>L:dsd_fsx_sound_id_29,number) 
(E:LOCAL TIME, seconds) 25 + (>L:APUSTART,enum)
</Click>
</Area>

Doug
 
Last edited:

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
The first <Element> won't work because you've included a conjunction operator (and) but no comparison operator (&gt; &lt; == !=)...

Which is really irrelevant because even if it did "work" it would kill your intended result, as it would instantly wipe out the timer variable you just set in the mouse click routine! :eek:

XML scripted "code" executes from top to bottom 18 times/second. When you click in the mouse area you set the timer variable to 25. When the script loops back to the top and begins the next "pass through" it then hits your first <Element> where you've (re)set your timer variable to 1... :whiteflag

Here is what you need:

Code:
<Element>
  <Select>
    <Value>
      (L:APU Run,bool) 0 != 
      if{ 
        (L:APUSTART,enum)
        (E:LOCAL TIME,seconds) &gt;
        if{ }
        els{
            2 (>L:dsd_fsx_sound_id_20,number)
            0 (>L:APUSTART,enum)
          }
        }
    </Value>
  </Select>
</Element>

However, I strongly suggest that you should NOT use <Element> entries for "pure logic" because then your "logic" is scattered all over the place...

...It's much easier to both write and keep track of when the "logic" is in one neat section, all by itself.


Code:
<Update Hidden="Yes">

 <!-- LOOP "RUN" SOUND AFTER 25 SECOND DELAY -->
 (L:APU Run,bool) 0 !=
 if{
   (L:APUSTART,enum)
   (E:LOCAL TIME,seconds) &gt;
   if{ }
   els{
       2 (>L:dsd_fsx_sound_id_20,number)
       0 (>L:APUSTART,enum)
      }
   }

</Update>
 
Messages
278
Country
ca-britishcolumbia
Once again thank you to you both

Thank you for your time and effort on this. I don't understand why i struggle with taking common sense and converting it to code. It works now as i wanted. I'm thinking I'm going to sit back and enjoy the holidays and try to avoid banging my head against the wall, yes I have a stucco repair now, and enjoy the flying FSX offers. Thanks again and Happy Holidays to you both.

Greg

P.S. that gauge your posted Doug is awesome, I like the the fact you can see whats triggering when and where. Helps a lot.

The Final Result:

Update Section:
Code:
<Update Hidden="Yes">
(L:APU Run,bool) 0 != 
if{ (L:APUSTART,enum) 
(E:LOCAL TIME,seconds) &gt; 
if{ } 
els{ 2 (>L:dsd_fsx_sound_id_20,number) 
0 (>L:APUSTART,enum) } 
}
</Update>

Mouse Click:
Code:
<Area Left="127" Top="24" Width="18" Height="28">
<Cursor Type="Hand"/>
<Tooltip>Start APU</Tooltip>
<Click>1 (>L:dsd_fsx_sound_id_32,number) 
1 (>L:APU Run,bool) 
1 (>K:APU_STARTER) 
1 (>K:APU_GENERATOR_SWITCH_SET) 
1 (>L:dsd_fsx_sound_id_29,number) 
(E:LOCAL TIME, seconds) 26 + 
(>L:APUSTART,enum)</Click>
</Area>
 
Top