petertalbanese / SoundSwapper

Allows the user to replace sounds with custom .wav files.
BSD 2-Clause "Simplified" License
1 stars 4 forks source link

Performance is extremely slow / freezes #7

Closed jacobholden closed 1 year ago

jacobholden commented 1 year ago

I changed one of my prayer sounds, for example 2686 which is the prayer SMITE sound, and placed a .wav file in the "SoundSwapper" folder in the root directory of runelite.

Now when I activate the SMITE prayer, it works as expected. But if I spam the prayer too much (i.e. 2 clicks in a tick) then runelite freezes for a second. So I think the performance of this plugin makes it unusable at least for my case.

petertalbanese commented 1 year ago

Sorry, this is a known issue! It has to do with the way sounds are loaded into the client. Something I wanted to fix, but haven't had the time to... I'll update the Readme calling out this issue for now. Will see if I can find some more time to look into this this week.

OsrsMerchant commented 1 year ago

Hey :) Can we please get a fix for this? <3

petertalbanese commented 1 year ago

Hey!!! Sorry for the super long delay on this. Last time I tried to fix it I fiddled around for a couple hours and couldn't get it working...then got distracted by life lol.

This time I think I solved it though 😄 It was a combo of what I tried last time and some things I picked up from other RL plugins. All of your custom sound files will be loaded into memory, so the Clip won't have to be re-loaded each time it plays. This removes the lag/freezes completely in my testing. One thing you'll notice: for sounds that occur very frequently (e.g. literally overlapping with itself), the sound will start over rather than stacking. I can try to figure this out in the future, but I think this compromise might be necessary given the limitations of Clip control. Different custom sounds played at the same time should work fine though!

Sorry again for the delay! Hope you like it!

Edit: This is up for review now, so it'll take a day or 2 to go through

OsrsMerchant commented 1 year ago

Thank you for taking the time to fix it!! :D I will test it properly and if any issues I will report it back :)

petertalbanese commented 1 year ago

Hey! This got merged in a few days ago. Let me know when you have a chance to try it out 😄

pajlada commented 1 year ago

@petertalbanese I opened #8 to polish your fix - your fix inadvertently made it reload on other plugin config changes which isn't an issue for most plugins, but some plugins programmatically change a config every tick which in combination with this causes even worse performance.

petertalbanese commented 1 year ago

Hey sorry I was away for the weekend. I'll test this out tonight and get the PR merged in!

petertalbanese commented 1 year ago

Alright! PR is up for review https://github.com/runelite/plugin-hub/pull/4425

Hopefully this will be the end of the bigger bugs 😅