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

FS2004 Gauges to trigger playing sounds

Messages
1,451
Country
mexico
Uff... I was expecting a problem with the sound file integrity itself. However, try to isolate the problem: make a simple gauge with the 2 way switch where you only trigger the sound using pertinent variables and logic. Test both cases, where you remove TOGGLE and then with it. If the problem persist, I've got no idea what is causing it :confused:
 
Messages
98
Trying to make a simple 2D push & release button with sound. Using the following code:

XML:
    <Element>

    <Position>
      <Select>
         <Value>(L:BUTTON,bool)</Value>
         <Case Value="0">
           <Image Name="Released.bmp">
         </Case>
         <Case Value="1">
            <Image Name="Pushed.bmp">
         </Case>
      </Select>
    </Element> 

  <Mouse>                     
        <Area>   
         <Tooltip>BUTTON</Tooltip>
                <Cursor Type="Hand"/>
      <Click Kind="LeftSingle+LeftRelease+Leave">
                (M:Event) 'LeftSingle' scmp 0 ==
                if{
                    1 (&gt;L:BUTTON,bool)
                    1 (&gt;L:PushedSound,number)
                  }

                (M:Event) 'LeftRelease' scmp 0 ==
                if{
                    0 (&gt;L:BUTTON,bool)
                    1 (&gt;L:ReleasedSound,number)
                  }

                (M:Event) 'Leave' scmp 0 ==
                if{
                    0 (&gt;L:BUTTON,bool)
                    1 (&gt;L:ReleasedSound,number)
                  } 
        </Click>
        </Area>       
</Mouse>

It works but with some glitches. First If I do a quick mouse click on the button the Released.bmp bitmap won't change to Pushed.bmp as it should. However the 2 sounds work almost perfectly. I have to firmly press and hold the left mouse button to see it changing the bitmaps. Did not test it with another mouse so could it be just a mouse problem?

Second when I hold the left mouse button for some time the PushedSound starts playing as a loop. Could it be fixed by adding some code?

Any help would be appreciated!
 
Messages
495
Country
austria
to the first, it's clear. There is a release and leave

for example some excerpt of a gauge

Code:
    <Area Left="0" Top="0" Right="29" Bottom="29">
    <Tooltip ID=""> AP Off </Tooltip>
    <Cursor Type="Hand"/>
     <Click Kind="LeftSingle+RightSingle+Leave" Repeat="Yes">
      (M:Event)
      'LeftSingle' scmp 0 ==
      (L:AP_Disc_BT,number) 0 ==
      &amp;&amp;
      if{
        1 (&gt;L:AP_Disc_BT,number)
        1 (&gt;L:DSD_TECH_Button_SD,number)
        }
      (M:Event)
      'Leave' scmp 0 ==
      if{
        2 (&gt;L:AP_Disc_BT,number)
        }
     </Click>
    </Area>
  </Mouse>

+++give this in an element ++++++++++++++++++++++++++++

<!-- Reset Button sound -->
      (L:AP_Disc_BT,number) 2 ==
      if{
        (L:DSD_TECH_Button_SD,number) 0 ==
        if{
          0 (&gt;L:AP_Disc_BT,number)
          1 (&gt;L:DSD_TECH_Button_SD,number)
          }
        }

adapt the code
You get also two clicks
 
Messages
98
Now doing a 6 position knob switch that should toggle VOR1 / ADF1 and VOR2 / ADF2 ident audio signal - the last 2, VOR and ADF combined in one and swapped by switches 1 and 2, see the image below:
panel.jpg

Default positions are marked by 0. Also the signal is toggled ON/OFF by switch 3. The Knob Switch code works perfectly:
XML:
        <Area>            <Tooltip></Tooltip>                  <Cursor Type="UpArrow"/>                  <Click Kind="LeftSingle" Repeat="No" MouseWheelFlip="No">                       (M:Event) 'LeftSingle' scmp 0 ==                          if{                              (L:KNOB,number) ++ 5 min (&gt;L:TRMODE,number)                              <!-- Knob Switch Sound -->                              1 (&gt;L:KNOBSOUND,number)                             }                      </Click>          </Area>                                              <Area>            <Tooltip></Tooltip>                  <Cursor Type="DownArrow"/>                  <Click Kind="LeftSingle" Repeat="No" MouseWheelFlip="No">                       (M:Event) 'LeftSingle' scmp 0 ==                          if{                              (L:KNOB,number) -- 0 max (&gt;L:TRMODE,number)                              <!-- Knob Switch Sound -->                              1 (&gt;L:KNOBSOUND,number)                             }                                         </Click>          </Area>
I added the following code:
XML:
    <Element>       <Select>        <Value>                          (L:KNOB,number) 4 == (L:SWITCH3,bool) ! &amp;&amp;                          (A:CIRCUIT AVIONICS ON,bool) &amp;&amp; (L:SWITCH1,bool) &amp;&amp;                          if{ (&gt;K:RADIO_VOR1_IDENT_ENABLE)                              }                           els{                          (&gt;K:RADIO_VOR1_IDENT_DISABLE) }                           (L:KNOB,number) 4 == (L:SWITCH3,bool) ! &amp;&amp;                          (A:CIRCUIT AVIONICS ON,bool) &amp;&amp; (L:SWITCH1,bool) ! &amp;&amp;                          if{ (&gt;K:KEY_RADIO_ADF_IDENT_ENABLE)                              }                           els{                          (&gt;K:KEY_RADIO_ADF_IDENT_DISABLE) }                           (L:KNOB,number) 5 == (L:SWITCH3,bool) ! &amp;&amp;                          (A:CIRCUIT AVIONICS ON,bool) &amp;&amp; (L:SWITCH2,bool) &amp;&amp;                          if{ (&gt;K:RADIO_VOR2_IDENT_ENABLE)                              }                           els{                          (&gt;K:RADIO_VOR2_IDENT_DISABLE) }                                                  (L:KNOB,number) 5 == (L:SWITCH3,bool) ! &amp;&amp;                          (A:CIRCUIT AVIONICS ON,bool) &amp;&amp; (L:SWITCH2,bool) ! &amp;&amp;                          if{ (&gt;K:KEY_RADIO_ADF2_IDENT_ENABLE)                              }                           els{                          (&gt;K:KEY_RADIO_ADF2_IDENT_DISABLE) }                                </Value>       </Select>      </Element>

Looks like VOR1 and VOR2 give a signal when switching / swapping but ADFs do not. I also tried KEY_RADIO_ADF2_IDENT_TOGGLE / KEY_RADIO_ADF_IDENT_TOGGLE. It works to some extent but the signal is interrupted sometimes and won't turn off.

Any help would be appreciated!
 
Last edited:
Messages
98
Yes, the "KEY" to understanding is that the KEY_ prefix is only used in C/C++ code... :teacher:

Thanks Bill! Yeah it's perfect now :)

BTW, if a switch is animated/clickable in VC it's mandatorily linked to some local variable? Is there any way to see the code?
 

tgibson

Resource contributor
Messages
11,338
Country
us-california
Load the MDL into ModelConverterX. If it is an FS2004 model set the general model to 0. You can figure out which part it is by using the Hierarchy Editor - turn on Highlight Selected. Click on the parts in the left box and when the desired part turns read, read the Animation name in the right box. This is the one you are looking for in the modeldef.xml file. Then click on the Modeldef.xml Editor button to see the code.

Hope this helps,
 
Messages
98
Load the MDL into ModelConverterX.
Tom thanks! Got an error when loading it. But I asked a guy that have access to the model source and he gave it to me.

Have a question about XML syntax for OR operator. I need TRUE for variables A and any of B or C.
Code:
A B C || &amp;&amp;
Is this correct? And for example A and any of B or C or D or E. That's:
Code:
A B C || D || E || &amp;&amp;

That's for example for a switch (ON/OFF) and any of the power sources: Battery, or GPU, or APU, or Engine generators.
 
Last edited:
Messages
98
the second is easy.
Adding (L:BUTTON,bool) 0 == works perfectly for a simple push & release button, no loop, but what if it is STAB TRIM like this one:
XML:
  <Mouse>                     
        <Area>   
         <Tooltip>STAB TRIM</Tooltip>
                <Cursor Type="UpArrow"/>
      <Click Kind="LeftSingle+LeftRelease+Leave">
                (M:Event) 'LeftSingle' scmp 0 ==
                if{
                    -1 (&gt;L:BUTTON,bool) (L:Stabilizer, degree) 0 &lt;
                    1 (&gt;L:PushedSound,number)
                        if{
                            (L:Stabilizer, degree) 0.05 + (&gt;L:Stabilizer, degree)
                          }
                  }

                (M:Event) 'LeftRelease' scmp 0 ==
                if{
                    0 (&gt;L:BUTTON,bool)
                    1 (&gt;L:ReleasedSound,number)
                  }

                (M:Event) 'Leave' scmp 0 ==
                if{
                    0 (&gt;L:BUTTON,bool)
                    1 (&gt;L:ReleasedSound,number)
                  }
        </Click>
        </Area>       
</Mouse>
Adding (L:BUTTON,bool) 0 == will have me click each time I want to move the STAB up or down (similar code). Thanks in advance for the help.
 
Messages
98
Well, adding a 15 sec silence to the sound file so it's enough for the stab to go up or down. However I still would love to hear your ideas on how to remove the loop.
 

Heretic

Resource contributor
Messages
6,830
Country
germany
Your evaluation and sound trigger in the "leftsingle" event is switched.


Generally, if you want to avoid a looping sound in an <Update> section, you need to compare the current stabilizer trim value with its last value in a slightly differently named variable and, if not equal, play the sound and then write the current value to the last value. E.g:

Code:
(L:Stabilizer, degree) (L:Stabilizer_Old, degree) !=            
if{ 1 (">&gt;L:PushedSound,number)
(L:Stabilizer, degree) 0.05 + (">&gt;L:Stabilizer, degree)
(L:Stabilizer, degree) (>L:Stabilizer_Old, degree)
 }
 
Messages
98
you need to compare the current stabilizer trim value with its last value in a slightly differently named variable
Thanks! Actually it's a 3 position switch and sorry I mistakenly put (L:BUTTON,bool) instead of (G:Var1) winch is linked to 3 bitmaps - up, center, & down with values -1, 0, & 1. The STAB range is 0 to -2.5 degrees so the second part of the code is:
XML:
        <Area>  
         <Tooltip>STAB TRIM</Tooltip>
                <Cursor Type="DownArrow"/>
      <Click Kind="LeftSingle+LeftRelease+Leave">
                (M:Event) 'LeftSingle' scmp 0 ==
                if{
                    1 (&gt;G:Var1) (L:Stabilizer, degree) -2.5 &gt;
                    1 (&gt;L:PushedSound,number)
                        if{
                            (L:Stabilizer, degree) 0.05 - (&gt;L:Stabilizer, degree)
                          }
                  }

                (M:Event) 'LeftRelease' scmp 0 ==
                if{
                    0 (&gt;G:Var1)
                    1 (&gt;L:ReleasedSound,number)
                  }

                (M:Event) 'Leave' scmp 0 ==
                if{
                    0 (&gt;G:Var1)
                    1 (&gt;L:ReleasedSound,number)
                  }
        </Click>
        </Area>
Do you mean I have to replace the string (L:Stabilizer, degree) 0.05 + (&gt;L:Stabilizer, degree) in the first part with what you suggested?
 
Top