Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve silence detection in MutedNotification #26951

Merged
merged 22 commits into from Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
dfd966e
Improve silence detection in `MutedNotification`
myQwil Jan 31, 2024
3122211
Change silence threshold and target restore volume level
myQwil Feb 2, 2024
f4a2d5f
Round off inaccuracies in the aggregate volume before evaluating
myQwil Feb 2, 2024
5d9200b
Update tests to reflect new restore target volume
myQwil Feb 2, 2024
c60e110
Try to fix code quality issues raised by workflow
myQwil Feb 2, 2024
29a2890
fix code quality error #2
myQwil Feb 2, 2024
906560f
Fix mute button test
myQwil Feb 2, 2024
e4ec8c1
give better volume names to `addVolumeSteps`
myQwil Feb 2, 2024
2ab967f
Increase precision of aggregate volume rounding
myQwil Feb 2, 2024
9a53485
Replace aggregate rounding method with a float cast
myQwil Feb 2, 2024
a9eac59
Remove seemingly unnecessary float casts
frenzibyte Feb 15, 2024
d81b148
Remove mention of decibel units in comment
frenzibyte Feb 15, 2024
5431781
Bring back target volume to 50%
frenzibyte Feb 15, 2024
6751f95
Adjust test cases and approximate equality
frenzibyte Feb 15, 2024
7530b1f
Adjust comment again
frenzibyte Feb 15, 2024
df40f55
Merge branch 'master' into mute_detection
frenzibyte Feb 15, 2024
22dafd8
fix typo
myQwil Feb 15, 2024
9f53185
Revert changes to muted notification action
frenzibyte Feb 16, 2024
6a1d118
Adjust tests again
frenzibyte Feb 16, 2024
952c5b0
Use `Precision.AlmostBigger`
frenzibyte Feb 16, 2024
583e716
Always bring master/music volume to 50%
frenzibyte Feb 16, 2024
bbd7706
Merge branch 'master' into mute_detection
frenzibyte Feb 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
Expand Up @@ -264,15 +264,23 @@ public void TestModDisplayChanges()
}

[Test]
public void TestMutedNotificationMasterVolume()
public void TestMutedNotificationHighMasterVolume()
{
addVolumeSteps("master volume", () => audioManager.Volume.Value = 0, () => audioManager.Volume.Value == 0.5);
addVolumeSteps("master and music volumes", () =>
{
audioManager.Volume.Value = 0.6;
audioManager.VolumeTrack.Value = 0.01;
}, () => Precision.AlmostEquals(audioManager.Volume.Value, 0.6) && Precision.AlmostEquals(audioManager.VolumeTrack.Value, 0.83));
}

[Test]
public void TestMutedNotificationTrackVolume()
public void TestMutedNotificationLowMasterVolume()
{
addVolumeSteps("music volume", () => audioManager.VolumeTrack.Value = 0, () => audioManager.VolumeTrack.Value == 0.5);
addVolumeSteps("master and music volumes", () =>
{
audioManager.Volume.Value = 0.01;
audioManager.VolumeTrack.Value = 0.15;
}, () => Precision.AlmostEquals(audioManager.Volume.Value, 0.5) && Precision.AlmostEquals(audioManager.VolumeTrack.Value, 1));
}

[Test]
Expand All @@ -281,9 +289,10 @@ public void TestMutedNotificationMuteButton()
addVolumeSteps("mute button", () =>
{
// Importantly, in the case the volume is muted but the user has a volume level set, it should be retained.
audioManager.Volume.Value = 0.5f;
audioManager.VolumeTrack.Value = 0.5f;
volumeOverlay.IsMuted.Value = true;
}, () => !volumeOverlay.IsMuted.Value && audioManager.VolumeTrack.Value == 0.5f);
}, () => !volumeOverlay.IsMuted.Value && audioManager.Volume.Value == 0.5f && audioManager.VolumeTrack.Value == 0.5f);
}

/// <remarks>
Expand Down
8 changes: 5 additions & 3 deletions osu.Game/Screens/Play/PlayerLoader.cs
Expand Up @@ -550,8 +550,10 @@ private void showMuteWarningIfNeeded()
{
if (!muteWarningShownOnce.Value)
{
double aggregateVolumeTrack = audioManager.Volume.Value * audioManager.VolumeTrack.Value;

// Checks if the notification has not been shown yet and also if master volume is muted, track/music volume is muted or if the whole game is muted.
if (volumeOverlay?.IsMuted.Value == true || audioManager.Volume.Value <= volume_requirement || audioManager.VolumeTrack.Value <= volume_requirement)
if (volumeOverlay?.IsMuted.Value == true || aggregateVolumeTrack <= volume_requirement)
{
notificationOverlay?.Post(new MutedNotification());
muteWarningShownOnce.Value = true;
Expand Down Expand Up @@ -583,9 +585,9 @@ private void load(OsuColour colours, AudioManager audioManager, INotificationOve
// Check values before resetting, as the user may have only had mute enabled, in which case we might not need to adjust volumes.
// Note that we only restore halfway to ensure the user isn't suddenly overloaded by unexpectedly high volume.
if (audioManager.Volume.Value <= volume_requirement)
audioManager.Volume.Value = 0.5f;
audioManager.Volume.Value = 0.5;
if (audioManager.VolumeTrack.Value <= volume_requirement)
audioManager.VolumeTrack.Value = 0.5f;
audioManager.VolumeTrack.Value = 0.5;

myQwil marked this conversation as resolved.
Show resolved Hide resolved
return true;
};
Expand Down