Question about love.audio.rewind()

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
ninwa
Party member
Posts: 118
Joined: Tue Oct 12, 2010 1:21 am
Location: Metro Detroit
Contact:

Re: Question about love.audio.rewind()

Post 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.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Question about love.audio.rewind()

Post 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... >_>
Hello, I am not dead.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Question about love.audio.rewind()

Post 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:
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Question about love.audio.rewind()

Post 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.)
User avatar
ninwa
Party member
Posts: 118
Joined: Tue Oct 12, 2010 1:21 am
Location: Metro Detroit
Contact:

Re: Question about love.audio.rewind()

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Mathisto and 46 guests