Page 2 of 2

Re: Question about love.audio.rewind()

Posted: Tue Oct 12, 2010 1:03 pm
by ninwa
nevon wrote:Not that I know what that piece of code does, but I suspect it turns off the garbage collector - which certainly wouldn't be a solution.

The reason the game crashed now, I suspect, is because your sound source is being cleaned up by the garbage collector after your function has been run - before it has stopped playing. To fix it, set up a sound queue, add every sound to that, remove the sounds once they've been played. Pretty simple.
Once again, thank you nevon. This shouldn't be too difficult.

Re: Question about love.audio.rewind()

Posted: Tue Oct 12, 2010 1:10 pm
by zac352
nevon wrote:Not that I know what that piece of code does, but I suspect it turns off the garbage collector - which certainly wouldn't be a solution.

The reason the game crashed now, I suspect, is because your sound source is being cleaned up by the garbage collector after your function has been run - before it has stopped playing. To fix it, set up a sound queue, add every sound to that, remove the sounds once they've been played. Pretty simple.
The lua manual is very specific in saying if the metatable field gc is 0, it will immediately force the garbage collector on that object... >_>

Re: Question about love.audio.rewind()

Posted: Tue Oct 12, 2010 1:52 pm
by nevon
zac352 wrote:The lua manual is very specific in saying if the metatable field gc is 0, it will immediately force the garbage collector on that object... >_>
Thanks for the information, but how would that help, exactly? :huh:

Re: Question about love.audio.rewind()

Posted: Wed Oct 13, 2010 12:45 am
by bmelts
This thread's gotten a bit off-topic. Bringing it back:
ninwa wrote:The problem I ran into at first was that this would only successfully play once every couple of seconds or so.
This is a known bug with LÖVE's WAV decoding, unfortunately. The easiest way to avoid that lag is to use a different audio format (may I recommend OGG?) - this will stop the Source as soon as it's done playing, instead of having the annoying delay WAV has. This would remove the need to generate a new Source every time the sound is played, and thus obviate the above argument about garbage collection.
ninwa wrote:This worked, however it also rewinds my background music and any other audio sources for that matter.

What am I doing wrong?
Nothing, it's the engine's fault - in 0.6.2, love.audio.rewind always rewound every Source, not just the one you specified. That's been fixed in the 0.7.0 beta. (You can still call love.audio.rewind with no arguments to rewind everything.)

Re: Question about love.audio.rewind()

Posted: Wed Oct 13, 2010 2:37 am
by ninwa
anjo wrote:This thread's gotten a bit off-topic. Bringing it back:
ninwa wrote:The problem I ran into at first was that this would only successfully play once every couple of seconds or so.
This is a known bug with LÖVE's WAV decoding, unfortunately. The easiest way to avoid that lag is to use a different audio format (may I recommend OGG?) - this will stop the Source as soon as it's done playing, instead of having the annoying delay WAV has. This would remove the need to generate a new Source every time the sound is played, and thus obviate the above argument about garbage collection.
ninwa wrote:This worked, however it also rewinds my background music and any other audio sources for that matter.

What am I doing wrong?
Nothing, it's the engine's fault - in 0.6.2, love.audio.rewind always rewound every Source, not just the one you specified. That's been fixed in the 0.7.0 beta. (You can still call love.audio.rewind with no arguments to rewind everything.)
Thank you Anjo. I will gladly convert the audio files to ogg (they're smaller anyway, why wouldn't I?) I appreciate the response.