Recent

Author Topic: Beep without delay  (Read 4074 times)

PeterH

  • New Member
  • *
  • Posts: 31
Beep without delay
« on: March 22, 2018, 10:08:03 pm »
Hello,

I have made an application in which a countdown is  used. 3,2,1, start. In 1 second steps.
I want to play a small beep on every second but this beep is played with a delay up to 1 second.

I have tried :

Code: Pascal  [Select][+][-]
  1. sndPlaySound(pchar(UTF8ToSys(path + '\beep_low.wav')), snd_Async)
  2. PlaySound('beep_low.wav', 0, SND_ASYNC);
  3. windows.beep(500,100);      
  4.  

but they all have a delay. Is there a way to play a small wav file without delay?
It seems that windows 7 has less or no delay but Windows 10 does have the delay.
It has to run on a windows 10 machine.

Beep_low.wav is wav file with a length of 250ms and they are played in the timerinterrupt of a 1 second timer.

Thanks in advance,

Peter

rvk

  • Hero Member
  • *****
  • Posts: 6056
Re: Beep without delay
« Reply #1 on: March 22, 2018, 10:14:29 pm »
PlaySound() with SND_ASYNC should work.
Have you tried it with a .wav files that's much longer?
Does the delay stay the same (in terms of ms).

Of course playing a sound from a file the program would need to read the sound from the file which always leads to some delay (in terms of ms). You could try to get around that by using the sound-data in a resource.

You could also just run windows.beep() in a separate thread.

 

TinyPortal © 2005-2018