mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 23:03:02 +08:00
Merge branch 'master' into seek-to-start-not-end
This commit is contained in:
commit
669d9231db
@ -11,7 +11,6 @@ using osu.Framework.Extensions.TypeExtensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
@ -96,8 +95,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected virtual float SamplePlaybackPosition => 0.5f;
|
protected virtual float SamplePlaybackPosition => 0.5f;
|
||||||
|
|
||||||
private readonly BindableDouble balanceAdjust = new BindableDouble();
|
|
||||||
|
|
||||||
private BindableList<HitSampleInfo> samplesBindable;
|
private BindableList<HitSampleInfo> samplesBindable;
|
||||||
private Bindable<double> startTimeBindable;
|
private Bindable<double> startTimeBindable;
|
||||||
private Bindable<bool> userPositionalHitSounds;
|
private Bindable<bool> userPositionalHitSounds;
|
||||||
@ -173,7 +170,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
}
|
}
|
||||||
|
|
||||||
Samples = new SkinnableSound(samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)));
|
Samples = new SkinnableSound(samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)));
|
||||||
Samples.AddAdjustment(AdjustableProperty.Balance, balanceAdjust);
|
|
||||||
AddInternal(Samples);
|
AddInternal(Samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,8 +356,11 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
{
|
{
|
||||||
const float balance_adjust_amount = 0.4f;
|
const float balance_adjust_amount = 0.4f;
|
||||||
|
|
||||||
balanceAdjust.Value = balance_adjust_amount * (userPositionalHitSounds.Value ? SamplePlaybackPosition - 0.5f : 0);
|
if (Samples != null)
|
||||||
Samples?.Play();
|
{
|
||||||
|
Samples.Balance.Value = balance_adjust_amount * (userPositionalHitSounds.Value ? SamplePlaybackPosition - 0.5f : 0);
|
||||||
|
Samples.Play();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Audio.Sample;
|
|
||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using osu.Framework.Graphics.Audio;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
@ -17,25 +17,32 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
private readonly ISampleInfo[] hitSamples;
|
private readonly ISampleInfo[] hitSamples;
|
||||||
|
|
||||||
private List<(AdjustableProperty property, BindableDouble bindable)> adjustments;
|
|
||||||
|
|
||||||
private SampleChannel[] channels;
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private ISampleStore samples { get; set; }
|
private ISampleStore samples { get; set; }
|
||||||
|
|
||||||
|
public SkinnableSound(ISampleInfo hitSamples)
|
||||||
|
: this(new[] { hitSamples })
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public SkinnableSound(IEnumerable<ISampleInfo> hitSamples)
|
public SkinnableSound(IEnumerable<ISampleInfo> hitSamples)
|
||||||
{
|
{
|
||||||
this.hitSamples = hitSamples.ToArray();
|
this.hitSamples = hitSamples.ToArray();
|
||||||
}
|
InternalChild = samplesContainer = new AudioContainer<DrawableSample>();
|
||||||
|
|
||||||
public SkinnableSound(ISampleInfo hitSamples)
|
|
||||||
{
|
|
||||||
this.hitSamples = new[] { hitSamples };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool looping;
|
private bool looping;
|
||||||
|
|
||||||
|
private readonly AudioContainer<DrawableSample> samplesContainer;
|
||||||
|
|
||||||
|
public BindableNumber<double> Volume => samplesContainer.Volume;
|
||||||
|
|
||||||
|
public BindableNumber<double> Balance => samplesContainer.Balance;
|
||||||
|
|
||||||
|
public BindableNumber<double> Frequency => samplesContainer.Frequency;
|
||||||
|
|
||||||
|
public BindableNumber<double> Tempo => samplesContainer.Tempo;
|
||||||
|
|
||||||
public bool Looping
|
public bool Looping
|
||||||
{
|
{
|
||||||
get => looping;
|
get => looping;
|
||||||
@ -45,33 +52,23 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
looping = value;
|
looping = value;
|
||||||
|
|
||||||
channels?.ForEach(c => c.Looping = looping);
|
samplesContainer.ForEach(c => c.Looping = looping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Play() => channels?.ForEach(c => c.Play());
|
public void Play() => samplesContainer.ForEach(c =>
|
||||||
|
|
||||||
public void Stop() => channels?.ForEach(c => c.Stop());
|
|
||||||
|
|
||||||
public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable)
|
|
||||||
{
|
{
|
||||||
if (adjustments == null) adjustments = new List<(AdjustableProperty, BindableDouble)>();
|
if (c.AggregateVolume.Value > 0)
|
||||||
|
c.Play();
|
||||||
|
});
|
||||||
|
|
||||||
adjustments.Add((type, adjustBindable));
|
public void Stop() => samplesContainer.ForEach(c => c.Stop());
|
||||||
channels?.ForEach(c => c.AddAdjustment(type, adjustBindable));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveAdjustment(AdjustableProperty type, BindableDouble adjustBindable)
|
|
||||||
{
|
|
||||||
adjustments?.Remove((type, adjustBindable));
|
|
||||||
channels?.ForEach(c => c.RemoveAdjustment(type, adjustBindable));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool IsPresent => Scheduler.HasPendingTasks;
|
public override bool IsPresent => Scheduler.HasPendingTasks;
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||||
{
|
{
|
||||||
channels = hitSamples.Select(s =>
|
var channels = hitSamples.Select(s =>
|
||||||
{
|
{
|
||||||
var ch = skin.GetSample(s);
|
var ch = skin.GetSample(s);
|
||||||
|
|
||||||
@ -88,27 +85,12 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
ch.Looping = looping;
|
ch.Looping = looping;
|
||||||
ch.Volume.Value = s.Volume / 100.0;
|
ch.Volume.Value = s.Volume / 100.0;
|
||||||
|
|
||||||
if (adjustments != null)
|
|
||||||
{
|
|
||||||
foreach (var (property, bindable) in adjustments)
|
|
||||||
ch.AddAdjustment(property, bindable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ch;
|
return ch;
|
||||||
}).Where(c => c != null).ToArray();
|
}).Where(c => c != null);
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
samplesContainer.ChildrenEnumerable = channels.Select(c => new DrawableSample(c));
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
|
|
||||||
if (channels != null)
|
|
||||||
{
|
|
||||||
foreach (var c in channels)
|
|
||||||
c.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user