# Thread: problem with sound script

1. ## problem with sound script

Several weeks ago I began a simple script with sounds, but I committed a mistaque that I'm not able to find from then on:
when the aircraft speed is higher than 135Knt, I want to sound (only one time!) an alarm, but sadly this sound repits again and again, very quickly. This alarm only stops when the speed is slower than 135Knt.
I don't undertand, I thought that Var0702 was enough to stop the sound.
This is the script:

Var 0701, Link SOUND // Sound on
Var 0702, Link SOUND, Type S // Sound off

Var 1224
Var 1220, Link FSUIPC_IN, Offset \$02BC, Length 4 // IAS in knots * 128
{
V1224 = V1220 / 128 // IAS
IF V1224 > 135 // if IAS higher than 135Knt...
{
V0701 = 3 // the alarm file in sioc.ini
V0701 = 0
}
ELSE
{
V0702 = 3
V0702 = 0
}
}

Please, I need your advice.
Greetings from Barcelona, Spain.

2. ## Re: problem with sound script

With your code the sound is triggered when the speed reaches more than 135 knots AND ABOVE. So the sound will play at over 135 knots and it will repeat until the speed drops below 135 knots. This because the code attached to variable 1220 will run every time the value of var 1220 changes ie for 135.1, 135.2, 135.3 knots etc etc. There are probably a number of ways to recode. You could create a variable called "IAS-over_135" and set this to 1 when you first go over 135 knots. Then insert a line to test if the IAS_over_135 variable is 1 before playing the sound. You will also need to add a line to reset the IAS_over_135 variable to zero after the sound has played once

Others may know a simpler way to solve this

David
Edited to correct logic !!

3. ## Re: problem with sound script

dear friend David,
thanks a lot for your help.

Your suggestion has given me some ideas to modify the script. I have to think about it.

Greetings, Mike.