#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Interrupt-able beep


    Dear all,

    I want to create something like a distance control as known in cars.
    Therefor I would need a continuous beep undefined duration, which I could stop by a second procedure.

    Is this easily possible, can anybody give me an example.

    Thx
    Alex
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    156
    Rep Power
    3
    Originally Posted by lupoli
    Dear all,

    I want to create something like a distance control as known in cars.
    Therefor I would need a continuous beep undefined duration, which I could stop by a second procedure.

    Is this easily possible, can anybody give me an example.

    Thx
    Alex
    Hi Alex,

    If you know how to deal with multithreading, you can consider this easy. Just play the beep in separate thread. Play the beep in loop, and each time a beep finish, the thread should check a flag. If the flag is set, the thread must be terminated thus exit the loop. The second procedure is the one to set the flag.

    You can safely use a boolean or integer variable for a flag. Or if you want to be more familiar with multithreading, you can consider using TEvent for the flag.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0
    Hi Luthfi ,

    thank you for the reply, that is what I already tried, but than there is a small delay between the beep's, but I would need a continuous beep.

    thanx Alex
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    156
    Rep Power
    3
    Originally Posted by lupoli
    Hi Luthfi ,

    thank you for the reply, that is what I already tried, but than there is a small delay between the beep's, but I would need a continuous beep.

    thanx Alex
    Hi Alex,

    Then you should not use Windows.Beep or "Delphi" Beep. I think Windows has api named playSound or something similar that able to play a sound file continously (in loop) which can be stopped if you can the same api without sound file or with specific flag. So use this api in that separate thread.

    I am currently a bit busy, so you have to look it up the details yourself. Once I have a time, I'll try to find the details.

IMN logo majestic logo threadwatch logo seochat tools logo