FS2004 Super charger sound problem

I am designing for fs9 I am trying to simulate a supercharger whine sound. The code below gives the lever movement and sound for the medium and high settings but the sound continues to run when the engine is shut down.
       <code>0 (L:spr_chrg_lever,enum) 50 * +</code>
       <tooltip_text>Left_Clicks to charge/Right_Clicks to return</tooltip_text>
            (M:Event) 'LeftSingle' scmp 0 ==
                                                                          if{ 1 (L:spr_chrg_lever,enum) ++ 10 min (>L:spr_chrg_lever,enum) }
            (M:Event) 'RightSingle' scmp 0 ==
                if{ -1 (L:spr_chrg_lever,enum) -- 0 max (>L:spr_chrg_lever,enum) }
               1 (&gt;L:XMLSND8,enum)
        (L:spr_chrg_lever,enum) >1
               if{ 2 (>L:XMLSND29,enum) }
               els{ 3 (>L:XMLSND29,enum) }
        (L:spr_chrg_lever,enum) 1 >
               if{ 2 (>L:XMLSND28,enum) }
               els{ 3 (>L:XMLSND28,enum) }
I think what I need is a code that uses the (A:GENERAL ENG1 COMBUSTION, bool) to return the spr_chrg_lever to 0 when the engine is shut down. Or is there any other way to shut the sound off when the engine is shut down.

I expect to be loosing my internet connection some time over the weekend, roommate is moving out. So I may not be able to respond untill I can get to a free wifi spot some time next week. I can monitor responses on my company phone but have not figured out how to post with it.

From the doc

0 - Stop Sound

2 - Play sound as a loop, without changing the existing volume or pan settings
3 - Set the sound's volume, using the setting found in the specified VolumeIn variable, see below
You have to stop the sound in your code.
You will have to use an A: variable with RPM or N1.



Resource contributor
Here is your problem, incorrect syntax!

(L:spr_chrg_lever,enum) >1
I have no idea whatever what you intend as a condition here, but that is most definitely wrong...

You already have "if greater than 1" as your XMLSND28 condition.

@Edi: Carl is using a licensed version of my sound module. In this case 2 = start loop and 3 = stop loop
Thanks Bill and Edi
I used the incorrect syntax because it seems to play the needed sound at the needed time in the levers animation.
(L:spr_chrg_lever,enum) >1
starts the medium pitch sound when the lever is clicked to move to the mid point in the key frame animation.
(L:spr_chrg_lever,enum) 1 >
starts the high pitch sound when the lever is clicked to move from the mid point in the key frame animation to the end. Both sounds turn off on cue with the lever return clicks.
I was having trouble getting the sounds to play on cue and stumbled across it during trial and error, and it works on cue so I used it. Now the problem is getting the sounds to turn off when the engine is shut down. I am still working on that.



Resource contributor
You need a "logic" section for your modeldef.xml -or- an invisible XML "logic" gauge with an <Update> section.

In either case, you would then need to add this simple conditional check and command sequence:
(A:GENERAL ENG1 COMBUSTION, bool) ! if{ 0 (>L:spr_chrg_lever,enum) }

Writing the invisible logic gauge returned the lever to 0 as desired but did not stop the sound. So I re wrote the code as:

<Gauge Name="f4u1 Supr" Version="1.0">
            <Image Name="f4u1_ll_on_bg.bmp"/>
    (A:GENERAL ENG1 COMBUSTION, bool) ! if{ 0 (>L:spr_chrg_lever,enum) 3 (>L:XMLSND29,enum) 3 (>L:XMLSND28,enum) }
Now the lever returns to zero and the sound cuts off. Joy!
Thank you! Bill



Resource contributor
That makes sense because the conditions in your mouse routine will only be affective whenever you click on the lever. I thought about killing the sound(s) in the script suggested, but didn't edit my reply in time. I'm happy though that you figured it out on your own... :idea: