mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 15:27:30 +08:00
Enforce minimum gameplay sample volume of 5%
This commit is contained in:
parent
a26e0bda35
commit
b321d556b6
@ -108,7 +108,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
RelativeSizeAxes = Axes.X
|
||||
},
|
||||
tailContainer = new Container<DrawableHoldNoteTail> { RelativeSizeAxes = Axes.Both },
|
||||
slidingSample = new PausableSkinnableSound { Looping = true }
|
||||
slidingSample = new PausableSkinnableSound
|
||||
{
|
||||
Looping = true,
|
||||
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME,
|
||||
}
|
||||
});
|
||||
|
||||
maskedContents.AddRange(new[]
|
||||
|
@ -107,7 +107,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
headContainer = new Container<DrawableSliderHead> { RelativeSizeAxes = Axes.Both },
|
||||
OverlayElementContainer = new Container { RelativeSizeAxes = Axes.Both, },
|
||||
Ball,
|
||||
slidingSample = new PausableSkinnableSound { Looping = true }
|
||||
slidingSample = new PausableSkinnableSound
|
||||
{
|
||||
Looping = true,
|
||||
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME,
|
||||
}
|
||||
});
|
||||
|
||||
PositionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
|
||||
|
@ -99,6 +99,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
spinningSample = new PausableSkinnableSound
|
||||
{
|
||||
Volume = { Value = 0 },
|
||||
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME,
|
||||
Looping = true,
|
||||
Frequency = { Value = spinning_sample_initial_frequency }
|
||||
}
|
||||
|
@ -159,6 +159,26 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
/// </summary>
|
||||
internal bool IsInitialized;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum allowable volume for sample playback.
|
||||
/// <see cref="Samples"/> quieter than that will be forcibly played at this volume instead.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Drawable hitobjects adding their own custom samples, or other sample playback sources
|
||||
/// (i.e. <see cref="GameplaySampleTriggerSource"/>) must enforce this themselves.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This sample volume floor is present in stable, although it is set at 8% rather than 5%.
|
||||
/// See: https://github.com/peppy/osu-stable-reference/blob/3ea48705eb67172c430371dcfc8a16a002ed0d3d/osu!/Audio/AudioEngine.cs#L1070,
|
||||
/// https://github.com/peppy/osu-stable-reference/blob/3ea48705eb67172c430371dcfc8a16a002ed0d3d/osu!/Audio/AudioEngine.cs#L1404-L1405.
|
||||
/// The reason why it is 5% here is that the 8% cap was enforced in a silent manner
|
||||
/// (i.e. the minimum selectable volume in the editor was 5%, but it would be played at 8% anyways),
|
||||
/// which is confusing and arbitrary, so we're just doing 5% here at the cost of sacrificing strict parity.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public const int MINIMUM_SAMPLE_VOLUME = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
@ -181,7 +201,10 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
comboColourBrightness.BindTo(gameplaySettings.ComboColourNormalisationAmount);
|
||||
|
||||
// Explicit non-virtual function call in case a DrawableHitObject overrides AddInternal.
|
||||
base.AddInternal(Samples = new PausableSkinnableSound());
|
||||
base.AddInternal(Samples = new PausableSkinnableSound
|
||||
{
|
||||
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME
|
||||
});
|
||||
|
||||
CurrentSkin = skinSource;
|
||||
CurrentSkin.SourceChanged += skinSourceChanged;
|
||||
|
@ -7,6 +7,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Skinning;
|
||||
@ -45,7 +46,10 @@ namespace osu.Game.Rulesets.UI
|
||||
Child = hitSounds = new Container<SkinnableSound>
|
||||
{
|
||||
Name = "concurrent sample pool",
|
||||
ChildrenEnumerable = Enumerable.Range(0, max_concurrent_hitsounds).Select(_ => new PausableSkinnableSound())
|
||||
ChildrenEnumerable = Enumerable.Range(0, max_concurrent_hitsounds).Select(_ => new PausableSkinnableSound
|
||||
{
|
||||
MinimumSampleVolume = DrawableHitObject.MINIMUM_SAMPLE_VOLUME
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -20,6 +20,12 @@ namespace osu.Game.Skinning
|
||||
/// </summary>
|
||||
public partial class SkinnableSound : SkinReloadableDrawable, IAdjustableAudioComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// The minimum allowable volume for <see cref="Samples"/>.
|
||||
/// <see cref="Samples"/> that specify a lower <see cref="ISampleInfo.Volume"/> will be forcibly pulled up to this volume.
|
||||
/// </summary>
|
||||
public int MinimumSampleVolume { get; set; }
|
||||
|
||||
public override bool RemoveWhenNotAlive => false;
|
||||
public override bool RemoveCompletedTransforms => false;
|
||||
|
||||
@ -156,7 +162,7 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
var sample = samplePool?.GetPooledSample(s) ?? new PoolableSkinnableSample(s);
|
||||
sample.Looping = Looping;
|
||||
sample.Volume.Value = s.Volume / 100.0;
|
||||
sample.Volume.Value = Math.Max(s.Volume, MinimumSampleVolume) / 100.0;
|
||||
|
||||
samplesContainer.Add(sample);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user