1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Merge pull request #11544 from smoogipoo/non-concurrent-sample-playback

This commit is contained in:
Dean Herbert 2021-02-15 23:40:24 +09:00 committed by GitHub
commit 335af04764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
64 changed files with 154 additions and 143 deletions

View File

@ -52,6 +52,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.211.1" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.128.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.215.0" />
</ItemGroup>
</Project>

View File

@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="nunit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
</ItemGroup>

View File

@ -3,7 +3,7 @@
<ItemGroup Label="Package References">
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>

View File

@ -3,7 +3,7 @@
<ItemGroup Label="Package References">
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>

View File

@ -140,11 +140,11 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
return animation == null ? null : new LegacyManiaJudgementPiece(result, animation);
}
public override SampleChannel GetSample(ISampleInfo sampleInfo)
public override Sample GetSample(ISampleInfo sampleInfo)
{
// layered hit sounds never play in mania
if (sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample && legacySample.IsLayered)
return new SampleChannelVirtual();
return new SampleVirtual();
return Source.GetSample(sampleInfo);
}

View File

@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Tests
return null;
}
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public Sample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();

View File

@ -162,7 +162,7 @@ namespace osu.Game.Rulesets.Osu.Tests
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null;
public SampleChannel GetSample(ISampleInfo sampleInfo) => null;
public Sample GetSample(ISampleInfo sampleInfo) => null;
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => default;
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => null;

View File

@ -3,7 +3,7 @@
<ItemGroup Label="Package References">
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>

View File

@ -130,7 +130,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
if (tracking.NewValue)
{
spinningSample?.Play(!spinningSample.IsPlaying);
if (!spinningSample.IsPlaying)
spinningSample?.Play();
spinningSample?.VolumeTo(1, 300);
}
else

View File

@ -3,7 +3,7 @@
<ItemGroup Label="Package References">
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>

View File

@ -152,7 +152,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
throw new ArgumentOutOfRangeException(nameof(component), $"Invalid component type: {component}");
}
public override SampleChannel GetSample(ISampleInfo sampleInfo) => Source.GetSample(new LegacyTaikoSampleInfo(sampleInfo));
public override Sample GetSample(ISampleInfo sampleInfo) => Source.GetSample(new LegacyTaikoSampleInfo(sampleInfo));
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Source.GetConfig<TLookup, TValue>(lookup);

View File

@ -121,7 +121,7 @@ namespace osu.Game.Tests.Gameplay
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException();
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public Sample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
{

View File

@ -35,7 +35,7 @@ namespace osu.Game.Tests.Gameplay
public void TestRetrieveTopLevelSample()
{
ISkin skin = null;
SampleChannel channel = null;
Sample channel = null;
AddStep("create skin", () => skin = new TestSkin("test-sample", this));
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("test-sample")));
@ -47,7 +47,7 @@ namespace osu.Game.Tests.Gameplay
public void TestRetrieveSampleInSubFolder()
{
ISkin skin = null;
SampleChannel channel = null;
Sample channel = null;
AddStep("create skin", () => skin = new TestSkin("folder/test-sample", this));
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("folder/test-sample")));

View File

@ -59,7 +59,7 @@ namespace osu.Game.Tests.NonVisual.Skinning
}
public Drawable GetDrawableComponent(ISkinComponent component) => throw new NotSupportedException();
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotSupportedException();
public Sample GetSample(ISampleInfo sampleInfo) => throw new NotSupportedException();
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotSupportedException();
}

View File

@ -105,9 +105,9 @@ namespace osu.Game.Tests.Rulesets
IsDisposed = true;
}
public SampleChannel Get(string name) => null;
public Sample Get(string name) => null;
public Task<SampleChannel> GetAsync(string name) => null;
public Task<Sample> GetAsync(string name) => null;
public Stream GetStream(string name) => null;

View File

@ -219,7 +219,7 @@ namespace osu.Game.Tests.Skins
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => skin.GetTexture(componentName, wrapModeS, wrapModeT);
public SampleChannel GetSample(ISampleInfo sampleInfo) => skin.GetSample(sampleInfo);
public Sample GetSample(ISampleInfo sampleInfo) => skin.GetSample(sampleInfo);
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => skin.GetConfig<TLookup, TValue>(lookup);
}

View File

@ -3,11 +3,11 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics.Audio;
using osu.Framework.Testing;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning;
namespace osu.Game.Tests.Visual.Editing
{
@ -19,14 +19,14 @@ namespace osu.Game.Tests.Visual.Editing
public void TestSlidingSampleStopsOnSeek()
{
DrawableSlider slider = null;
DrawableSample[] loopingSamples = null;
DrawableSample[] onceOffSamples = null;
PoolableSkinnableSample[] loopingSamples = null;
PoolableSkinnableSample[] onceOffSamples = null;
AddStep("get first slider", () =>
{
slider = Editor.ChildrenOfType<DrawableSlider>().OrderBy(s => s.HitObject.StartTime).First();
onceOffSamples = slider.ChildrenOfType<DrawableSample>().Where(s => !s.Looping).ToArray();
loopingSamples = slider.ChildrenOfType<DrawableSample>().Where(s => s.Looping).ToArray();
onceOffSamples = slider.ChildrenOfType<PoolableSkinnableSample>().Where(s => !s.Looping).ToArray();
loopingSamples = slider.ChildrenOfType<PoolableSkinnableSample>().Where(s => s.Looping).ToArray();
});
AddStep("start playback", () => EditorClock.Start());

View File

@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics.Audio;
using osu.Framework.Testing;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
@ -20,14 +19,14 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestAllSamplesStopDuringSeek()
{
DrawableSlider slider = null;
DrawableSample[] samples = null;
PoolableSkinnableSample[] samples = null;
ISamplePlaybackDisabler sampleDisabler = null;
AddUntilStep("get variables", () =>
{
sampleDisabler = Player;
slider = Player.ChildrenOfType<DrawableSlider>().OrderBy(s => s.HitObject.StartTime).FirstOrDefault();
samples = slider?.ChildrenOfType<DrawableSample>().ToArray();
samples = slider?.ChildrenOfType<PoolableSkinnableSample>().ToArray();
return slider != null;
});

View File

@ -298,7 +298,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException();
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public Sample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();
}
@ -309,7 +309,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException();
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public Sample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();
}
@ -321,7 +321,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException();
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public Sample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();

View File

@ -43,70 +43,60 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestStoppedSoundDoesntResumeAfterPause()
{
DrawableSample sample = null;
AddStep("start sample with looping", () =>
{
sample = skinnableSound.ChildrenOfType<DrawableSample>().First();
skinnableSound.Looping = true;
skinnableSound.Play();
});
AddUntilStep("wait for sample to start playing", () => sample.Playing);
AddUntilStep("wait for sample to start playing", () => skinnableSound.IsPlaying);
AddStep("stop sample", () => skinnableSound.Stop());
AddUntilStep("wait for sample to stop playing", () => !sample.Playing);
AddUntilStep("wait for sample to stop playing", () => !skinnableSound.IsPlaying);
AddStep("disable sample playback", () => skinSource.SamplePlaybackDisabled.Value = true);
AddStep("enable sample playback", () => skinSource.SamplePlaybackDisabled.Value = false);
AddWaitStep("wait a bit", 5);
AddAssert("sample not playing", () => !sample.Playing);
AddAssert("sample not playing", () => !skinnableSound.IsPlaying);
}
[Test]
public void TestLoopingSoundResumesAfterPause()
{
DrawableSample sample = null;
AddStep("start sample with looping", () =>
{
skinnableSound.Looping = true;
skinnableSound.Play();
sample = skinnableSound.ChildrenOfType<DrawableSample>().First();
});
AddUntilStep("wait for sample to start playing", () => sample.Playing);
AddUntilStep("wait for sample to start playing", () => skinnableSound.IsPlaying);
AddStep("disable sample playback", () => skinSource.SamplePlaybackDisabled.Value = true);
AddUntilStep("wait for sample to stop playing", () => !sample.Playing);
AddUntilStep("wait for sample to stop playing", () => !skinnableSound.IsPlaying);
AddStep("enable sample playback", () => skinSource.SamplePlaybackDisabled.Value = false);
AddUntilStep("wait for sample to start playing", () => sample.Playing);
AddUntilStep("wait for sample to start playing", () => skinnableSound.IsPlaying);
}
[Test]
public void TestNonLoopingStopsWithPause()
{
DrawableSample sample = null;
AddStep("start sample", () =>
{
skinnableSound.Play();
sample = skinnableSound.ChildrenOfType<DrawableSample>().First();
});
AddStep("start sample", () => skinnableSound.Play());
AddAssert("sample playing", () => sample.Playing);
AddAssert("sample playing", () => skinnableSound.IsPlaying);
AddStep("disable sample playback", () => skinSource.SamplePlaybackDisabled.Value = true);
AddUntilStep("sample not playing", () => !sample.Playing);
AddUntilStep("sample not playing", () => !skinnableSound.IsPlaying);
AddStep("enable sample playback", () => skinSource.SamplePlaybackDisabled.Value = false);
AddAssert("sample not playing", () => !sample.Playing);
AddAssert("sample not playing", () => !sample.Playing);
AddAssert("sample not playing", () => !sample.Playing);
AddAssert("sample not playing", () => !skinnableSound.IsPlaying);
AddAssert("sample not playing", () => !skinnableSound.IsPlaying);
AddAssert("sample not playing", () => !skinnableSound.IsPlaying);
}
[Test]
@ -119,10 +109,10 @@ namespace osu.Game.Tests.Visual.Gameplay
sample = skinnableSound.ChildrenOfType<DrawableSample>().Single();
});
AddAssert("sample playing", () => sample.Playing);
AddAssert("sample playing", () => skinnableSound.IsPlaying);
AddStep("disable sample playback", () => skinSource.SamplePlaybackDisabled.Value = true);
AddUntilStep("wait for sample to stop playing", () => !sample.Playing);
AddUntilStep("wait for sample to stop playing", () => !skinnableSound.IsPlaying);
AddStep("trigger skin change", () => skinSource.TriggerSourceChanged());
@ -133,11 +123,11 @@ namespace osu.Game.Tests.Visual.Gameplay
return sample != oldSample;
});
AddAssert("new sample stopped", () => !sample.Playing);
AddAssert("new sample stopped", () => !skinnableSound.IsPlaying);
AddStep("enable sample playback", () => skinSource.SamplePlaybackDisabled.Value = false);
AddWaitStep("wait a bit", 5);
AddAssert("new sample not played", () => !sample.Playing);
AddAssert("new sample not played", () => !skinnableSound.IsPlaying);
}
[Cached(typeof(ISkinSource))]
@ -155,7 +145,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public Drawable GetDrawableComponent(ISkinComponent component) => source?.GetDrawableComponent(component);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => source?.GetTexture(componentName, wrapModeS, wrapModeT);
public SampleChannel GetSample(ISampleInfo sampleInfo) => source?.GetSample(sampleInfo);
public Sample GetSample(ISampleInfo sampleInfo) => source?.GetSample(sampleInfo);
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => source?.GetConfig<TLookup, TValue>(lookup);
public void TriggerSourceChanged()

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="DeepEqual" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
<PackageReference Include="Moq" Version="4.16.0" />

View File

@ -6,7 +6,7 @@
<ItemGroup Label="Package References">
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
</ItemGroup>
<PropertyGroup Label="Project">

View File

@ -18,8 +18,8 @@ namespace osu.Game.Graphics.Containers
[Cached(typeof(IPreviewTrackOwner))]
public abstract class OsuFocusedOverlayContainer : FocusedOverlayContainer, IPreviewTrackOwner, IKeyBindingHandler<GlobalAction>
{
private SampleChannel samplePopIn;
private SampleChannel samplePopOut;
private Sample samplePopIn;
private Sample samplePopOut;
protected virtual string PopInSampleName => "UI/overlay-pop-in";
protected virtual string PopOutSampleName => "UI/overlay-pop-out";

View File

@ -44,7 +44,7 @@ namespace osu.Game.Graphics
[Resolved]
private NotificationOverlay notificationOverlay { get; set; }
private SampleChannel shutter;
private Sample shutter;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, Storage storage, AudioManager audio)

View File

@ -22,8 +22,8 @@ namespace osu.Game.Graphics.UserInterface
private const int text_size = 17;
private const int transition_length = 80;
private SampleChannel sampleClick;
private SampleChannel sampleHover;
private Sample sampleClick;
private Sample sampleHover;
private TextContainer text;

View File

@ -17,7 +17,7 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public class HoverClickSounds : HoverSounds
{
private SampleChannel sampleClick;
private Sample sampleClick;
private readonly MouseButton[] buttons;
/// <summary>

View File

@ -18,7 +18,7 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public class HoverSounds : HoverSampleDebounceComponent
{
private SampleChannel sampleHover;
private Sample sampleHover;
protected readonly HoverSampleSet SampleSet;

View File

@ -46,8 +46,8 @@ namespace osu.Game.Graphics.UserInterface
protected readonly Nub Nub;
private readonly OsuTextFlowContainer labelText;
private SampleChannel sampleChecked;
private SampleChannel sampleUnchecked;
private Sample sampleChecked;
private Sample sampleUnchecked;
public OsuCheckbox(bool nubOnRight = true)
{

View File

@ -25,7 +25,7 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
private const int max_decimal_digits = 5;
private SampleChannel sample;
private Sample sample;
private double lastSampleTime;
private T lastSampleValue;
@ -155,16 +155,15 @@ namespace osu.Game.Graphics.UserInterface
return;
lastSampleValue = value;
lastSampleTime = Clock.CurrentTime;
sample.Frequency.Value = 1 + NormalizedValue * 0.2f;
var channel = sample.Play();
channel.Frequency.Value = 1 + NormalizedValue * 0.2f;
if (NormalizedValue == 0)
sample.Frequency.Value -= 0.4f;
channel.Frequency.Value -= 0.4f;
else if (NormalizedValue == 1)
sample.Frequency.Value += 0.4f;
sample.Play();
channel.Frequency.Value += 0.4f;
}
private void updateTooltipText(T value)

View File

@ -23,11 +23,11 @@ namespace osu.Game.Graphics.UserInterface
{
public class OsuTextBox : BasicTextBox
{
private readonly SampleChannel[] textAddedSamples = new SampleChannel[4];
private SampleChannel capsTextAddedSample;
private SampleChannel textRemovedSample;
private SampleChannel textCommittedSample;
private SampleChannel caretMovedSample;
private readonly Sample[] textAddedSamples = new Sample[4];
private Sample capsTextAddedSample;
private Sample textRemovedSample;
private Sample textCommittedSample;
private Sample caretMovedSample;
/// <summary>
/// Whether to allow playing a different samples based on the type of character.

View File

@ -23,7 +23,7 @@ namespace osu.Game.Overlays
{
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
private SampleChannel sampleBack;
private Sample sampleBack;
private List<APIChangelogBuild> builds;

View File

@ -39,7 +39,7 @@ namespace osu.Game.Overlays
private readonly Sprite innerSpin, outerSpin;
private DrawableMedal drawableMedal;
private SampleChannel getSample;
private Sample getSample;
private readonly Container content;

View File

@ -87,7 +87,7 @@ namespace osu.Game.Overlays.Mods
private const float content_width = 0.8f;
private const float footer_button_spacing = 20;
private SampleChannel sampleOn, sampleOff;
private Sample sampleOn, sampleOff;
protected ModSelectOverlay()
{

View File

@ -42,8 +42,8 @@ namespace osu.Game.Overlays.Notifications
/// </summary>
public virtual bool DisplayOnTop => true;
private SampleChannel samplePopIn;
private SampleChannel samplePopOut;
private Sample samplePopIn;
private Sample samplePopOut;
protected virtual string PopInSampleName => "UI/notification-pop-in";
protected virtual string PopOutSampleName => "UI/overlay-pop-out"; // TODO: replace with a unique sample?

View File

@ -24,9 +24,9 @@ namespace osu.Game.Overlays.OSD
private readonly int optionCount;
private readonly int selectedOption = -1;
private SampleChannel sampleOn;
private SampleChannel sampleOff;
private SampleChannel sampleChange;
private Sample sampleOn;
private Sample sampleOff;
private Sample sampleChange;
public TrackedSettingToast(SettingDescription description)
: base(description.Name, description.Value, description.Shortcut)

View File

@ -102,9 +102,9 @@ namespace osu.Game.Rulesets.UI
this.fallback = fallback;
}
public SampleChannel Get(string name) => primary.Get(name) ?? fallback.Get(name);
public Sample Get(string name) => primary.Get(name) ?? fallback.Get(name);
public Task<SampleChannel> GetAsync(string name) => primary.GetAsync(name) ?? fallback.GetAsync(name);
public Task<Sample> GetAsync(string name) => primary.GetAsync(name) ?? fallback.GetAsync(name);
public Stream GetStream(string name) => primary.GetStream(name) ?? fallback.GetStream(name);

View File

@ -45,8 +45,8 @@ namespace osu.Game.Screens.Menu
public ButtonSystemState VisibleState = ButtonSystemState.TopLevel;
private readonly Action clickAction;
private SampleChannel sampleClick;
private SampleChannel sampleHover;
private Sample sampleClick;
private Sample sampleHover;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);

View File

@ -81,7 +81,7 @@ namespace osu.Game.Screens.Menu
private readonly List<Button> buttonsTopLevel = new List<Button>();
private readonly List<Button> buttonsPlay = new List<Button>();
private SampleChannel sampleBack;
private Sample sampleBack;
private readonly LogoTrackingContainer logoTrackingContainer;

View File

@ -18,7 +18,7 @@ namespace osu.Game.Screens.Menu
private const double delay_step_one = 2300;
private const double delay_step_two = 600;
private SampleChannel welcome;
private Sample welcome;
[BackgroundDependencyLoader]
private void load(AudioManager audio)

View File

@ -48,7 +48,7 @@ namespace osu.Game.Screens.Menu
private const int exit_delay = 3000;
private SampleChannel seeya;
private Sample seeya;
protected virtual string SeeyaSampleName => "Intro/seeya";

View File

@ -39,7 +39,7 @@ namespace osu.Game.Screens.Menu
private BackgroundScreenDefault background;
private SampleChannel welcome;
private Sample welcome;
[BackgroundDependencyLoader]
private void load()

View File

@ -21,8 +21,8 @@ namespace osu.Game.Screens.Menu
protected override string BeatmapHash => "64e00d7022195959bfa3109d09c2e2276c8f12f486b91fcf6175583e973b48f2";
protected override string BeatmapFile => "welcome.osz";
private const double delay_step_two = 2142;
private SampleChannel welcome;
private SampleChannel pianoReverb;
private Sample welcome;
private Sample pianoReverb;
protected override string SeeyaSampleName => "Intro/Welcome/seeya";
protected override BackgroundScreen CreateBackground() => background = new BackgroundScreenDefault(false)
@ -56,12 +56,13 @@ namespace osu.Game.Screens.Menu
{
PrepareMenuLoad();
intro.LogoVisualisation.AddAmplitudeSource(pianoReverb);
AddInternal(intro);
welcome?.Play();
pianoReverb?.Play();
var reverbChannel = pianoReverb?.Play();
if (reverbChannel != null)
intro.LogoVisualisation.AddAmplitudeSource(reverbChannel);
Scheduler.AddDelayed(() =>
{

View File

@ -43,9 +43,9 @@ namespace osu.Game.Screens.Menu
private readonly IntroSequence intro;
private SampleChannel sampleClick;
private SampleChannel sampleBeat;
private SampleChannel sampleDownbeat;
private Sample sampleClick;
private Sample sampleBeat;
private Sample sampleDownbeat;
private readonly Container colourAndTriangles;
private readonly Triangles triangles;

View File

@ -25,7 +25,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
public override bool DisallowExternalBeatmapRulesetChanges => true;
private SampleChannel sampleStart;
private Sample sampleStart;
[Resolved(typeof(Room), nameof(Room.Playlist))]
protected BindableList<PlaylistItem> Playlist { get; private set; }

View File

@ -36,7 +36,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
private IBindable<bool> operationInProgress;
private SampleChannel sampleReadyCount;
private Sample sampleReadyCount;
private readonly ButtonWithTrianglesExposed button;
@ -117,8 +117,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
if (sampleReadyCount == null)
return;
sampleReadyCount.Frequency.Value = 0.77f + countReady * 0.06f;
sampleReadyCount.Play();
var channel = sampleReadyCount.GetChannel();
channel.Frequency.Value = 0.77f + countReady * 0.06f;
channel.Play();
}
private void updateButtonColour(bool green)

View File

@ -75,7 +75,7 @@ namespace osu.Game.Screens
/// </summary>
public virtual bool DisallowExternalBeatmapRulesetChanges => false;
private SampleChannel sampleExit;
private Sample sampleExit;
protected virtual bool PlayResumeSound => true;

View File

@ -34,7 +34,7 @@ namespace osu.Game.Screens.Play
private const float duration = 2500;
private SampleChannel failSample;
private Sample failSample;
public FailAnimation(DrawableRuleset drawableRuleset)
{

View File

@ -93,7 +93,7 @@ namespace osu.Game.Screens.Play
[Resolved]
private MusicController musicController { get; set; }
private SampleChannel sampleRestart;
private Sample sampleRestart;
public BreakOverlay BreakOverlay;

View File

@ -230,7 +230,7 @@ namespace osu.Game.Screens.Play
private Box background;
private AspectContainer aspect;
private SampleChannel sampleConfirm;
private Sample sampleConfirm;
public Button()
{

View File

@ -84,7 +84,7 @@ namespace osu.Game.Screens.Select.Carousel
public class HoverLayer : HoverSampleDebounceComponent
{
private SampleChannel sampleHover;
private Sample sampleHover;
private Box box;

View File

@ -86,10 +86,10 @@ namespace osu.Game.Screens.Select
protected ModSelectOverlay ModSelect { get; private set; }
protected SampleChannel SampleConfirm { get; private set; }
protected Sample SampleConfirm { get; private set; }
private SampleChannel sampleChangeDifficulty;
private SampleChannel sampleChangeBeatmap;
private Sample sampleChangeDifficulty;
private Sample sampleChangeBeatmap;
private Container carouselContainer;

View File

@ -24,7 +24,7 @@ namespace osu.Game.Skinning
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null;
public override SampleChannel GetSample(ISampleInfo sampleInfo) => null;
public override Sample GetSample(ISampleInfo sampleInfo) => null;
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
{

View File

@ -48,7 +48,7 @@ namespace osu.Game.Skinning
/// <param name="sampleInfo">The requested sample.</param>
/// <returns>A matching sample channel, or null if unavailable.</returns>
[CanBeNull]
SampleChannel GetSample(ISampleInfo sampleInfo);
Sample GetSample(ISampleInfo sampleInfo);
/// <summary>
/// Retrieve a configuration value.

View File

@ -39,7 +39,7 @@ namespace osu.Game.Skinning
return base.GetConfig<TLookup, TValue>(lookup);
}
public override SampleChannel GetSample(ISampleInfo sampleInfo)
public override Sample GetSample(ISampleInfo sampleInfo)
{
if (sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacy && legacy.CustomSampleBank == 0)
{

View File

@ -29,7 +29,7 @@ namespace osu.Game.Skinning
protected TextureStore Textures;
[CanBeNull]
protected IResourceStore<SampleChannel> Samples;
protected ISampleStore Samples;
/// <summary>
/// Whether texture for the keys exists.
@ -452,7 +452,7 @@ namespace osu.Game.Skinning
return null;
}
public override SampleChannel GetSample(ISampleInfo sampleInfo)
public override Sample GetSample(ISampleInfo sampleInfo)
{
IEnumerable<string> lookupNames;

View File

@ -34,14 +34,14 @@ namespace osu.Game.Skinning
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
=> Source.GetTexture(componentName, wrapModeS, wrapModeT);
public virtual SampleChannel GetSample(ISampleInfo sampleInfo)
public virtual Sample GetSample(ISampleInfo sampleInfo)
{
if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample))
return Source.GetSample(sampleInfo);
var playLayeredHitSounds = GetConfig<LegacySetting, bool>(LegacySetting.LayeredHitSounds);
if (legacySample.IsLayered && playLayeredHitSounds?.Value == false)
return new SampleChannelVirtual();
return new SampleVirtual();
return Source.GetSample(sampleInfo);
}

View File

@ -69,7 +69,7 @@ namespace osu.Game.Skinning
}
}
public override void Play(bool restart = true)
public override void Play()
{
cancelPendingStart();
RequestedPlaying = true;
@ -77,7 +77,7 @@ namespace osu.Game.Skinning
if (samplePlaybackDisabled.Value)
return;
base.Play(restart);
base.Play();
}
public override void Stop()

View File

@ -27,6 +27,7 @@ namespace osu.Game.Skinning
private readonly AudioContainer<DrawableSample> sampleContainer;
private ISampleInfo sampleInfo;
private SampleChannel activeChannel;
[Resolved]
private ISampleStore sampleStore { get; set; }
@ -99,7 +100,7 @@ namespace osu.Game.Skinning
if (ch == null)
return;
sampleContainer.Add(Sample = new DrawableSample(ch) { Looping = Looping });
sampleContainer.Add(Sample = new DrawableSample(ch));
// Start playback internally for the new sample if the previous one was playing beforehand.
if (wasPlaying && Looping)
@ -109,18 +110,33 @@ namespace osu.Game.Skinning
/// <summary>
/// Plays the sample.
/// </summary>
/// <param name="restart">Whether to play the sample from the beginning.</param>
public void Play(bool restart = true) => Sample?.Play(restart);
public void Play()
{
if (Sample == null)
return;
activeChannel = Sample.GetChannel();
activeChannel.Looping = Looping;
activeChannel.Play();
Played = true;
}
/// <summary>
/// Stops the sample.
/// </summary>
public void Stop() => Sample?.Stop();
public void Stop()
{
activeChannel?.Stop();
activeChannel = null;
}
/// <summary>
/// Whether the sample is currently playing.
/// </summary>
public bool Playing => Sample?.Playing ?? false;
public bool Playing => activeChannel?.Playing ?? false;
public bool Played { get; private set; }
private bool looping;
@ -134,8 +150,8 @@ namespace osu.Game.Skinning
{
looping = value;
if (Sample != null)
Sample.Looping = value;
if (activeChannel != null)
activeChannel.Looping = value;
}
}

View File

@ -19,7 +19,7 @@ namespace osu.Game.Skinning
public abstract Drawable GetDrawableComponent(ISkinComponent componentName);
public abstract SampleChannel GetSample(ISampleInfo sampleInfo);
public abstract Sample GetSample(ISampleInfo sampleInfo);
public Texture GetTexture(string componentName) => GetTexture(componentName, default, default);

View File

@ -171,7 +171,7 @@ namespace osu.Game.Skinning
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => CurrentSkin.Value.GetTexture(componentName, wrapModeS, wrapModeT);
public SampleChannel GetSample(ISampleInfo sampleInfo) => CurrentSkin.Value.GetSample(sampleInfo);
public Sample GetSample(ISampleInfo sampleInfo) => CurrentSkin.Value.GetSample(sampleInfo);
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => CurrentSkin.Value.GetConfig<TLookup, TValue>(lookup);

View File

@ -59,9 +59,9 @@ namespace osu.Game.Skinning
return fallbackSource?.GetTexture(componentName, wrapModeS, wrapModeT);
}
public SampleChannel GetSample(ISampleInfo sampleInfo)
public Sample GetSample(ISampleInfo sampleInfo)
{
SampleChannel sourceChannel;
Sample sourceChannel;
if (AllowSampleLookup(sampleInfo) && (sourceChannel = skin?.GetSample(sampleInfo)) != null)
return sourceChannel;

View File

@ -119,13 +119,15 @@ namespace osu.Game.Skinning
/// <summary>
/// Plays the samples.
/// </summary>
/// <param name="restart">Whether to play the sample from the beginning.</param>
public virtual void Play(bool restart = true)
public virtual void Play()
{
samplesContainer.ForEach(c =>
{
if (PlayWhenZeroVolume || c.AggregateVolume.Value > 0)
c.Play(restart);
{
c.Stop();
c.Play();
}
});
}
@ -188,6 +190,8 @@ namespace osu.Game.Skinning
/// </summary>
public bool IsPlaying => samplesContainer.Any(s => s.Playing);
public bool IsPlayed => samplesContainer.Any(s => s.Played);
#endregion
}
}

View File

@ -29,11 +29,11 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Framework" Version="2021.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.215.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.211.1" />
<PackageReference Include="Sentry" Version="3.0.1" />
<PackageReference Include="SharpCompress" Version="0.27.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
</Project>

View File

@ -70,7 +70,7 @@
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.128.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.215.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.211.1" />
</ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
@ -91,7 +91,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Framework" Version="2021.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.215.0" />
<PackageReference Include="SharpCompress" Version="0.27.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />