soloud icon indicating copy to clipboard operation
soloud copied to clipboard

Possible invalidation of voice handle before sound is done playing

Open lilmike opened this issue 9 years ago • 5 comments

Hi, On certain computers, native win32 and native arch linux vm, but not on some, for example another arch linux computer, soloud will cut off the last part of a sound at the end of the program, for example about .5 seconds. I check the isValidVoiceHandle function on the handle, and sleep for 10 milliseconds in a while loop until it returns 0. This makes me think that the isValidVoiceHandle function is returning 0 earlier than it should, causing my program to quit the function early, causing the Wav class to become invalid as well. I don't know if this is the case, but for some reason the program exits before the sound is done playing. -Michael.

lilmike avatar Feb 28 '15 15:02 lilmike

The voice handle is invalidated when soloud is done with the sound. It's possible that the sound itself is still playing, because all audio is buffered.

Now, how to check that audio has ended, that's a good question.

On Sat, Feb 28, 2015 at 5:54 PM, Michael Taboada [email protected] wrote:

Hi, On certain computers, native win32 and native arch linux vm, but not on some, for example another arch linux computer, soloud will cut off the last part of a sound at the end of the program, for example about .5 seconds. I check the isValidVoiceHandle function on the handle, and sleep for 10 milliseconds in a while loop until it returns 0. This makes me think that the isValidVoiceHandle function is returning 0 earlier than it should, causing my program to quit the function early, causing the Wav class to become invalid as well. I don't know if this is the case, but for some reason the program exits before the sound is done playing. -Michael.

— Reply to this email directly or view it on GitHub https://github.com/jarikomppa/soloud/issues/76.

jarikomppa avatar Feb 28 '15 16:02 jarikomppa

Ah yes, that makes sense. I noticed that using oss on my vm the program cuts off quite a bit. On windows using winmm, it cuts off a little, and using sdl2, it cuts off almost nothing. If you can figure out a way to check if audio has ended that would be nice though :-). -Michael.

lilmike avatar Feb 28 '15 19:02 lilmike

what about waiting for the sample duration to happen, after sound has been triggered?

r-lyeh-archived avatar Feb 28 '15 20:02 r-lyeh-archived

Has there been any progress on this issue? Sound effects can be important to ex. fast paced games, and having things cut off can really have an impact on user experience; especially if the sounds themselves are also short...

hsdk123 avatar Dec 04 '18 23:12 hsdk123

The question is related to terminating the application. While the application is playing, the sounds do play to the finish without problems.

If you make a small application that, say, plays a phrase through a speech synth, waits until SoLoud says the voice handle is invalid (assuming it's played), but at that point SoLoud has read the sound from the speech synth and sent it to the back end; the back end may not have played it yet.

Then the application terminates, killing off the back end, cutting off the sample.

There's no trivial way to detect when the backend has played everything. I'd assume doing a sleep((buffersize * 1000) / samplerate) before quiting would do it, but quite frankly that's not a guarantee either.

jarikomppa avatar Feb 22 '20 11:02 jarikomppa