zorggn / love-asl

Advanced Source Library for Löve
ISC License
32 stars 3 forks source link

weird things happen for sounds < 0.3s, and seemingly when the same sound is played twice in < 0.3s between #3

Closed lilmike closed 2 years ago

lilmike commented 2 years ago

Hiya,

I've pretty successfully integrated ripple and asl into my game, and most things are working as expected. However, one thing that I immediately noticed, is that if you're trying to play a sound whose duration is < 0.3s, asl will play the sound, then loop it for just long enough for the duration played in total to be 0.3s or so (estimated). What I do know for sure, is making a sound 0.3s by padding or other means causes the problem to disappear.

I thought this was all, so I change my sounds slightly to make them 0.3s or greater, and went on with my day, intending to report the issue later. However, just now, when testing my game, I noticed something that seems to be related to that same number, 0.3s (by approximation): When I try to play a sound with ripple, this one in partiular is 0.31s, so over that threshhold), but you do it rather quickly, it does a very similar stutter. My first hunch would be that something about playing the same sound before 0.3s have passed after playing the first causes that weird stutter, but this is just a guess. Based on the fact that sounds have to be longer than 0.3s to not trigger the first issue, and that the speed of my footsteps was around 0.3s or less when I started having this issue, my guess is they're somehow related. Where or how, I have no idea though.

Thanks for any help,

-Michael.

lilmike commented 2 years ago

I've made a simple example that indicated both of these issues: Steps should play approx every 0.2s, and will stutter on every 2 approximately. Pressing space will play a jump or boing sound that is less than 0.3s, which will have the indicated behavior. Pressing escape will close the program.

-Michael.

asl-example-0.3s.love.zip

zorggn commented 2 years ago

I committed a change that fixes the issue on my end, please test it out.

lilmike commented 2 years ago

Hiya,

Sorry, apparently my email replies aren't getting to the issues. How annoying. We probably should reopen this issue, the push fixed the jump sound (heard when you press space in the demo), but the footstep weirdness is still there.

-Michael.

lilmike commented 2 years ago

Hiya,

That seems to fix issue of a single sound less than 0.3s being stuttery, but it doesn't seem to fix the issue of sounds being played relatively quickly on my end. In terms of the example.love file, replacing asl-thread.lua with the new one, the jump sound plays perfectly well, while the footsteps still stutter quite often.

-Michael.

On Tue, Oct 04, 2022 at 07:08:46AM -0700, zorg wrote:

I committed a change that fixes the issue on my end, please test it out.

-- Reply to this email directly or view it on GitHub: https://github.com/zorggn/love-asl/issues/3#issuecomment-1267065912 You are receiving this because you authored the thread.

Message ID: @.***>

-- Sorry about the test, it's just a me thing. Michael Taboada, Creator of Games. Does that make me a god, well, sorta. My pgp key: 79BC390E8864CD71305D4DD606CD2197A6EE5ED7 My website: https://michaels.world 2MB website: https://2mb.games Don't believe everything you read on the internet. I might not be real, you might not be real, and this email certainly isn't real. Sent from my super powered... stationary bicycle

zorggn commented 2 years ago

Okay, so i believe that the remaining issue stems from the fact that

  1. You're not setting a buffer size for the Asources, so they default to 2048 samplepoints, and that
  2. The library is threaded, unlike regular Sources (in terms of their lua-side methods.)

Due to these two things, Ripple sometimes gets the memo a bit late that an ASource went into the stopped state, and it starts up another one, and this can happen multiple times, hence the stutteryness.

With me changing the buffer size down to 256 samplepoints, or increasing the time delay, the issue vanishes, so i'm not sure that i can fix the root cause of this in the current iteration of the library sadly.

lilmike commented 2 years ago

Hiya,

Does the clone method respect the buffer variable (third parameter to constructor), because when setting the newAdvancedSource in the example to 256 or even 32, it works ok for about a second or two, but then reverts to the stuttering.

-Michael.

zorggn commented 2 years ago

Yes, it should just copy it over from the original source.

Another thing you can try additionally is to force Ripple to pre-generate some extra sources by muting the ripple object, and then calling play like 3-4 times in a row, that might help.

lilmike commented 1 year ago

Hiya,

I'm still having trouble with quick footsteps causing stuttering. I've tried your suggestion, I've tried from 4 to 10 pre-made instances and a buffer size of 32 with no dice. Any other ideas? It would be a shame to not be able to pair these two great projects together...

-Michael.

On Tue, Oct 11, 2022 at 03:59:11AM -0700, zorg wrote:

Yes, it should just copy it over from the original source.

Another thing you can try is to force Ripple to pre-generate some extra sources by muting the ripple object, and then calling play like 3-4 times in a row, that might help.

-- Reply to this email directly or view it on GitHub: https://github.com/zorggn/love-asl/issues/3#issuecomment-1274504254 You are receiving this because you authored the thread.

Message ID: @.***>

-- Sorry about the test, it's just a me thing. Michael Taboada, Creator of Games. Does that make me a god, well, sorta. My pgp key: 79BC390E8864CD71305D4DD606CD2197A6EE5ED7 My website: https://michaels.world 2MB website: https://2mb.games Don't believe everything you read on the internet. I might not be real, you might not be real, and this email certainly isn't real. Sent from my brand new... stationary bicycle

zorggn commented 1 year ago

Sorry for the late reply; sadly i don't see an easy solution to get interop to work properly, there is an option i've been considering: Since i'm gonna add a few more things to this library, i could add tagging support to it as well, and/or have it be possible for it to not be threaded.

I have no ETA though.