play 1 sound 2 times?

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
Tomonline
Prole
Posts: 17
Joined: Sun Oct 20, 2013 12:29 am

Re: play 1 sound 2 times?

Post by Tomonline »

ok :
x.love
(64.14 KiB) Downloaded 179 times
.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: play 1 sound 2 times?

Post by kikito »

I am attaching a fixed version.

I had to do more work than anticipated (clone each source before playing it, and storing it in a "current" var). This is because LÖVE seems to be doing something strange with the sources: when a source has finished playing, and you play it again (with :play), it sometimes returns false on :isPlaying - as a result, some words were being skipped if you used them twice on the same phrase, a bit randomly.

By cloning the source before playing it I sidestep this issue (at the price of consuming a bit more memory).

I seem to remember there was a detected problem with sources on 0.9.1 which was fixed on 0.9.2, maybe that was it.
Attachments
x.love
(65.2 KiB) Downloaded 79 times
When I write def I mean function.
User avatar
Tomonline
Prole
Posts: 17
Joined: Sun Oct 20, 2013 12:29 am

Re: play 1 sound 2 times?

Post by Tomonline »

kikito wrote:I am attaching a fixed version.

I had to do more work than anticipated (clone each source before playing it, and storing it in a "current" var). This is because LÖVE seems to be doing something strange with the sources: when a source has finished playing, and you play it again (with :play), it sometimes returns false on :isPlaying - as a result, some words were being skipped if you used them twice on the same phrase, a bit randomly.

By cloning the source before playing it I sidestep this issue (at the price of consuming a bit more memory).

I seem to remember there was a detected problem with sources on 0.9.1 which was fixed on 0.9.2, maybe that was it.
ok, thank you for this fix :)

[edit:] the memory is not going to be filled with duplicates after a few sentences right?

i really hope this is fixed in 0.9.2.
is it possible to download version 0.9.2 anywhere that you know of or did you just noticed somewhere it maybe be fixed in 0.9.2?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: play 1 sound 2 times?

Post by kikito »

Some memory will get filled with those extra sources, and when they are finished playing and are de-referenced from the phrase, they will be garbage-collected.

On the particular example I gave you the "last clone" keeps being referenced by words.current so it will never be garbage collected. You can change this by making current = nil when the phrase is finished (when phrase.index > #phrase)
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests