1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 02:22:56 +08:00

Apply changes required for AudioMixer

This commit is contained in:
smoogipoo 2021-07-27 03:55:49 +09:00
parent 8837340ac3
commit 5b06a9d120
2 changed files with 9 additions and 4 deletions

View File

@ -7,6 +7,7 @@ using System.IO;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -30,11 +31,11 @@ namespace osu.Game.Audio
private readonly BindableNumber<double> globalTrackVolumeAdjust = new BindableNumber<double>(OsuGameBase.GLOBAL_TRACK_VOLUME_ADJUST);
[BackgroundDependencyLoader]
private void load()
private void load(AudioManager audioManager)
{
// this is a temporary solution to get around muting ourselves.
// todo: update this once we have a BackgroundTrackManager or similar.
trackStore = new PreviewTrackStore(new OnlineStore());
trackStore = new PreviewTrackStore(audioManager.Mixer, new OnlineStore());
audio.AddItem(trackStore);
trackStore.AddAdjustment(AdjustableProperty.Volume, globalTrackVolumeAdjust);
@ -118,10 +119,12 @@ namespace osu.Game.Audio
private class PreviewTrackStore : AudioCollectionManager<AdjustableAudioComponent>, ITrackStore
{
private readonly AudioMixer defaultMixer;
private readonly IResourceStore<byte[]> store;
internal PreviewTrackStore(IResourceStore<byte[]> store)
internal PreviewTrackStore(AudioMixer defaultMixer, IResourceStore<byte[]> store)
{
this.defaultMixer = defaultMixer;
this.store = store;
}
@ -145,7 +148,7 @@ namespace osu.Game.Audio
if (dataStream == null)
return null;
Track track = new TrackBass(dataStream);
Track track = new TrackBass(dataStream, (IBassAudioMixer)defaultMixer);
AddItem(track);
return track;
}

View File

@ -10,6 +10,7 @@ using JetBrains.Annotations;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -290,6 +291,7 @@ namespace osu.Game.Tests.Visual
private bool running;
public TrackVirtualManual(IFrameBasedClock referenceClock)
: base(new NullAudioMixer())
{
this.referenceClock = referenceClock;
Length = double.PositiveInfinity;