FSXA PLaying Sounds in series

#1
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
#2
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.
 
#3
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
#4
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
#5
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
 
#6
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
#7
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
#8
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>
 
#9
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