Jump to content

Playing sound every 16th minute of every hour


Recommended Posts

Keep in mind with a loop like that, the script is going to consume massive CPU, as well as play the sound, (weather audible or not) MANY times in that 16th minute... I suggest something like...

While 1
     If @MIN = 16 Then
          SoundPlay("C:\test.wav",1)
          Sleep(60000)
     EndIf
     sleep(1000)
WEnd

That way the second it hits the 16th minute, you clearly hear the sound... and you don't hear it again until the next 16th minute... It doesn't consume CPU, and slower machines won't sound like a skipping record for 60 seconds... :P

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

My grossly over complicated addition...

Global $minute = 16
Global $hour = -1;Any hour
Global $played = 0
AdlibEnable("_Chimer", 1000)

While 1
    Sleep(100)
WEnd

Func _Chimer()
    Local $lhour, $lminute = @MIN
    If $hour = -1 Then $lhour = @HOUR
    If $lminute = $minute Then
        If Not $played Then
            SoundPlay(@WindowsDir & "\MEDIA\notify.WAV")
            $played = 1
        ;I did this to test for more than one case...
        ;$minute += 1
        EndIf
    Else
        $played = 0
    EndIf
EndFunc  ;==>_Chimer
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...