Page 2 of 2
Re: play 1 sound 2 times?
Posted: Tue Jan 06, 2015 2:15 pm
by Tomonline
ok :
- x.love
- (64.14 KiB) Downloaded 179 times
.
Re: play 1 sound 2 times?
Posted: Tue Jan 06, 2015 5:20 pm
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.
Re: play 1 sound 2 times?
Posted: Tue Jan 06, 2015 5:51 pm
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?
Re: play 1 sound 2 times?
Posted: Tue Jan 06, 2015 7:36 pm
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)