Jump to content

my upgraded beep() function


Guest
 Share

Recommended Posts

Hello,

A few days ago I wrote a upgraded Beep function based on the normal Beep().

the Improvements done are:

1) you can create more complex beep(see the example).

2) the function have an option to run with non-loop Independent(see the example).

sorry i can't explain it more.. My English is not good enough for that.
But I gave examples and you can explore the examples and play with the variables.

 

the function:

Func PlayBeep($Frequency,$BeepTime,$BeepTimeDiff,$BeepTimeDiff2,$TotalBeepTime,$LoppMode = 1)
Local $Return = 0
If $LoppMode = 1 Then
    Local $beep_timer = TimerInit() , $EndTimer = TimerInit() , $beep_timer2 = TimerInit() , $loop = 1 , $ring = 1
ElseIf $LoppMode = "S" Then
    Global $beep_timer = TimerInit() , $EndTimer = TimerInit() , $beep_timer2 = TimerInit() , $loop = 1 , $ring = 1
EndIf
    If $LoppMode <> "S" Then
        If $ring = 1 Then
            While 1
                If $loop = 1 Then
                    $TimerDiff1 = $BeepTimeDiff2
                ElseIf $loop = 2 Then
                    $TimerDiff1 = TimerDiff($beep_timer2)
                EndIf
                If $TimerDiff1 >= $BeepTimeDiff2 Then 
                    If TimerDiff($beep_timer) >= $BeepTimeDiff Then
                        Beep($Frequency,$BeepTime)
                        $beep_timer = TimerInit()
                    ElseIf TimerDiff($beep_timer2) >= ($BeepTimeDiff2-$BeepTime)*$loop Then
                        $beep_timer2 = TimerInit()
                        If $loop = 1 Then $loop = 2
                    EndIf
                EndIf
                If TimerDiff($EndTimer) >= $TotalBeepTime Then
                    $Return = 1
                    If $LoppMode = 1 Then
                        Return $Return
                    Else
                        $ring = 0
                    EndIf
                EndIf
                If $LoppMode = 1 Then
                    Sleep(10)
                ElseIf $LoppMode = 2 Then
                    Return $ring
                EndIf
            WEnd
        EndIf
    Else
        Return 1
    EndIf
EndFunc

example 1 (Without an independent loop):

Local $LoppMode = "S"
While 1
    $test = PlayBeep(700,430,80,3000,10000,$LoppMode)
    ToolTip($test)
    If $LoppMode = "S" Then $LoppMode = 2
    Sleep(10)
WEnd

example 2 (With independent loop):

PlayBeep(900,200,90,5000,35000)

Hope you liked it :)

Edited by Guest
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...