mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 16:32:59 +08:00
Back to using SampleInfo + fix taiko beatmap conversion.
This commit is contained in:
parent
e903241c7b
commit
eb82a4c090
@ -43,7 +43,7 @@ namespace osu.Game.Modes.Osu.Beatmaps
|
|||||||
return new Slider
|
return new Slider
|
||||||
{
|
{
|
||||||
StartTime = original.StartTime,
|
StartTime = original.StartTime,
|
||||||
SampleBanks = original.SampleBanks,
|
Samples = original.Samples,
|
||||||
CurveObject = curveData,
|
CurveObject = curveData,
|
||||||
Position = positionData?.Position ?? Vector2.Zero,
|
Position = positionData?.Position ?? Vector2.Zero,
|
||||||
NewCombo = comboData?.NewCombo ?? false
|
NewCombo = comboData?.NewCombo ?? false
|
||||||
@ -55,7 +55,7 @@ namespace osu.Game.Modes.Osu.Beatmaps
|
|||||||
return new Spinner
|
return new Spinner
|
||||||
{
|
{
|
||||||
StartTime = original.StartTime,
|
StartTime = original.StartTime,
|
||||||
SampleBanks = original.SampleBanks,
|
Samples = original.Samples,
|
||||||
Position = new Vector2(512, 384) / 2,
|
Position = new Vector2(512, 384) / 2,
|
||||||
EndTime = endTimeData.EndTime
|
EndTime = endTimeData.EndTime
|
||||||
};
|
};
|
||||||
@ -64,7 +64,7 @@ namespace osu.Game.Modes.Osu.Beatmaps
|
|||||||
return new HitCircle
|
return new HitCircle
|
||||||
{
|
{
|
||||||
StartTime = original.StartTime,
|
StartTime = original.StartTime,
|
||||||
SampleBanks = original.SampleBanks,
|
Samples = original.Samples,
|
||||||
Position = positionData?.Position ?? Vector2.Zero,
|
Position = positionData?.Position ?? Vector2.Zero,
|
||||||
NewCombo = comboData?.NewCombo ?? false
|
NewCombo = comboData?.NewCombo ?? false
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
ComboIndex = s.ComboIndex,
|
ComboIndex = s.ComboIndex,
|
||||||
Scale = s.Scale,
|
Scale = s.Scale,
|
||||||
ComboColour = s.ComboColour,
|
ComboColour = s.ComboColour,
|
||||||
SampleBanks = s.SampleBanks,
|
Samples = s.Samples,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,17 +2,12 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Audio.Sample;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Beatmaps.Samples;
|
|
||||||
using osu.Game.Modes.Objects.Drawables;
|
using osu.Game.Modes.Objects.Drawables;
|
||||||
using osu.Game.Modes.Osu.Judgements;
|
using osu.Game.Modes.Osu.Judgements;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace osu.Game.Modes.Osu.Objects.Drawables
|
namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -29,8 +24,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
|
|
||||||
protected override OsuJudgement CreateJudgement() => new OsuJudgement { MaxScore = OsuScoreResult.SliderTick };
|
protected override OsuJudgement CreateJudgement() => new OsuJudgement { MaxScore = OsuScoreResult.SliderTick };
|
||||||
|
|
||||||
private List<SampleChannel> samples = new List<SampleChannel>();
|
|
||||||
|
|
||||||
public DrawableSliderTick(SliderTick sliderTick) : base(sliderTick)
|
public DrawableSliderTick(SliderTick sliderTick) : base(sliderTick)
|
||||||
{
|
{
|
||||||
this.sliderTick = sliderTick;
|
this.sliderTick = sliderTick;
|
||||||
@ -56,18 +49,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(AudioManager audio)
|
|
||||||
{
|
|
||||||
foreach (var bank in HitObject.SampleBanks)
|
|
||||||
samples.Add(audio.Sample.Get($@"Gameplay/{bank.Name}-slidertick"));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void PlaySamples()
|
|
||||||
{
|
|
||||||
samples.ForEach(s => s?.Play());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CheckJudgement(bool userTriggered)
|
protected override void CheckJudgement(bool userTriggered)
|
||||||
{
|
{
|
||||||
if (Judgement.TimeOffset >= 0)
|
if (Judgement.TimeOffset >= 0)
|
||||||
|
@ -2,13 +2,14 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Game.Beatmaps.Samples;
|
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Modes.Objects.Types;
|
using osu.Game.Modes.Objects.Types;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Osu.Objects
|
namespace osu.Game.Modes.Osu.Objects
|
||||||
{
|
{
|
||||||
@ -95,7 +96,12 @@ namespace osu.Game.Modes.Osu.Objects
|
|||||||
StackHeight = StackHeight,
|
StackHeight = StackHeight,
|
||||||
Scale = Scale,
|
Scale = Scale,
|
||||||
ComboColour = ComboColour,
|
ComboColour = ComboColour,
|
||||||
SampleBanks = SampleBanks
|
Samples = Samples.Select(s => new SampleInfo
|
||||||
|
{
|
||||||
|
Bank = s.Bank,
|
||||||
|
Name = @"slidertick",
|
||||||
|
Volume = s.Volume
|
||||||
|
}).ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Samples;
|
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
using osu.Game.Modes.Objects.Types;
|
using osu.Game.Modes.Objects.Types;
|
||||||
using osu.Game.Modes.Taiko.Objects;
|
using osu.Game.Modes.Taiko.Objects;
|
||||||
@ -10,6 +9,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Taiko.Beatmaps
|
namespace osu.Game.Modes.Taiko.Beatmaps
|
||||||
{
|
{
|
||||||
@ -57,9 +57,9 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
|||||||
var endTimeData = obj as IHasEndTime;
|
var endTimeData = obj as IHasEndTime;
|
||||||
|
|
||||||
// Old osu! used hit sounding to determine various hit type information
|
// Old osu! used hit sounding to determine various hit type information
|
||||||
List<SampleBank> sampleBanks = obj.SampleBanks;
|
List<SampleInfo> samples = obj.Samples;
|
||||||
|
|
||||||
bool strong = sampleBanks.Any(b => b.Samples.Any(s => s.Type == SampleType.Finish));
|
bool strong = samples.Any(s => s.Name == @"hitfinish");
|
||||||
|
|
||||||
if (distanceData != null)
|
if (distanceData != null)
|
||||||
{
|
{
|
||||||
@ -98,7 +98,7 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
|||||||
yield return new CentreHit
|
yield return new CentreHit
|
||||||
{
|
{
|
||||||
StartTime = j,
|
StartTime = j,
|
||||||
SampleBanks = obj.SampleBanks,
|
Samples = obj.Samples,
|
||||||
IsStrong = strong,
|
IsStrong = strong,
|
||||||
VelocityMultiplier = legacy_velocity_multiplier
|
VelocityMultiplier = legacy_velocity_multiplier
|
||||||
};
|
};
|
||||||
@ -109,7 +109,7 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
|||||||
yield return new DrumRoll
|
yield return new DrumRoll
|
||||||
{
|
{
|
||||||
StartTime = obj.StartTime,
|
StartTime = obj.StartTime,
|
||||||
SampleBanks = obj.SampleBanks,
|
Samples = obj.Samples,
|
||||||
IsStrong = strong,
|
IsStrong = strong,
|
||||||
Distance = distance,
|
Distance = distance,
|
||||||
TickRate = beatmap.BeatmapInfo.Difficulty.SliderTickRate == 3 ? 3 : 4,
|
TickRate = beatmap.BeatmapInfo.Difficulty.SliderTickRate == 3 ? 3 : 4,
|
||||||
@ -124,7 +124,7 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
|||||||
yield return new Swell
|
yield return new Swell
|
||||||
{
|
{
|
||||||
StartTime = obj.StartTime,
|
StartTime = obj.StartTime,
|
||||||
SampleBanks = obj.SampleBanks,
|
Samples = obj.Samples,
|
||||||
IsStrong = strong,
|
IsStrong = strong,
|
||||||
EndTime = endTimeData.EndTime,
|
EndTime = endTimeData.EndTime,
|
||||||
RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier),
|
RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier),
|
||||||
@ -133,24 +133,24 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool isCentre = sampleBanks.Any(b => b.Samples.Any(s => s.Type == SampleType.Normal));
|
bool isRim = samples.Any(s => s.Name == @"hitclap" || s.Name == @"hitwhistle");
|
||||||
|
|
||||||
if (isCentre)
|
if (isRim)
|
||||||
{
|
{
|
||||||
yield return new CentreHit
|
yield return new RimHit
|
||||||
{
|
{
|
||||||
StartTime = obj.StartTime,
|
StartTime = obj.StartTime,
|
||||||
SampleBanks = obj.SampleBanks,
|
Samples = obj.Samples,
|
||||||
IsStrong = strong,
|
IsStrong = strong,
|
||||||
VelocityMultiplier = legacy_velocity_multiplier
|
VelocityMultiplier = legacy_velocity_multiplier
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yield return new RimHit
|
yield return new CentreHit
|
||||||
{
|
{
|
||||||
StartTime = obj.StartTime,
|
StartTime = obj.StartTime,
|
||||||
SampleBanks = obj.SampleBanks,
|
Samples = obj.Samples,
|
||||||
IsStrong = strong,
|
IsStrong = strong,
|
||||||
VelocityMultiplier = legacy_velocity_multiplier
|
VelocityMultiplier = legacy_velocity_multiplier
|
||||||
};
|
};
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
// 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
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps.Samples;
|
|
||||||
using osu.Game.Modes.Objects.Types;
|
using osu.Game.Modes.Objects.Types;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Taiko.Objects
|
namespace osu.Game.Modes.Taiko.Objects
|
||||||
{
|
{
|
||||||
@ -95,7 +95,12 @@ namespace osu.Game.Modes.Taiko.Objects
|
|||||||
TickSpacing = tickSpacing,
|
TickSpacing = tickSpacing,
|
||||||
StartTime = t,
|
StartTime = t,
|
||||||
IsStrong = IsStrong,
|
IsStrong = IsStrong,
|
||||||
SampleBanks = SampleBanks
|
Samples = Samples.Select(s => new SampleInfo
|
||||||
|
{
|
||||||
|
Bank = s.Bank,
|
||||||
|
Name = @"slidertick",
|
||||||
|
Volume = s.Volume
|
||||||
|
}).ToList()
|
||||||
});
|
});
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
|
@ -6,7 +6,6 @@ using NUnit.Framework;
|
|||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
using osu.Game.Beatmaps.Samples;
|
|
||||||
using osu.Game.Modes;
|
using osu.Game.Modes;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osu.Game.Modes.Osu;
|
using osu.Game.Modes.Osu;
|
||||||
@ -137,12 +136,12 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.IsNotNull(slider);
|
Assert.IsNotNull(slider);
|
||||||
Assert.AreEqual(new Vector2(192, 168), slider.Position);
|
Assert.AreEqual(new Vector2(192, 168), slider.Position);
|
||||||
Assert.AreEqual(956, slider.StartTime);
|
Assert.AreEqual(956, slider.StartTime);
|
||||||
Assert.IsTrue(slider.SampleBanks.Any(b => b.Name == "none"));
|
Assert.IsTrue(slider.Samples.Any(s => s.Name == @"normal"));
|
||||||
var hit = beatmap.HitObjects[1] as LegacyHit;
|
var hit = beatmap.HitObjects[1] as LegacyHit;
|
||||||
Assert.IsNotNull(hit);
|
Assert.IsNotNull(hit);
|
||||||
Assert.AreEqual(new Vector2(304, 56), hit.Position);
|
Assert.AreEqual(new Vector2(304, 56), hit.Position);
|
||||||
Assert.AreEqual(1285, hit.StartTime);
|
Assert.AreEqual(1285, hit.StartTime);
|
||||||
Assert.IsTrue(hit.SampleBanks.Any(b => b.Name == "clap"));
|
Assert.IsTrue(hit.Samples.Any(s => s.Name == @"clap"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
osu.Game/Audio/BeatmapSampleStore.cs
Normal file
21
osu.Game/Audio/BeatmapSampleStore.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
|
||||||
|
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
|
|
||||||
|
namespace osu.Game.Audio
|
||||||
|
{
|
||||||
|
public class BeatmapSampleStore : NamespacedResourceStore<SampleChannel>
|
||||||
|
{
|
||||||
|
public BeatmapSampleStore(IResourceStore<SampleChannel> store, string ns)
|
||||||
|
: base(store, ns)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public SampleChannel Get(SampleInfo sampleInfo)
|
||||||
|
{
|
||||||
|
return Get($@"{sampleInfo.Bank}-{sampleInfo.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
osu.Game/Audio/SampleInfo.cs
Normal file
23
osu.Game/Audio/SampleInfo.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// 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.Audio
|
||||||
|
{
|
||||||
|
public class SampleInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The bank to load the sample from.
|
||||||
|
/// </summary>
|
||||||
|
public string Bank;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the sample to load.
|
||||||
|
/// </summary>
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sample volume.
|
||||||
|
/// </summary>
|
||||||
|
public int Volume;
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,6 @@ using System.Globalization;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Game.Beatmaps.Events;
|
using osu.Game.Beatmaps.Events;
|
||||||
using osu.Game.Beatmaps.Samples;
|
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Modes;
|
using osu.Game.Modes;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
@ -247,6 +246,10 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
omitFirstBarSignature = (effectFlags & 8) > 0;
|
omitFirstBarSignature = (effectFlags & 8) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string stringSampleSet = sampleSet.ToString().ToLower();
|
||||||
|
if (stringSampleSet == "none")
|
||||||
|
stringSampleSet = "normal";
|
||||||
|
|
||||||
beatmap.TimingInfo.ControlPoints.Add(new ControlPoint
|
beatmap.TimingInfo.ControlPoints.Add(new ControlPoint
|
||||||
{
|
{
|
||||||
Time = time,
|
Time = time,
|
||||||
@ -254,11 +257,8 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
VelocityAdjustment = beatLength < 0 ? -beatLength / 100.0 : 1,
|
VelocityAdjustment = beatLength < 0 ? -beatLength / 100.0 : 1,
|
||||||
TimingChange = timingChange,
|
TimingChange = timingChange,
|
||||||
TimeSignature = timeSignature,
|
TimeSignature = timeSignature,
|
||||||
SampleBank = new SampleBank
|
SampleBank = stringSampleSet,
|
||||||
{
|
SampleVolume = sampleVolume,
|
||||||
Name = sampleSet.ToString().ToLower(),
|
|
||||||
Volume = sampleVolume
|
|
||||||
},
|
|
||||||
KiaiMode = kiaiMode,
|
KiaiMode = kiaiMode,
|
||||||
OmitFirstBarLine = omitFirstBarSignature
|
OmitFirstBarLine = omitFirstBarSignature
|
||||||
});
|
});
|
||||||
|
@ -1,21 +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
|
|
||||||
{
|
|
||||||
/// <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,29 +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
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.Samples
|
|
||||||
{
|
|
||||||
/// <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
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The list of samples that are to be played to be played from this bank.
|
|
||||||
/// </summary>
|
|
||||||
public List<Sample> Samples = new List<Sample>();
|
|
||||||
|
|
||||||
/// <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,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 SampleType
|
|
||||||
{
|
|
||||||
Normal,
|
|
||||||
Whistle,
|
|
||||||
Finish,
|
|
||||||
Clap
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,6 @@
|
|||||||
// 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
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps.Samples;
|
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.Timing
|
namespace osu.Game.Beatmaps.Timing
|
||||||
{
|
{
|
||||||
public class ControlPoint
|
public class ControlPoint
|
||||||
@ -13,7 +11,9 @@ namespace osu.Game.Beatmaps.Timing
|
|||||||
TimingChange = true,
|
TimingChange = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
public SampleBank SampleBank;
|
public string SampleBank;
|
||||||
|
public int SampleVolume;
|
||||||
|
|
||||||
public TimeSignatures TimeSignature;
|
public TimeSignatures TimeSignature;
|
||||||
public double Time;
|
public double Time;
|
||||||
public double BeatLength;
|
public double BeatLength;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// 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
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps.Samples;
|
|
||||||
using osu.Game.Modes;
|
using osu.Game.Modes;
|
||||||
using SQLite.Net.Attributes;
|
using SQLite.Net.Attributes;
|
||||||
using SQLiteNetExtensions.Attributes;
|
using SQLiteNetExtensions.Attributes;
|
||||||
|
@ -7,11 +7,11 @@ using osu.Framework;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Game.Beatmaps.Samples;
|
|
||||||
using osu.Game.Modes.Judgements;
|
using osu.Game.Modes.Judgements;
|
||||||
using Container = osu.Framework.Graphics.Containers.Container;
|
using Container = osu.Framework.Graphics.Containers.Container;
|
||||||
using osu.Game.Modes.Objects.Types;
|
using osu.Game.Modes.Objects.Types;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Objects.Drawables
|
namespace osu.Game.Modes.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -50,6 +50,7 @@ namespace osu.Game.Modes.Objects.Drawables
|
|||||||
public TObject HitObject;
|
public TObject HitObject;
|
||||||
|
|
||||||
private readonly List<SampleChannel> samples = new List<SampleChannel>();
|
private readonly List<SampleChannel> samples = new List<SampleChannel>();
|
||||||
|
private AudioManager audio;
|
||||||
|
|
||||||
protected DrawableHitObject(TObject hitObject)
|
protected DrawableHitObject(TObject hitObject)
|
||||||
{
|
{
|
||||||
@ -59,9 +60,10 @@ namespace osu.Game.Modes.Objects.Drawables
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio)
|
private void load(AudioManager audio)
|
||||||
{
|
{
|
||||||
foreach (var bank in HitObject.SampleBanks)
|
this.audio = audio;
|
||||||
foreach (var sample in bank.Samples)
|
|
||||||
samples.Add(audio.Sample.Get($@"Gameplay/{bank.Name}-hit{sample.Type.ToString().ToLower()}"));
|
foreach (var sample in HitObject.Samples)
|
||||||
|
samples.Add(GetSample(sample));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArmedState state;
|
private ArmedState state;
|
||||||
@ -155,9 +157,21 @@ namespace osu.Game.Modes.Objects.Drawables
|
|||||||
UpdateJudgement(false);
|
UpdateJudgement(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected SampleChannel GetSample(SampleInfo sampleInfo)
|
||||||
|
{
|
||||||
|
SampleChannel ret = audio.Sample.Get($@"Gameplay/{sampleInfo.Bank}-{sampleInfo.Name}");
|
||||||
|
ret.Volume.Value = sampleInfo.Volume;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void PlaySamples()
|
protected virtual void PlaySamples()
|
||||||
{
|
{
|
||||||
samples.ForEach(s => s?.Play());
|
samples.ForEach(s =>
|
||||||
|
{
|
||||||
|
|
||||||
|
s?.Play();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DrawableHitObject<TObject, TJudgement>> nestedHitObjects;
|
private List<DrawableHitObject<TObject, TJudgement>> nestedHitObjects;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// 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
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps.Samples;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -22,9 +22,9 @@ namespace osu.Game.Modes.Objects
|
|||||||
public double StartTime { get; set; }
|
public double StartTime { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The sample banks to be played when this hit object is hit.
|
/// The samples to be played when this hit object is hit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<SampleBank> SampleBanks = new List<SampleBank>();
|
public List<SampleInfo> Samples = new List<SampleInfo>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies default values to this HitObject.
|
/// Applies default values to this HitObject.
|
||||||
@ -33,17 +33,19 @@ namespace osu.Game.Modes.Objects
|
|||||||
/// <param name="timing">The timing settings to use.</param>
|
/// <param name="timing">The timing settings to use.</param>
|
||||||
public virtual void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
public virtual void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
foreach (var bank in SampleBanks)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(bank.Name) && bank.Name != @"none")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// If the bank is not assigned a name, assign it from the relevant timing point
|
|
||||||
ControlPoint overridePoint;
|
ControlPoint overridePoint;
|
||||||
ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint);
|
ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint);
|
||||||
|
|
||||||
bank.Name = (overridePoint ?? timingPoint)?.SampleBank.Name ?? string.Empty;
|
foreach (var sample in Samples)
|
||||||
bank.Volume = (overridePoint ?? timingPoint)?.SampleBank.Volume ?? 0;
|
{
|
||||||
|
if (sample.Volume == 0)
|
||||||
|
sample.Volume = (overridePoint ?? timingPoint)?.SampleVolume ?? 0;
|
||||||
|
|
||||||
|
// If the bank is not assigned a name, assign it from the control point
|
||||||
|
if (!string.IsNullOrEmpty(sample.Bank))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sample.Bank = (overridePoint ?? timingPoint)?.SampleBank ?? string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using osu.Game.Modes.Objects.Legacy;
|
using osu.Game.Modes.Objects.Legacy;
|
||||||
using osu.Game.Beatmaps.Samples;
|
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Objects
|
namespace osu.Game.Modes.Objects
|
||||||
{
|
{
|
||||||
@ -21,8 +21,9 @@ namespace osu.Game.Modes.Objects
|
|||||||
bool combo = type.HasFlag(LegacyHitObjectType.NewCombo);
|
bool combo = type.HasFlag(LegacyHitObjectType.NewCombo);
|
||||||
type &= ~LegacyHitObjectType.NewCombo;
|
type &= ~LegacyHitObjectType.NewCombo;
|
||||||
|
|
||||||
var normalSampleBank = new SampleBank();
|
int sampleVolume = 0;
|
||||||
var addSampleBank = new SampleBank();
|
string normalSampleBank = string.Empty;
|
||||||
|
string addSampleBank = string.Empty;
|
||||||
|
|
||||||
HitObject result;
|
HitObject result;
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ namespace osu.Game.Modes.Objects
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (split.Length > 5)
|
if (split.Length > 5)
|
||||||
readCustomSampleBanks(split[5], ref normalSampleBank, ref addSampleBank);
|
readCustomSampleBanks(split[5], ref normalSampleBank, ref addSampleBank, ref sampleVolume);
|
||||||
}
|
}
|
||||||
else if ((type & LegacyHitObjectType.Slider) > 0)
|
else if ((type & LegacyHitObjectType.Slider) > 0)
|
||||||
{
|
{
|
||||||
@ -93,7 +94,7 @@ namespace osu.Game.Modes.Objects
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (split.Length > 10)
|
if (split.Length > 10)
|
||||||
readCustomSampleBanks(split[10], ref normalSampleBank, ref addSampleBank);
|
readCustomSampleBanks(split[10], ref normalSampleBank, ref addSampleBank, ref sampleVolume);
|
||||||
}
|
}
|
||||||
else if ((type & LegacyHitObjectType.Spinner) > 0)
|
else if ((type & LegacyHitObjectType.Spinner) > 0)
|
||||||
{
|
{
|
||||||
@ -103,11 +104,15 @@ namespace osu.Game.Modes.Objects
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (split.Length > 6)
|
if (split.Length > 6)
|
||||||
readCustomSampleBanks(split[6], ref normalSampleBank, ref addSampleBank);
|
readCustomSampleBanks(split[6], ref normalSampleBank, ref addSampleBank, ref sampleVolume);
|
||||||
}
|
}
|
||||||
else if ((type & LegacyHitObjectType.Hold) > 0)
|
else if ((type & LegacyHitObjectType.Hold) > 0)
|
||||||
{
|
{
|
||||||
// Note: Hold is generated by BMS converts
|
// Note: Hold is generated by BMS converts
|
||||||
|
|
||||||
|
// Todo: Apparently end time is determined by samples??
|
||||||
|
// Shouldn't be needed until mania
|
||||||
|
|
||||||
result = new LegacyHold
|
result = new LegacyHold
|
||||||
{
|
{
|
||||||
Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])),
|
Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])),
|
||||||
@ -121,45 +126,68 @@ namespace osu.Game.Modes.Objects
|
|||||||
|
|
||||||
var soundType = (LegacySoundType)int.Parse(split[4]);
|
var soundType = (LegacySoundType)int.Parse(split[4]);
|
||||||
|
|
||||||
normalSampleBank.Samples.Add(new Sample { Type = SampleType.Normal });
|
result.Samples.Add(new SampleInfo
|
||||||
if ((soundType & LegacySoundType.Finish) > 0)
|
{
|
||||||
addSampleBank.Samples.Add(new Sample { Type = SampleType.Finish });
|
Bank = normalSampleBank,
|
||||||
if ((soundType & LegacySoundType.Whistle) > 0)
|
Name = "hitnormal",
|
||||||
addSampleBank.Samples.Add(new Sample { Type = SampleType.Whistle });
|
Volume = sampleVolume
|
||||||
if ((soundType & LegacySoundType.Clap) > 0)
|
});
|
||||||
addSampleBank.Samples.Add(new Sample { Type = SampleType.Clap });
|
|
||||||
|
|
||||||
result.SampleBanks.Add(normalSampleBank);
|
if ((soundType & LegacySoundType.Finish) > 0)
|
||||||
result.SampleBanks.Add(addSampleBank);
|
{
|
||||||
|
result.Samples.Add(new SampleInfo
|
||||||
|
{
|
||||||
|
Bank = addSampleBank,
|
||||||
|
Name = "hitfinish",
|
||||||
|
Volume = sampleVolume
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((soundType & LegacySoundType.Whistle) > 0)
|
||||||
|
{
|
||||||
|
result.Samples.Add(new SampleInfo
|
||||||
|
{
|
||||||
|
Bank = addSampleBank,
|
||||||
|
Name = "hitwhistle",
|
||||||
|
Volume = sampleVolume
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((soundType & LegacySoundType.Clap) > 0)
|
||||||
|
{
|
||||||
|
result.Samples.Add(new SampleInfo
|
||||||
|
{
|
||||||
|
Bank = addSampleBank,
|
||||||
|
Name = "hitclap",
|
||||||
|
Volume = sampleVolume
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readCustomSampleBanks(string str, ref SampleBank normalSampleBank, ref SampleBank addSampleBank)
|
private void readCustomSampleBanks(string str, ref string normalSampleBank, ref string addSampleBank, ref int sampleVolume)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(str))
|
if (string.IsNullOrEmpty(str))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string[] split = str.Split(':');
|
string[] split = str.Split(':');
|
||||||
|
|
||||||
var sb = (OsuLegacyDecoder.LegacySampleBank)Convert.ToInt32(split[0]);
|
var bank = (OsuLegacyDecoder.LegacySampleBank)Convert.ToInt32(split[0]);
|
||||||
var addsb = (OsuLegacyDecoder.LegacySampleBank)Convert.ToInt32(split[1]);
|
var addbank = (OsuLegacyDecoder.LegacySampleBank)Convert.ToInt32(split[1]);
|
||||||
|
|
||||||
int volume = split.Length > 3 ? int.Parse(split[3]) : 0;
|
|
||||||
|
|
||||||
//string sampleFile = split2.Length > 4 ? split2[4] : string.Empty;
|
//string sampleFile = split2.Length > 4 ? split2[4] : string.Empty;
|
||||||
|
|
||||||
normalSampleBank = new SampleBank
|
string stringBank = bank.ToString().ToLower();
|
||||||
{
|
if (stringBank == @"none")
|
||||||
Name = sb.ToString().ToLower(),
|
stringBank = string.Empty;
|
||||||
Volume = volume
|
string stringAddBank = addbank.ToString().ToLower();
|
||||||
};
|
if (stringAddBank == @"none")
|
||||||
|
stringAddBank = string.Empty;
|
||||||
|
|
||||||
addSampleBank = new SampleBank
|
normalSampleBank = stringBank;
|
||||||
{
|
addSampleBank = stringAddBank;
|
||||||
Name = addsb.ToString().ToLower(),
|
sampleVolume = split.Length > 3 ? int.Parse(split[3]) : 0;
|
||||||
Volume = volume
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
|
@ -71,14 +71,13 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Audio\BeatmapSampleStore.cs" />
|
||||||
|
<Compile Include="Audio\SampleInfo.cs" />
|
||||||
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
||||||
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
|
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
|
||||||
<Compile Include="Beatmaps\IBeatmapCoverter.cs" />
|
<Compile Include="Beatmaps\IBeatmapCoverter.cs" />
|
||||||
<Compile Include="Beatmaps\IBeatmapProcessor.cs" />
|
<Compile Include="Beatmaps\IBeatmapProcessor.cs" />
|
||||||
<Compile Include="Beatmaps\Legacy\LegacyBeatmap.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\TimeSignatures.cs" />
|
||||||
<Compile Include="Beatmaps\Timing\TimingInfo.cs" />
|
<Compile Include="Beatmaps\Timing\TimingInfo.cs" />
|
||||||
<Compile Include="Database\ScoreDatabase.cs" />
|
<Compile Include="Database\ScoreDatabase.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user