Hi!
I am using xaudio2 to trigger very simple 100 ms .wav files. The timing is very important in this application, and when the mouse is clicked, the application sends a trigger to the parallel port, and 40 ms later, plays the sound. To play sound, I used MSDN's sample code Xaudio2BasicSound (find it here: https://code.msdn.microsoft.com/wind...mples-024b3933). In that code, the PlayWave() function is defined, which reads the wave file, creates a source voice, submits the data to a buffer, and plays the sound. However, the big problem is that it blocks the application while the sound is playing. I need to send additional triggers to my parallel port while the sound is playing, for example 10 ms after the beginning of the sound. What is it in this playwave function which is blocking the rest of the application? How can I modify that so that it effectively plays my sound in the background and still processes my parallel port triggers?

I am attaching my code, which contains all the xaudio2 functionalities as well as the timing for the different events, in the RunTrials() function.
tactile2ifc_piezo script.txt
Thank you so much.