mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Re-implement the SampleBank/Sample structure. No parsing support yet.
This commit is contained in:
parent
1d4a371ded
commit
2d8239a3f7
@ -43,7 +43,7 @@ namespace osu.Game.Modes.Osu.Beatmaps
|
||||
return new Slider
|
||||
{
|
||||
StartTime = original.StartTime,
|
||||
Sample = original.Sample,
|
||||
SampleBank = original.SampleBank,
|
||||
CurveObject = curveData,
|
||||
Position = positionData?.Position ?? Vector2.Zero,
|
||||
NewCombo = comboData?.NewCombo ?? false
|
||||
@ -55,7 +55,7 @@ namespace osu.Game.Modes.Osu.Beatmaps
|
||||
return new Spinner
|
||||
{
|
||||
StartTime = original.StartTime,
|
||||
Sample = original.Sample,
|
||||
SampleBank = original.SampleBank,
|
||||
Position = new Vector2(512, 384) / 2,
|
||||
EndTime = endTimeData.EndTime
|
||||
};
|
||||
@ -64,7 +64,7 @@ namespace osu.Game.Modes.Osu.Beatmaps
|
||||
return new HitCircle
|
||||
{
|
||||
StartTime = original.StartTime,
|
||||
Sample = original.Sample,
|
||||
SampleBank = original.SampleBank,
|
||||
Position = positionData?.Position ?? Vector2.Zero,
|
||||
NewCombo = comboData?.NewCombo ?? false
|
||||
};
|
||||
|
@ -67,7 +67,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
ComboIndex = s.ComboIndex,
|
||||
Scale = s.Scale,
|
||||
ComboColour = s.ComboColour,
|
||||
Sample = s.Sample,
|
||||
SampleBank = s.SampleBank,
|
||||
}),
|
||||
};
|
||||
|
||||
@ -111,7 +111,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
if (repeat > currentRepeat)
|
||||
{
|
||||
if (repeat < slider.RepeatCount && ball.Tracking)
|
||||
PlaySample();
|
||||
PlaySamples();
|
||||
currentRepeat = repeat;
|
||||
}
|
||||
|
||||
|
@ -58,12 +58,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
string sampleSet = (HitObject.Sample?.Set ?? SampleSet.Normal).ToString().ToLower();
|
||||
|
||||
sample = audio.Sample.Get($@"Gameplay/{sampleSet}-slidertick");
|
||||
sample = audio.Sample.Get($@"Gameplay/{HitObject.SampleBank.Name.ToLower()}-slidertick");
|
||||
}
|
||||
|
||||
protected override void PlaySample()
|
||||
protected override void PlaySamples()
|
||||
{
|
||||
sample?.Play();
|
||||
}
|
||||
|
@ -95,11 +95,7 @@ namespace osu.Game.Modes.Osu.Objects
|
||||
StackHeight = StackHeight,
|
||||
Scale = Scale,
|
||||
ComboColour = ComboColour,
|
||||
Sample = new HitSampleInfo
|
||||
{
|
||||
Type = SampleType.None,
|
||||
Set = SampleSet.Soft,
|
||||
},
|
||||
SampleBank = SampleBank
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -57,9 +57,9 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
||||
var endTimeData = obj as IHasEndTime;
|
||||
|
||||
// Old osu! used hit sounding to determine various hit type information
|
||||
SampleType sample = obj.Sample?.Type ?? SampleType.None;
|
||||
SampleBank sampleBank = obj.SampleBank;
|
||||
|
||||
bool strong = (sample & SampleType.Finish) > 0;
|
||||
bool strong = sampleBank.Sets.Any(s => s.Type == SampleType.Finish);
|
||||
|
||||
if (distanceData != null)
|
||||
{
|
||||
@ -98,7 +98,7 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
||||
yield return new CentreHit
|
||||
{
|
||||
StartTime = j,
|
||||
Sample = obj.Sample,
|
||||
SampleBank = obj.SampleBank,
|
||||
IsStrong = strong,
|
||||
VelocityMultiplier = legacy_velocity_multiplier
|
||||
};
|
||||
@ -109,7 +109,7 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
||||
yield return new DrumRoll
|
||||
{
|
||||
StartTime = obj.StartTime,
|
||||
Sample = obj.Sample,
|
||||
SampleBank = obj.SampleBank,
|
||||
IsStrong = strong,
|
||||
Distance = distance,
|
||||
TickRate = beatmap.BeatmapInfo.Difficulty.SliderTickRate == 3 ? 3 : 4,
|
||||
@ -124,7 +124,7 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
||||
yield return new Swell
|
||||
{
|
||||
StartTime = obj.StartTime,
|
||||
Sample = obj.Sample,
|
||||
SampleBank = obj.SampleBank,
|
||||
IsStrong = strong,
|
||||
EndTime = endTimeData.EndTime,
|
||||
RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier),
|
||||
@ -133,14 +133,14 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isCentre = (sample & ~(SampleType.Finish | SampleType.Normal)) == 0;
|
||||
bool isCentre = sampleBank.Sets.Any(s => s.Type == SampleType.Normal);
|
||||
|
||||
if (isCentre)
|
||||
{
|
||||
yield return new CentreHit
|
||||
{
|
||||
StartTime = obj.StartTime,
|
||||
Sample = obj.Sample,
|
||||
SampleBank = obj.SampleBank,
|
||||
IsStrong = strong,
|
||||
VelocityMultiplier = legacy_velocity_multiplier
|
||||
};
|
||||
@ -150,7 +150,7 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
||||
yield return new RimHit
|
||||
{
|
||||
StartTime = obj.StartTime,
|
||||
Sample = obj.Sample,
|
||||
SampleBank = obj.SampleBank,
|
||||
IsStrong = strong,
|
||||
VelocityMultiplier = legacy_velocity_multiplier
|
||||
};
|
||||
|
@ -95,11 +95,7 @@ namespace osu.Game.Modes.Taiko.Objects
|
||||
TickSpacing = tickSpacing,
|
||||
StartTime = t,
|
||||
IsStrong = IsStrong,
|
||||
Sample = new HitSampleInfo
|
||||
{
|
||||
Type = SampleType.None,
|
||||
Set = SampleSet.Soft
|
||||
}
|
||||
SampleBank = SampleBank
|
||||
});
|
||||
|
||||
first = false;
|
||||
|
@ -136,12 +136,12 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.IsNotNull(slider);
|
||||
Assert.AreEqual(new Vector2(192, 168), slider.Position);
|
||||
Assert.AreEqual(956, slider.StartTime);
|
||||
Assert.AreEqual(SampleType.None, slider.Sample.Type);
|
||||
Assert.AreEqual(SampleType.None, slider.SampleBank.Type);
|
||||
var hit = beatmap.HitObjects[1] as LegacyHit;
|
||||
Assert.IsNotNull(hit);
|
||||
Assert.AreEqual(new Vector2(304, 56), hit.Position);
|
||||
Assert.AreEqual(1285, hit.StartTime);
|
||||
Assert.AreEqual(SampleType.Clap, hit.Sample.Type);
|
||||
Assert.AreEqual(SampleType.Clap, hit.SampleBank.Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
// TODO: Not sure how far back to go, or differences between versions
|
||||
}
|
||||
|
||||
private SampleSet defaultSampleSet;
|
||||
private Sample defaultSampleSet;
|
||||
private int defaultSampleVolume = 100;
|
||||
private bool samplesMatchPlaybackRate;
|
||||
|
||||
@ -77,7 +77,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
beatmap.BeatmapInfo.Countdown = int.Parse(val) == 1;
|
||||
break;
|
||||
case @"SampleSet":
|
||||
defaultSampleSet = (SampleSet)Enum.Parse(typeof(SampleSet), val);
|
||||
defaultSampleSet = (Sample)Enum.Parse(typeof(Sample), val);
|
||||
break;
|
||||
case @"SampleVolume":
|
||||
defaultSampleVolume = int.Parse(val);
|
||||
@ -222,9 +222,9 @@ namespace osu.Game.Beatmaps.Formats
|
||||
if (split.Length >= 3)
|
||||
timeSignature = split[2][0] == '0' ? TimeSignatures.SimpleQuadruple : (TimeSignatures)int.Parse(split[2]);
|
||||
|
||||
SampleSet sampleSet = defaultSampleSet;
|
||||
Sample sampleSet = defaultSampleSet;
|
||||
if (split.Length >= 4)
|
||||
sampleSet = (SampleSet)int.Parse(split[3]);
|
||||
sampleSet = (Sample)int.Parse(split[3]);
|
||||
|
||||
SampleBank sampleBank = SampleBank.Default;
|
||||
if (split.Length >= 5)
|
||||
|
@ -1,10 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Beatmaps.Samples
|
||||
{
|
||||
public class HitSampleInfo : SampleInfo
|
||||
{
|
||||
public SampleType Type;
|
||||
}
|
||||
}
|
21
osu.Game/Beatmaps/Samples/Sample.cs
Normal file
21
osu.Game/Beatmaps/Samples/Sample.cs
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Beatmaps.Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="Sample"/> defines a type of sound that is to be played.
|
||||
/// </summary>
|
||||
public class Sample
|
||||
{
|
||||
/// <summary>
|
||||
/// The type of sound to be played.
|
||||
/// </summary>
|
||||
public SampleType Type;
|
||||
|
||||
/// <summary>
|
||||
/// The volume to be played at.
|
||||
/// </summary>
|
||||
public int? Volume;
|
||||
}
|
||||
}
|
@ -1,12 +1,29 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Beatmaps.Samples
|
||||
{
|
||||
public enum SampleBank
|
||||
/// <summary>
|
||||
/// Wraps a list of <see cref="Sample"/> to change which bank of files are used for each <see cref="Sample"/>.
|
||||
/// </summary>
|
||||
public class SampleBank
|
||||
{
|
||||
Default = 0,
|
||||
Custom1 = 1,
|
||||
Custom2 = 2
|
||||
/// <summary>
|
||||
/// The list of samples that are to be played to be played from this bank.
|
||||
/// </summary>
|
||||
public List<Sample> Sets;
|
||||
|
||||
/// <summary>
|
||||
/// In conversion from osu-stable, this is equivalent to SampleSet (_not_ CustomSampleSet).
|
||||
/// i.e. None/Normal/Soft/Drum
|
||||
/// </summary>
|
||||
public string Name;
|
||||
|
||||
/// <summary>
|
||||
/// Default sample volume.
|
||||
/// </summary>
|
||||
public int Volume;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Beatmaps.Samples
|
||||
{
|
||||
public class SampleInfo
|
||||
{
|
||||
public SampleBank Bank;
|
||||
public SampleSet Set;
|
||||
public int Volume;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Beatmaps.Samples
|
||||
{
|
||||
public enum SampleSet
|
||||
{
|
||||
None = 0,
|
||||
Normal = 1,
|
||||
Soft = 2,
|
||||
Drum = 3
|
||||
}
|
||||
}
|
@ -1,17 +1,14 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Beatmaps.Samples
|
||||
{
|
||||
[Flags]
|
||||
public enum SampleType
|
||||
{
|
||||
None = 0,
|
||||
Normal = 1,
|
||||
Whistle = 2,
|
||||
Finish = 4,
|
||||
Clap = 8
|
||||
};
|
||||
}
|
||||
None,
|
||||
Normal,
|
||||
Whistle,
|
||||
Finish,
|
||||
Clap
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Modes.Objects.Drawables
|
||||
{
|
||||
public abstract class DrawableHitObject<TJudgement> : Container, IStateful<ArmedState>
|
||||
public abstract class DrawableHitObject<TJudgement> : Container
|
||||
where TJudgement : Judgement
|
||||
{
|
||||
public override bool HandleInput => Interactive;
|
||||
@ -24,9 +24,44 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
|
||||
public TJudgement Judgement;
|
||||
|
||||
protected abstract TJudgement CreateJudgement();
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
protected abstract void UpdateState(ArmedState state);
|
||||
// We may be setting a custom judgement in test cases or what not
|
||||
if (Judgement == null)
|
||||
Judgement = CreateJudgement();
|
||||
}
|
||||
|
||||
protected abstract TJudgement CreateJudgement();
|
||||
}
|
||||
|
||||
public abstract class DrawableHitObject<TObject, TJudgement> : DrawableHitObject<TJudgement>, IStateful<ArmedState>
|
||||
where TObject : HitObject
|
||||
where TJudgement : Judgement
|
||||
{
|
||||
public event Action<DrawableHitObject<TObject, TJudgement>> OnJudgement;
|
||||
|
||||
/// <summary>
|
||||
/// The colour used for various elements of this DrawableHitObject.
|
||||
/// </summary>
|
||||
public Color4 AccentColour { get; protected set; }
|
||||
|
||||
public TObject HitObject;
|
||||
|
||||
private readonly List<SampleChannel> samples = new List<SampleChannel>();
|
||||
|
||||
protected DrawableHitObject(TObject hitObject)
|
||||
{
|
||||
HitObject = hitObject;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
foreach (var sample in HitObject.SampleBank.Sets)
|
||||
samples.Add(audio.Sample.Get($@"Gameplay/{sample.Type.ToString().ToLower()}-hit{HitObject.SampleBank.Name.ToLower()}"));
|
||||
}
|
||||
|
||||
private ArmedState state;
|
||||
public ArmedState State
|
||||
@ -45,47 +80,17 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
UpdateState(state);
|
||||
|
||||
if (State == ArmedState.Hit)
|
||||
PlaySample();
|
||||
PlaySamples();
|
||||
}
|
||||
}
|
||||
|
||||
protected SampleChannel Sample;
|
||||
|
||||
protected virtual void PlaySample()
|
||||
{
|
||||
Sample?.Play();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
//we may be setting a custom judgement in test cases or what not.
|
||||
if (Judgement == null)
|
||||
Judgement = CreateJudgement();
|
||||
|
||||
//force application of the state that was set before we loaded.
|
||||
// Force application of the state that was set before we loaded
|
||||
UpdateState(State);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class DrawableHitObject<TObject, TJudgement> : DrawableHitObject<TJudgement>
|
||||
where TObject : HitObject
|
||||
where TJudgement : Judgement
|
||||
{
|
||||
public event Action<DrawableHitObject<TObject, TJudgement>> OnJudgement;
|
||||
|
||||
public TObject HitObject;
|
||||
|
||||
/// <summary>
|
||||
/// The colour used for various elements of this DrawableHitObject.
|
||||
/// </summary>
|
||||
public Color4 AccentColour { get; protected set; }
|
||||
|
||||
protected DrawableHitObject(TObject hitObject)
|
||||
{
|
||||
HitObject = hitObject;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process a hit of this hitobject. Carries out judgement.
|
||||
@ -149,16 +154,9 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
UpdateJudgement(false);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
protected virtual void PlaySamples()
|
||||
{
|
||||
SampleType type = HitObject.Sample?.Type ?? SampleType.None;
|
||||
if (type == SampleType.None)
|
||||
type = SampleType.Normal;
|
||||
|
||||
SampleSet sampleSet = HitObject.Sample?.Set ?? SampleSet.Normal;
|
||||
|
||||
Sample = audio.Sample.Get($@"Gameplay/{sampleSet.ToString().ToLower()}-hit{type.ToString().ToLower()}");
|
||||
samples.ForEach(s => s?.Play());
|
||||
}
|
||||
|
||||
private List<DrawableHitObject<TObject, TJudgement>> nestedHitObjects;
|
||||
@ -173,5 +171,7 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
h.OnJudgement += d => OnJudgement?.Invoke(d);
|
||||
nestedHitObjects.Add(h);
|
||||
}
|
||||
|
||||
protected abstract void UpdateState(ArmedState state);
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ namespace osu.Game.Modes.Objects
|
||||
public double StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sample to be played when this HitObject is hit.
|
||||
/// The sample bank to be played when this hit object is hit.
|
||||
/// </summary>
|
||||
public HitSampleInfo Sample { get; set; }
|
||||
public SampleBank SampleBank { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Applies default values to this HitObject.
|
||||
|
@ -105,10 +105,10 @@ namespace osu.Game.Modes.Objects
|
||||
throw new InvalidOperationException($@"Unknown hit object type {type}");
|
||||
|
||||
result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture);
|
||||
result.Sample = new HitSampleInfo
|
||||
result.SampleBank = new HitSampleInfo
|
||||
{
|
||||
Type = (SampleType)int.Parse(split[4]),
|
||||
Set = SampleSet.Soft,
|
||||
Set = Sample.Soft,
|
||||
};
|
||||
|
||||
// TODO: "addition" field
|
||||
|
@ -76,6 +76,9 @@
|
||||
<Compile Include="Beatmaps\IBeatmapCoverter.cs" />
|
||||
<Compile Include="Beatmaps\IBeatmapProcessor.cs" />
|
||||
<Compile Include="Beatmaps\Legacy\LegacyBeatmap.cs" />
|
||||
<Compile Include="Beatmaps\Samples\SampleBank.cs" />
|
||||
<Compile Include="Beatmaps\Samples\Sample.cs" />
|
||||
<Compile Include="Beatmaps\Samples\SampleType.cs" />
|
||||
<Compile Include="Beatmaps\Timing\TimeSignatures.cs" />
|
||||
<Compile Include="Beatmaps\Timing\TimingInfo.cs" />
|
||||
<Compile Include="Database\ScoreDatabase.cs" />
|
||||
@ -148,11 +151,6 @@
|
||||
<Compile Include="Beatmaps\Drawables\Panel.cs" />
|
||||
<Compile Include="Modes\Objects\Drawables\DrawableHitObject.cs" />
|
||||
<Compile Include="Modes\Objects\HitObject.cs" />
|
||||
<Compile Include="Beatmaps\Samples\HitSampleInfo.cs" />
|
||||
<Compile Include="Beatmaps\Samples\SampleBank.cs" />
|
||||
<Compile Include="Beatmaps\Samples\SampleInfo.cs" />
|
||||
<Compile Include="Beatmaps\Samples\SampleSet.cs" />
|
||||
<Compile Include="Beatmaps\Samples\SampleType.cs" />
|
||||
<Compile Include="Beatmaps\Timing\ControlPoint.cs" />
|
||||
<Compile Include="Configuration\OsuConfigManager.cs" />
|
||||
<Compile Include="Overlays\Notifications\IHasCompletionTarget.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user