I have a Dialog box with a radio button on, when I click it it should make a sound using the PlaySound function. There is a short delay between clicking and hearing the sound. How can I make it so that the delay is as short as possible?
When the program starts it reads the .wav file and stores it in memory. I do this so I can use a trackbar control to change the volume of the sample.
I have also downloaded Audacity so I can hear and modify the sample.
Now, when I click on the play button in Audacity this takes a similar amount of time to play the sample as my program does. This is not what I want. If I use the Peekmessage function instead of GetMessage would this make any difference ? And if it may can someone show me the message loop using peekmessage instead of getmessage.
not sure if peek is faster than get or not. They should be about the same, the extra work to remove the message after reading should be microscopic.
if you try peek, it should be peek, play, get and discard so you lose the message after you handled it.
What you need to do is find the delay. I don't know how to tell you to do that; maybe eliminate the button press for example, and make it happen say 10 seconds after the program initialize stuff is done. See if its in the library itself, or some sort of hardware thing (eg buffering to the device? Don't know how sound works here...). Does your tool have a play and pause/resume? Maybe you can start it playing when you load to memory and pause it instantly, so your play just releases the pause?
All I am saying is you can't fix it until you find it, unless you get lucky or you have info from web or something on some things to try. EG see if this helps: https://stackoverflow.com/questions/30338079/c-playing-sound-lag ... the 'direct' libraries are often a performance cure; and this post says use directsound instead of whatever the other one is if you want it FAST.