ppy / osu

rhythm is just a *click* away!
https://osu.ppy.sh
MIT License
14.64k stars 2.16k forks source link

Add a 'ducking' effect to the currently playing track when changing ruleset #28547

Open nekodex opened 1 week ago

nekodex commented 1 week ago

A combination volume+filter effect is added to attenuate the currently playing track to allow the ruleset selection samples to be better heard.

Also adds 'sample-choking' logic to prevent overlapping sample playback when rapidly cycling through rulesets.

https://github.com/ppy/osu/assets/272140/3c505417-1263-4835-836a-65edc28ff157

The ducking is implemented via new methods added to MusicController, which are generic enough to also replace some AudioFilter usages in the codebase that provide a similar effect.

I originally wrote this as a component ala AudioFilter, but having it coupled with an ITrackStore to do audio adjustments for volume attenuation felt weird, so I instead just implemented them as methods on MusicControler (for now?). After ManagedBass is updated to support the volume effect type (i.e. via peppy/ManagedBass#1 ?), we can do attenuation via a volume effect on the mixer instead of using audio adjustments and that'd allow for a cleaner component.

I also tried adding the ducking effect to other places (f.e. ButtonSystem), but due to audio adjustments being relative/percentage-based, I couldn't get it sounding consistently nice... with music volume at 70% it would sound okay, but at 100% it sounded off, especially with louder songs. I'll look into it again later, but maybe a fixed decibel reduction could work better... but that's for a separate/future PR.

LittleLilyBun commented 1 week ago

It seems the game crashes when switching to a custom ruleset with this PR...

https://github.com/ppy/osu/assets/62504841/f9e0fbfd-b5fe-4684-b2cc-ed0614b67112

I'm not really a developer at all, just looking around, but noticed this issue with this PR and thought I should report it.

Logs: compressed-logs.zip