mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Fix volume discrepancies
This commit is contained in:
parent
688a04c2ff
commit
0287269b2f
@ -8,26 +8,28 @@ using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Audio;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Audio;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class PoolableSkinnableSample : SkinReloadableDrawable, IAggregateAudioAdjustment, IAdjustableAudioComponent
|
||||
{
|
||||
private readonly AudioContainer<DrawableSample> sampleContainer;
|
||||
|
||||
private ISampleInfo sampleInfo;
|
||||
private DrawableSample sample;
|
||||
|
||||
[Resolved]
|
||||
private ISampleStore sampleStore { get; set; }
|
||||
|
||||
[Cached]
|
||||
private readonly AudioAdjustments adjustments = new AudioAdjustments();
|
||||
|
||||
public PoolableSkinnableSample()
|
||||
{
|
||||
InternalChild = sampleContainer = new AudioContainer<DrawableSample> { RelativeSizeAxes = Axes.Both };
|
||||
}
|
||||
|
||||
public PoolableSkinnableSample(ISampleInfo sampleInfo)
|
||||
: this()
|
||||
{
|
||||
Apply(sampleInfo);
|
||||
}
|
||||
@ -39,6 +41,8 @@ namespace osu.Game.Skinning
|
||||
|
||||
this.sampleInfo = sampleInfo;
|
||||
|
||||
Volume.Value = sampleInfo.Volume / 100.0;
|
||||
|
||||
if (LoadState >= LoadState.Ready)
|
||||
updateSample();
|
||||
}
|
||||
@ -51,7 +55,7 @@ namespace osu.Game.Skinning
|
||||
|
||||
private void updateSample()
|
||||
{
|
||||
ClearInternal();
|
||||
sampleContainer.Clear();
|
||||
|
||||
var ch = CurrentSkin.GetSample(sampleInfo);
|
||||
|
||||
@ -67,11 +71,7 @@ namespace osu.Game.Skinning
|
||||
if (ch == null)
|
||||
return;
|
||||
|
||||
AddInternal(sample = new DrawableSample(ch)
|
||||
{
|
||||
Looping = Looping,
|
||||
Volume = { Value = sampleInfo.Volume / 100.0 }
|
||||
});
|
||||
sampleContainer.Add(sample = new DrawableSample(ch) { Looping = Looping });
|
||||
}
|
||||
|
||||
public void Play(bool restart = true) => sample?.Play(restart);
|
||||
@ -97,37 +97,35 @@ namespace osu.Game.Skinning
|
||||
/// <summary>
|
||||
/// The volume of this component.
|
||||
/// </summary>
|
||||
public BindableNumber<double> Volume => adjustments.Volume;
|
||||
public BindableNumber<double> Volume => sampleContainer.Volume;
|
||||
|
||||
/// <summary>
|
||||
/// The playback balance of this sample (-1 .. 1 where 0 is centered)
|
||||
/// </summary>
|
||||
public BindableNumber<double> Balance => adjustments.Balance;
|
||||
public BindableNumber<double> Balance => sampleContainer.Balance;
|
||||
|
||||
/// <summary>
|
||||
/// Rate at which the component is played back (affects pitch). 1 is 100% playback speed, or default frequency.
|
||||
/// </summary>
|
||||
public BindableNumber<double> Frequency => adjustments.Frequency;
|
||||
public BindableNumber<double> Frequency => sampleContainer.Frequency;
|
||||
|
||||
/// <summary>
|
||||
/// Rate at which the component is played back (does not affect pitch). 1 is 100% playback speed.
|
||||
/// </summary>
|
||||
public BindableNumber<double> Tempo => adjustments.Tempo;
|
||||
public BindableNumber<double> Tempo => sampleContainer.Tempo;
|
||||
|
||||
public void AddAdjustment(AdjustableProperty type, BindableNumber<double> adjustBindable)
|
||||
=> adjustments.AddAdjustment(type, adjustBindable);
|
||||
public void AddAdjustment(AdjustableProperty type, BindableNumber<double> adjustBindable) => sampleContainer.AddAdjustment(type, adjustBindable);
|
||||
|
||||
public void RemoveAdjustment(AdjustableProperty type, BindableNumber<double> adjustBindable)
|
||||
=> adjustments.RemoveAdjustment(type, adjustBindable);
|
||||
public void RemoveAdjustment(AdjustableProperty type, BindableNumber<double> adjustBindable) => sampleContainer.RemoveAdjustment(type, adjustBindable);
|
||||
|
||||
public void RemoveAllAdjustments(AdjustableProperty type) => adjustments.RemoveAllAdjustments(type);
|
||||
public void RemoveAllAdjustments(AdjustableProperty type) => sampleContainer.RemoveAllAdjustments(type);
|
||||
|
||||
public IBindable<double> AggregateVolume => adjustments.AggregateVolume;
|
||||
public IBindable<double> AggregateVolume => sampleContainer.AggregateVolume;
|
||||
|
||||
public IBindable<double> AggregateBalance => adjustments.AggregateBalance;
|
||||
public IBindable<double> AggregateBalance => sampleContainer.AggregateBalance;
|
||||
|
||||
public IBindable<double> AggregateFrequency => adjustments.AggregateFrequency;
|
||||
public IBindable<double> AggregateFrequency => sampleContainer.AggregateFrequency;
|
||||
|
||||
public IBindable<double> AggregateTempo => adjustments.AggregateTempo;
|
||||
public IBindable<double> AggregateTempo => sampleContainer.AggregateTempo;
|
||||
}
|
||||
}
|
||||
|
@ -41,14 +41,13 @@ namespace osu.Game.Skinning
|
||||
|
||||
public SkinnableSound()
|
||||
{
|
||||
InternalChild = SamplesContainer = new AudioContainer<PoolableSkinnableSample>();
|
||||
}
|
||||
|
||||
public SkinnableSound([NotNull] IEnumerable<ISampleInfo> samples)
|
||||
: this()
|
||||
{
|
||||
this.samples = samples.ToArray();
|
||||
|
||||
InternalChild = SamplesContainer = new AudioContainer<PoolableSkinnableSample>();
|
||||
}
|
||||
|
||||
public SkinnableSound([NotNull] ISampleInfo sample)
|
||||
@ -123,6 +122,7 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
var sample = pooledProvider?.GetPooledSample(s) ?? new PoolableSkinnableSample(s);
|
||||
sample.Looping = Looping;
|
||||
sample.Volume.Value = s.Volume / 100.0;
|
||||
|
||||
SamplesContainer.Add(sample);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user