forked from Mirror/Ryujinx
[Ryujinx.Audio] Address dotnet-format issues (#5362)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA2208 warnings * Address or silence dotnet format CA2211 warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Format if-blocks correctly * Run dotnet format whitespace after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Add comments to disabled warnings * Remove a few unused parameters * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Fix and silence a few dotnet-format warnings again * Address IDE0251 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * Fix naming rule violations, remove redundant code and fix build issues * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Add trailing commas * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Address review feedback --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
parent
0684b00b3c
commit
515fc32b21
207 changed files with 1354 additions and 1670 deletions
|
@ -16,17 +16,17 @@ namespace Ryujinx.Audio
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Events signaled when the driver played audio buffers.
|
/// Events signaled when the driver played audio buffers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ManualResetEvent[] _updateRequiredEvents;
|
private readonly ManualResetEvent[] _updateRequiredEvents;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Action to execute when the driver played audio buffers.
|
/// Action to execute when the driver played audio buffers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Action[] _actions;
|
private readonly Action[] _actions;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The worker thread in charge of handling sessions update.
|
/// The worker thread in charge of handling sessions update.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Thread _workerThread;
|
private readonly Thread _workerThread;
|
||||||
|
|
||||||
private bool _isRunning;
|
private bool _isRunning;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ namespace Ryujinx.Audio
|
||||||
|
|
||||||
_workerThread = new Thread(Update)
|
_workerThread = new Thread(Update)
|
||||||
{
|
{
|
||||||
Name = "AudioManager.Worker"
|
Name = "AudioManager.Worker",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@ namespace Ryujinx.Audio
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,10 +66,7 @@ namespace Ryujinx.Audio.Backends.Common
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer.Data == null)
|
buffer.Data ??= samples;
|
||||||
{
|
|
||||||
buffer.Data = samples;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,13 @@ using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Memory;
|
using Ryujinx.Memory;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
|
using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Backends.CompatLayer
|
namespace Ryujinx.Audio.Backends.CompatLayer
|
||||||
{
|
{
|
||||||
public class CompatLayerHardwareDeviceDriver : IHardwareDeviceDriver
|
public class CompatLayerHardwareDeviceDriver : IHardwareDeviceDriver
|
||||||
{
|
{
|
||||||
private IHardwareDeviceDriver _realDriver;
|
private readonly IHardwareDeviceDriver _realDriver;
|
||||||
|
|
||||||
public static bool IsSupported => true;
|
public static bool IsSupported => true;
|
||||||
|
|
||||||
|
@ -24,6 +23,7 @@ namespace Ryujinx.Audio.Backends.CompatLayer
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
_realDriver.Dispose();
|
_realDriver.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ namespace Ryujinx.Audio.Backends.CompatLayer
|
||||||
6 => SelectHardwareChannelCount(2),
|
6 => SelectHardwareChannelCount(2),
|
||||||
2 => SelectHardwareChannelCount(1),
|
2 => SelectHardwareChannelCount(1),
|
||||||
1 => throw new ArgumentException("No valid channel configuration found!"),
|
1 => throw new ArgumentException("No valid channel configuration found!"),
|
||||||
_ => throw new ArgumentException($"Invalid targetChannelCount {targetChannelCount}")
|
_ => throw new ArgumentException($"Invalid targetChannelCount {targetChannelCount}"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Backends.CompatLayer
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.Audio, "The selected audio backend doesn't support audio input, fallback to dummy...");
|
Logger.Warning?.Print(LogClass.Audio, "The selected audio backend doesn't support audio input, fallback to dummy...");
|
||||||
|
|
||||||
return new DummyHardwareDeviceSessionInput(this, memoryManager, sampleFormat, sampleRate, channelCount);
|
return new DummyHardwareDeviceSessionInput(this, memoryManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
@ -138,12 +138,12 @@ namespace Ryujinx.Audio.Backends.CompatLayer
|
||||||
|
|
||||||
if (direction == Direction.Input)
|
if (direction == Direction.Input)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.Audio, $"The selected audio backend doesn't support the requested audio input configuration, fallback to dummy...");
|
Logger.Warning?.Print(LogClass.Audio, "The selected audio backend doesn't support the requested audio input configuration, fallback to dummy...");
|
||||||
|
|
||||||
// TODO: We currently don't support audio input upsampling/downsampling, implement this.
|
// TODO: We currently don't support audio input upsampling/downsampling, implement this.
|
||||||
realSession.Dispose();
|
realSession.Dispose();
|
||||||
|
|
||||||
return new DummyHardwareDeviceSessionInput(this, memoryManager, sampleFormat, sampleRate, channelCount);
|
return new DummyHardwareDeviceSessionInput(this, memoryManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It must be a HardwareDeviceSessionOutputBase.
|
// It must be a HardwareDeviceSessionOutputBase.
|
||||||
|
|
|
@ -8,9 +8,9 @@ namespace Ryujinx.Audio.Backends.CompatLayer
|
||||||
{
|
{
|
||||||
class CompatLayerHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
class CompatLayerHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||||
{
|
{
|
||||||
private HardwareDeviceSessionOutputBase _realSession;
|
private readonly HardwareDeviceSessionOutputBase _realSession;
|
||||||
private SampleFormat _userSampleFormat;
|
private readonly SampleFormat _userSampleFormat;
|
||||||
private uint _userChannelCount;
|
private readonly uint _userChannelCount;
|
||||||
|
|
||||||
public CompatLayerHardwareDeviceSession(HardwareDeviceSessionOutputBase realSession, SampleFormat userSampleFormat, uint userChannelCount) : base(realSession.MemoryManager, realSession.RequestedSampleFormat, realSession.RequestedSampleRate, userChannelCount)
|
public CompatLayerHardwareDeviceSession(HardwareDeviceSessionOutputBase realSession, SampleFormat userSampleFormat, uint userChannelCount) : base(realSession.MemoryManager, realSession.RequestedSampleFormat, realSession.RequestedSampleRate, userChannelCount)
|
||||||
{
|
{
|
||||||
|
@ -116,11 +116,11 @@ namespace Ryujinx.Audio.Backends.CompatLayer
|
||||||
samples = MemoryMarshal.Cast<short, byte>(samplesPCM16).ToArray();
|
samples = MemoryMarshal.Cast<short, byte>(samplesPCM16).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioBuffer fakeBuffer = new AudioBuffer
|
AudioBuffer fakeBuffer = new()
|
||||||
{
|
{
|
||||||
BufferTag = buffer.BufferTag,
|
BufferTag = buffer.BufferTag,
|
||||||
DataPointer = buffer.DataPointer,
|
DataPointer = buffer.DataPointer,
|
||||||
DataSize = (ulong)samples.Length
|
DataSize = (ulong)samples.Length,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool result = _realSession.RegisterBuffer(fakeBuffer, samples);
|
bool result = _realSession.RegisterBuffer(fakeBuffer, samples);
|
||||||
|
|
|
@ -31,18 +31,18 @@ namespace Ryujinx.Audio.Backends.CompatLayer
|
||||||
private const int Minus6dBInQ15 = (int)(0.501f * RawQ15One);
|
private const int Minus6dBInQ15 = (int)(0.501f * RawQ15One);
|
||||||
private const int Minus12dBInQ15 = (int)(0.251f * RawQ15One);
|
private const int Minus12dBInQ15 = (int)(0.251f * RawQ15One);
|
||||||
|
|
||||||
private static readonly int[] DefaultSurroundToStereoCoefficients = new int[4]
|
private static readonly int[] _defaultSurroundToStereoCoefficients = new int[4]
|
||||||
{
|
{
|
||||||
RawQ15One,
|
RawQ15One,
|
||||||
Minus3dBInQ15,
|
Minus3dBInQ15,
|
||||||
Minus12dBInQ15,
|
Minus12dBInQ15,
|
||||||
Minus3dBInQ15
|
Minus3dBInQ15,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly int[] DefaultStereoToMonoCoefficients = new int[2]
|
private static readonly int[] _defaultStereoToMonoCoefficients = new int[2]
|
||||||
{
|
{
|
||||||
Minus6dBInQ15,
|
Minus6dBInQ15,
|
||||||
Minus6dBInQ15
|
Minus6dBInQ15,
|
||||||
};
|
};
|
||||||
|
|
||||||
private const int SurroundChannelCount = 6;
|
private const int SurroundChannelCount = 6;
|
||||||
|
@ -114,12 +114,12 @@ namespace Ryujinx.Audio.Backends.CompatLayer
|
||||||
|
|
||||||
public static short[] DownMixStereoToMono(ReadOnlySpan<short> data)
|
public static short[] DownMixStereoToMono(ReadOnlySpan<short> data)
|
||||||
{
|
{
|
||||||
return DownMixStereoToMono(DefaultStereoToMonoCoefficients, data);
|
return DownMixStereoToMono(_defaultStereoToMonoCoefficients, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static short[] DownMixSurroundToStereo(ReadOnlySpan<short> data)
|
public static short[] DownMixSurroundToStereo(ReadOnlySpan<short> data)
|
||||||
{
|
{
|
||||||
return DownMixSurroundToStereo(DefaultSurroundToStereoCoefficients, data);
|
return DownMixSurroundToStereo(_defaultSurroundToStereoCoefficients, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
using Ryujinx.Audio.Common;
|
using Ryujinx.Audio.Common;
|
||||||
using Ryujinx.Audio.Integration;
|
using Ryujinx.Audio.Integration;
|
||||||
using Ryujinx.Memory;
|
using Ryujinx.Memory;
|
||||||
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
|
using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Backends.Dummy
|
namespace Ryujinx.Audio.Backends.Dummy
|
||||||
{
|
{
|
||||||
public class DummyHardwareDeviceDriver : IHardwareDeviceDriver
|
public class DummyHardwareDeviceDriver : IHardwareDeviceDriver
|
||||||
{
|
{
|
||||||
private ManualResetEvent _updateRequiredEvent;
|
private readonly ManualResetEvent _updateRequiredEvent;
|
||||||
private ManualResetEvent _pauseEvent;
|
private readonly ManualResetEvent _pauseEvent;
|
||||||
|
|
||||||
public static bool IsSupported => true;
|
public static bool IsSupported => true;
|
||||||
|
|
||||||
|
@ -36,10 +36,8 @@ namespace Ryujinx.Audio.Backends.Dummy
|
||||||
{
|
{
|
||||||
return new DummyHardwareDeviceSessionOutput(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
return new DummyHardwareDeviceSessionOutput(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return new DummyHardwareDeviceSessionInput(this, memoryManager);
|
||||||
return new DummyHardwareDeviceSessionInput(this, memoryManager, sampleFormat, sampleRate, channelCount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetUpdateRequiredEvent()
|
public ManualResetEvent GetUpdateRequiredEvent()
|
||||||
|
@ -54,6 +52,7 @@ namespace Ryujinx.Audio.Backends.Dummy
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ namespace Ryujinx.Audio.Backends.Dummy
|
||||||
class DummyHardwareDeviceSessionInput : IHardwareDeviceSession
|
class DummyHardwareDeviceSessionInput : IHardwareDeviceSession
|
||||||
{
|
{
|
||||||
private float _volume;
|
private float _volume;
|
||||||
private IHardwareDeviceDriver _manager;
|
private readonly IHardwareDeviceDriver _manager;
|
||||||
private IVirtualMemoryManager _memoryManager;
|
private readonly IVirtualMemoryManager _memoryManager;
|
||||||
|
|
||||||
public DummyHardwareDeviceSessionInput(IHardwareDeviceDriver manager, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount)
|
public DummyHardwareDeviceSessionInput(IHardwareDeviceDriver manager, IVirtualMemoryManager memoryManager)
|
||||||
{
|
{
|
||||||
_volume = 1.0f;
|
_volume = 1.0f;
|
||||||
_manager = manager;
|
_manager = manager;
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Ryujinx.Audio.Backends.Dummy
|
||||||
internal class DummyHardwareDeviceSessionOutput : HardwareDeviceSessionOutputBase
|
internal class DummyHardwareDeviceSessionOutput : HardwareDeviceSessionOutputBase
|
||||||
{
|
{
|
||||||
private float _volume;
|
private float _volume;
|
||||||
private IHardwareDeviceDriver _manager;
|
private readonly IHardwareDeviceDriver _manager;
|
||||||
|
|
||||||
private ulong _playedSampleCount;
|
private ulong _playedSampleCount;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Ryujinx.Audio.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Array of all buffers currently used or released.
|
/// Array of all buffers currently used or released.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AudioBuffer[] _buffers;
|
private readonly AudioBuffer[] _buffers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The server index inside <see cref="_buffers"/> (appended but not queued to device driver).
|
/// The server index inside <see cref="_buffers"/> (appended but not queued to device driver).
|
||||||
|
@ -58,17 +58,17 @@ namespace Ryujinx.Audio.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The released buffer event.
|
/// The released buffer event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private IWritableEvent _bufferEvent;
|
private readonly IWritableEvent _bufferEvent;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The session on the device driver.
|
/// The session on the device driver.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private IHardwareDeviceSession _hardwareDeviceSession;
|
private readonly IHardwareDeviceSession _hardwareDeviceSession;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Max number of buffers that can be registered to the device driver at a time.
|
/// Max number of buffers that can be registered to the device driver at a time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private uint _bufferRegisteredLimit;
|
private readonly uint _bufferRegisteredLimit;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="AudioDeviceSession"/>.
|
/// Create a new <see cref="AudioDeviceSession"/>.
|
||||||
|
@ -311,9 +311,9 @@ namespace Ryujinx.Audio.Common
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AppendUacBuffer(AudioBuffer buffer, uint handle)
|
public static bool AppendUacBuffer(AudioBuffer buffer, uint handle)
|
||||||
{
|
{
|
||||||
// NOTE: On hardware, there is another RegisterBuffer method taking an handle.
|
// NOTE: On hardware, there is another RegisterBuffer method taking a handle.
|
||||||
// This variant of the call always return false (stubbed?) as a result this logic will never succeed.
|
// This variant of the call always return false (stubbed?) as a result this logic will never succeed.
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -425,10 +425,8 @@ namespace Ryujinx.Audio.Common
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return _hardwareDeviceSession.GetPlayedSampleCount();
|
||||||
return _hardwareDeviceSession.GetPlayedSampleCount();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -13,6 +13,6 @@ namespace Ryujinx.Audio.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The audio device is stopped.
|
/// The audio device is stopped.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Stopped
|
Stopped,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,6 @@ namespace Ryujinx.Audio.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/unused.
|
/// Reserved/unused.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ushort _reserved;
|
private readonly ushort _reserved;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -38,6 +38,6 @@ namespace Ryujinx.Audio.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ADPCM sample format. (Also known as GC-ADPCM)
|
/// ADPCM sample format. (Also known as GC-ADPCM)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Adpcm = 6
|
Adpcm = 6,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,7 +24,7 @@ namespace Ryujinx.Audio.Input
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The session ids allocation table.
|
/// The session ids allocation table.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int[] _sessionIds;
|
private readonly int[] _sessionIds;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The device driver.
|
/// The device driver.
|
||||||
|
@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Input
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="AudioInputSystem"/> session instances.
|
/// The <see cref="AudioInputSystem"/> session instances.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AudioInputSystem[] _sessions;
|
private readonly AudioInputSystem[] _sessions;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The count of active sessions.
|
/// The count of active sessions.
|
||||||
|
@ -166,6 +166,7 @@ namespace Ryujinx.Audio.Input
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filtered">If true, filter disconnected devices</param>
|
/// <param name="filtered">If true, filter disconnected devices</param>
|
||||||
/// <returns>The list of all audio inputs name</returns>
|
/// <returns>The list of all audio inputs name</returns>
|
||||||
|
#pragma warning disable CA1822 // Mark member as static
|
||||||
public string[] ListAudioIns(bool filtered)
|
public string[] ListAudioIns(bool filtered)
|
||||||
{
|
{
|
||||||
if (filtered)
|
if (filtered)
|
||||||
|
@ -173,8 +174,9 @@ namespace Ryujinx.Audio.Input
|
||||||
// TODO: Detect if the driver supports audio input
|
// TODO: Detect if the driver supports audio input
|
||||||
}
|
}
|
||||||
|
|
||||||
return new string[] { Constants.DefaultDeviceInputName };
|
return new[] { Constants.DefaultDeviceInputName };
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CA1822
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Open a new <see cref="AudioInputSystem"/>.
|
/// Open a new <see cref="AudioInputSystem"/>.
|
||||||
|
@ -205,7 +207,7 @@ namespace Ryujinx.Audio.Input
|
||||||
|
|
||||||
IHardwareDeviceSession deviceSession = _deviceDriver.OpenDeviceSession(IHardwareDeviceDriver.Direction.Input, memoryManager, sampleFormat, parameter.SampleRate, parameter.ChannelCount);
|
IHardwareDeviceSession deviceSession = _deviceDriver.OpenDeviceSession(IHardwareDeviceDriver.Direction.Input, memoryManager, sampleFormat, parameter.SampleRate, parameter.ChannelCount);
|
||||||
|
|
||||||
AudioInputSystem audioIn = new AudioInputSystem(this, _lock, deviceSession, _sessionsBufferEvents[sessionId]);
|
AudioInputSystem audioIn = new(this, _lock, deviceSession, _sessionsBufferEvents[sessionId]);
|
||||||
|
|
||||||
ResultCode result = audioIn.Initialize(inputDeviceName, sampleFormat, ref parameter, sessionId);
|
ResultCode result = audioIn.Initialize(inputDeviceName, sampleFormat, ref parameter, sessionId);
|
||||||
|
|
||||||
|
@ -238,6 +240,8 @@ namespace Ryujinx.Audio.Input
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Input
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The session the <see cref="AudioInputSystem"/>.
|
/// The session the <see cref="AudioInputSystem"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AudioDeviceSession _session;
|
private readonly AudioDeviceSession _session;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The target device name of the <see cref="AudioInputSystem"/>.
|
/// The target device name of the <see cref="AudioInputSystem"/>.
|
||||||
|
@ -43,7 +43,7 @@ namespace Ryujinx.Audio.Input
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="AudioInputManager"/> owning this.
|
/// The <see cref="AudioInputManager"/> owning this.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AudioInputManager _manager;
|
private readonly AudioInputManager _manager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The lock of the parent.
|
/// The lock of the parent.
|
||||||
|
@ -90,11 +90,13 @@ namespace Ryujinx.Audio.Input
|
||||||
{
|
{
|
||||||
return ResultCode.DeviceNotFound;
|
return ResultCode.DeviceNotFound;
|
||||||
}
|
}
|
||||||
else if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
|
|
||||||
|
if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
|
||||||
{
|
{
|
||||||
return ResultCode.UnsupportedSampleRate;
|
return ResultCode.UnsupportedSampleRate;
|
||||||
}
|
}
|
||||||
else if (configuration.ChannelCount != 0 && configuration.ChannelCount != 1 && configuration.ChannelCount != 2 && configuration.ChannelCount != 6)
|
|
||||||
|
if (configuration.ChannelCount != 0 && configuration.ChannelCount != 1 && configuration.ChannelCount != 2 && configuration.ChannelCount != 6)
|
||||||
{
|
{
|
||||||
return ResultCode.UnsupportedChannelConfiguration;
|
return ResultCode.UnsupportedChannelConfiguration;
|
||||||
}
|
}
|
||||||
|
@ -185,11 +187,11 @@ namespace Ryujinx.Audio.Input
|
||||||
{
|
{
|
||||||
lock (_parentLock)
|
lock (_parentLock)
|
||||||
{
|
{
|
||||||
AudioBuffer buffer = new AudioBuffer
|
AudioBuffer buffer = new()
|
||||||
{
|
{
|
||||||
BufferTag = bufferTag,
|
BufferTag = bufferTag,
|
||||||
DataPointer = userBuffer.Data,
|
DataPointer = userBuffer.Data,
|
||||||
DataSize = userBuffer.DataSize
|
DataSize = userBuffer.DataSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_session.AppendBuffer(buffer))
|
if (_session.AppendBuffer(buffer))
|
||||||
|
@ -213,14 +215,14 @@ namespace Ryujinx.Audio.Input
|
||||||
{
|
{
|
||||||
lock (_parentLock)
|
lock (_parentLock)
|
||||||
{
|
{
|
||||||
AudioBuffer buffer = new AudioBuffer
|
AudioBuffer buffer = new()
|
||||||
{
|
{
|
||||||
BufferTag = bufferTag,
|
BufferTag = bufferTag,
|
||||||
DataPointer = userBuffer.Data,
|
DataPointer = userBuffer.Data,
|
||||||
DataSize = userBuffer.DataSize
|
DataSize = userBuffer.DataSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_session.AppendUacBuffer(buffer, handle))
|
if (AudioDeviceSession.AppendUacBuffer(buffer, handle))
|
||||||
{
|
{
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
@ -373,6 +375,8 @@ namespace Ryujinx.Audio.Input
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
|
|
@ -6,12 +6,12 @@ namespace Ryujinx.Audio.Integration
|
||||||
{
|
{
|
||||||
public class HardwareDeviceImpl : IHardwareDevice
|
public class HardwareDeviceImpl : IHardwareDevice
|
||||||
{
|
{
|
||||||
private IHardwareDeviceSession _session;
|
private readonly IHardwareDeviceSession _session;
|
||||||
private uint _channelCount;
|
private readonly uint _channelCount;
|
||||||
private uint _sampleRate;
|
private readonly uint _sampleRate;
|
||||||
private uint _currentBufferTag;
|
private uint _currentBufferTag;
|
||||||
|
|
||||||
private byte[] _buffer;
|
private readonly byte[] _buffer;
|
||||||
|
|
||||||
public HardwareDeviceImpl(IHardwareDeviceDriver deviceDriver, uint channelCount, uint sampleRate, float volume)
|
public HardwareDeviceImpl(IHardwareDeviceDriver deviceDriver, uint channelCount, uint sampleRate, float volume)
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@ namespace Ryujinx.Audio.Integration
|
||||||
DataSize = (ulong)_buffer.Length,
|
DataSize = (ulong)_buffer.Length,
|
||||||
});
|
});
|
||||||
|
|
||||||
_currentBufferTag = _currentBufferTag % 4;
|
_currentBufferTag %= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetVolume(float volume)
|
public void SetVolume(float volume)
|
||||||
|
@ -61,6 +61,7 @@ namespace Ryujinx.Audio.Integration
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.Audio.Integration
|
||||||
public enum Direction
|
public enum Direction
|
||||||
{
|
{
|
||||||
Input,
|
Input,
|
||||||
Output
|
Output,
|
||||||
}
|
}
|
||||||
|
|
||||||
IHardwareDeviceSession OpenDeviceSession(Direction direction, IVirtualMemoryManager memoryManager, SampleFormat sampleFormat, uint sampleRate, uint channelCount, float volume = 1f);
|
IHardwareDeviceSession OpenDeviceSession(Direction direction, IVirtualMemoryManager memoryManager, SampleFormat sampleFormat, uint sampleRate, uint channelCount, float volume = 1f);
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Ryujinx.Audio.Output
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The session ids allocation table.
|
/// The session ids allocation table.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int[] _sessionIds;
|
private readonly int[] _sessionIds;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The device driver.
|
/// The device driver.
|
||||||
|
@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Output
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="AudioOutputSystem"/> session instances.
|
/// The <see cref="AudioOutputSystem"/> session instances.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AudioOutputSystem[] _sessions;
|
private readonly AudioOutputSystem[] _sessions;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The count of active sessions.
|
/// The count of active sessions.
|
||||||
|
@ -165,10 +165,12 @@ namespace Ryujinx.Audio.Output
|
||||||
/// Get the list of all audio outputs name.
|
/// Get the list of all audio outputs name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The list of all audio outputs name</returns>
|
/// <returns>The list of all audio outputs name</returns>
|
||||||
|
#pragma warning disable CA1822 // Mark member as static
|
||||||
public string[] ListAudioOuts()
|
public string[] ListAudioOuts()
|
||||||
{
|
{
|
||||||
return new string[] { Constants.DefaultDeviceOutputName };
|
return new[] { Constants.DefaultDeviceOutputName };
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CA1822
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Open a new <see cref="AudioOutputSystem"/>.
|
/// Open a new <see cref="AudioOutputSystem"/>.
|
||||||
|
@ -182,6 +184,7 @@ namespace Ryujinx.Audio.Output
|
||||||
/// <param name="parameter">The user configuration</param>
|
/// <param name="parameter">The user configuration</param>
|
||||||
/// <param name="appletResourceUserId">The applet resource user id of the application</param>
|
/// <param name="appletResourceUserId">The applet resource user id of the application</param>
|
||||||
/// <param name="processHandle">The process handle of the application</param>
|
/// <param name="processHandle">The process handle of the application</param>
|
||||||
|
/// <param name="volume">The volume level to request</param>
|
||||||
/// <returns>A <see cref="ResultCode"/> reporting an error or a success</returns>
|
/// <returns>A <see cref="ResultCode"/> reporting an error or a success</returns>
|
||||||
public ResultCode OpenAudioOut(out string outputDeviceName,
|
public ResultCode OpenAudioOut(out string outputDeviceName,
|
||||||
out AudioOutputConfiguration outputConfiguration,
|
out AudioOutputConfiguration outputConfiguration,
|
||||||
|
@ -200,7 +203,7 @@ namespace Ryujinx.Audio.Output
|
||||||
|
|
||||||
IHardwareDeviceSession deviceSession = _deviceDriver.OpenDeviceSession(IHardwareDeviceDriver.Direction.Output, memoryManager, sampleFormat, parameter.SampleRate, parameter.ChannelCount, volume);
|
IHardwareDeviceSession deviceSession = _deviceDriver.OpenDeviceSession(IHardwareDeviceDriver.Direction.Output, memoryManager, sampleFormat, parameter.SampleRate, parameter.ChannelCount, volume);
|
||||||
|
|
||||||
AudioOutputSystem audioOut = new AudioOutputSystem(this, _lock, deviceSession, _sessionsBufferEvents[sessionId]);
|
AudioOutputSystem audioOut = new(this, _lock, deviceSession, _sessionsBufferEvents[sessionId]);
|
||||||
|
|
||||||
ResultCode result = audioOut.Initialize(inputDeviceName, sampleFormat, ref parameter, sessionId);
|
ResultCode result = audioOut.Initialize(inputDeviceName, sampleFormat, ref parameter, sessionId);
|
||||||
|
|
||||||
|
@ -268,6 +271,8 @@ namespace Ryujinx.Audio.Output
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Output
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The session the <see cref="AudioOutputSystem"/>.
|
/// The session the <see cref="AudioOutputSystem"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AudioDeviceSession _session;
|
private readonly AudioDeviceSession _session;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The target device name of the <see cref="AudioOutputSystem"/>.
|
/// The target device name of the <see cref="AudioOutputSystem"/>.
|
||||||
|
@ -43,7 +43,7 @@ namespace Ryujinx.Audio.Output
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="AudioOutputManager"/> owning this.
|
/// The <see cref="AudioOutputManager"/> owning this.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AudioOutputManager _manager;
|
private readonly AudioOutputManager _manager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// THe lock of the parent.
|
/// THe lock of the parent.
|
||||||
|
@ -90,11 +90,13 @@ namespace Ryujinx.Audio.Output
|
||||||
{
|
{
|
||||||
return ResultCode.DeviceNotFound;
|
return ResultCode.DeviceNotFound;
|
||||||
}
|
}
|
||||||
else if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
|
|
||||||
|
if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
|
||||||
{
|
{
|
||||||
return ResultCode.UnsupportedSampleRate;
|
return ResultCode.UnsupportedSampleRate;
|
||||||
}
|
}
|
||||||
else if (configuration.ChannelCount != 0 && configuration.ChannelCount != 1 && configuration.ChannelCount != 2 && configuration.ChannelCount != 6)
|
|
||||||
|
if (configuration.ChannelCount != 0 && configuration.ChannelCount != 1 && configuration.ChannelCount != 2 && configuration.ChannelCount != 6)
|
||||||
{
|
{
|
||||||
return ResultCode.UnsupportedChannelConfiguration;
|
return ResultCode.UnsupportedChannelConfiguration;
|
||||||
}
|
}
|
||||||
|
@ -185,11 +187,11 @@ namespace Ryujinx.Audio.Output
|
||||||
{
|
{
|
||||||
lock (_parentLock)
|
lock (_parentLock)
|
||||||
{
|
{
|
||||||
AudioBuffer buffer = new AudioBuffer
|
AudioBuffer buffer = new()
|
||||||
{
|
{
|
||||||
BufferTag = bufferTag,
|
BufferTag = bufferTag,
|
||||||
DataPointer = userBuffer.Data,
|
DataPointer = userBuffer.Data,
|
||||||
DataSize = userBuffer.DataSize
|
DataSize = userBuffer.DataSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_session.AppendBuffer(buffer))
|
if (_session.AppendBuffer(buffer))
|
||||||
|
@ -346,6 +348,8 @@ namespace Ryujinx.Audio.Output
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private uint _padding;
|
private readonly uint _padding;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The flags given controlling behaviour of the audio renderer
|
/// The flags given controlling behaviour of the audio renderer
|
||||||
|
@ -38,7 +38,7 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private uint _padding;
|
private readonly uint _padding;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extra information given with the <see cref="ResultCode"/>
|
/// Extra information given with the <see cref="ResultCode"/>
|
||||||
|
|
|
@ -38,6 +38,6 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The memory pool is released. (client side only)
|
/// The memory pool is released. (client side only)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Released = 6
|
Released = 6,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,6 +28,6 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performance monitoring related node id (performance commands)
|
/// Performance monitoring related node id (performance commands)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Performance = 15
|
Performance = 15,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -53,17 +53,17 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _nodeCount;
|
private int _nodeCount;
|
||||||
private EdgeMatrix _discovered;
|
private readonly EdgeMatrix _discovered;
|
||||||
private EdgeMatrix _finished;
|
private readonly EdgeMatrix _finished;
|
||||||
private Memory<int> _resultArray;
|
private Memory<int> _resultArray;
|
||||||
private Stack _stack;
|
private readonly Stack _stack;
|
||||||
private int _tsortResultIndex;
|
private int _tsortResultIndex;
|
||||||
|
|
||||||
private enum NodeState : byte
|
private enum NodeState : byte
|
||||||
{
|
{
|
||||||
Unknown,
|
Unknown,
|
||||||
Discovered,
|
Discovered,
|
||||||
Finished
|
Finished,
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeStates()
|
public NodeStates()
|
||||||
|
@ -88,16 +88,16 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
|
|
||||||
int edgeMatrixWorkBufferSize = EdgeMatrix.GetWorkBufferSize(nodeCount);
|
int edgeMatrixWorkBufferSize = EdgeMatrix.GetWorkBufferSize(nodeCount);
|
||||||
|
|
||||||
_discovered.Initialize(nodeStatesWorkBuffer.Slice(0, edgeMatrixWorkBufferSize), nodeCount);
|
_discovered.Initialize(nodeStatesWorkBuffer[..edgeMatrixWorkBufferSize], nodeCount);
|
||||||
_finished.Initialize(nodeStatesWorkBuffer.Slice(edgeMatrixWorkBufferSize, edgeMatrixWorkBufferSize), nodeCount);
|
_finished.Initialize(nodeStatesWorkBuffer.Slice(edgeMatrixWorkBufferSize, edgeMatrixWorkBufferSize), nodeCount);
|
||||||
|
|
||||||
nodeStatesWorkBuffer = nodeStatesWorkBuffer.Slice(edgeMatrixWorkBufferSize * 2);
|
nodeStatesWorkBuffer = nodeStatesWorkBuffer[(edgeMatrixWorkBufferSize * 2)..];
|
||||||
|
|
||||||
_resultArray = SpanMemoryManager<int>.Cast(nodeStatesWorkBuffer.Slice(0, sizeof(int) * nodeCount));
|
_resultArray = SpanMemoryManager<int>.Cast(nodeStatesWorkBuffer[..(sizeof(int) * nodeCount)]);
|
||||||
|
|
||||||
nodeStatesWorkBuffer = nodeStatesWorkBuffer.Slice(sizeof(int) * nodeCount);
|
nodeStatesWorkBuffer = nodeStatesWorkBuffer[(sizeof(int) * nodeCount)..];
|
||||||
|
|
||||||
Memory<int> stackWorkBuffer = SpanMemoryManager<int>.Cast(nodeStatesWorkBuffer.Slice(0, Stack.CalcBufferSize(nodeCount * nodeCount)));
|
Memory<int> stackWorkBuffer = SpanMemoryManager<int>.Cast(nodeStatesWorkBuffer[..Stack.CalcBufferSize(nodeCount * nodeCount)]);
|
||||||
|
|
||||||
_stack.Reset(stackWorkBuffer, nodeCount * nodeCount);
|
_stack.Reset(stackWorkBuffer, nodeCount * nodeCount);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,8 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
|
|
||||||
return NodeState.Discovered;
|
return NodeState.Discovered;
|
||||||
}
|
}
|
||||||
else if (_finished.Test(index))
|
|
||||||
|
if (_finished.Test(index))
|
||||||
{
|
{
|
||||||
Debug.Assert(!_discovered.Test(index));
|
Debug.Assert(!_discovered.Test(index));
|
||||||
|
|
||||||
|
@ -158,7 +159,7 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
|
|
||||||
public ReadOnlySpan<int> GetTsortResult()
|
public ReadOnlySpan<int> GetTsortResult()
|
||||||
{
|
{
|
||||||
return _resultArray.Span.Slice(0, _tsortResultIndex);
|
return _resultArray.Span[.._tsortResultIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Sort(EdgeMatrix edgeMatrix)
|
public bool Sort(EdgeMatrix edgeMatrix)
|
||||||
|
|
|
@ -15,6 +15,6 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
PcmFloat,
|
PcmFloat,
|
||||||
Limiter,
|
Limiter,
|
||||||
CaptureBuffer,
|
CaptureBuffer,
|
||||||
Compressor
|
Compressor,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,6 +6,6 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
Voice,
|
Voice,
|
||||||
SubMix,
|
SubMix,
|
||||||
FinalMix,
|
FinalMix,
|
||||||
Sink
|
Sink,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,6 +18,6 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The user request the voice to be paused.
|
/// The user request the voice to be paused.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Pause
|
Pause,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,6 +28,6 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// No early reflection.
|
/// No early reflection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Disabled
|
Disabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,6 +33,6 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Max delay. (used for delay line limits)
|
/// Max delay. (used for delay line limits)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Limit = NoDelay
|
Limit = NoDelay,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,6 +18,6 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The sink is a circular buffer.
|
/// The sink is a circular buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
CircularBuffer
|
CircularBuffer,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Ryujinx.Common.Memory;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Renderer.Common
|
namespace Ryujinx.Audio.Renderer.Common
|
||||||
|
@ -19,7 +20,9 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
public uint Unknown24;
|
public uint Unknown24;
|
||||||
public uint RenderInfoSize;
|
public uint RenderInfoSize;
|
||||||
|
|
||||||
private unsafe fixed int _reserved[4];
|
#pragma warning disable IDE0051, CS0169 // Remove unused field
|
||||||
|
private Array4<int> _reserved;
|
||||||
|
#pragma warning restore IDE0051, CS0169
|
||||||
|
|
||||||
public uint TotalSize;
|
public uint TotalSize;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using DspAddr = System.UInt64;
|
using DspAddr = System.UInt64;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Renderer.Common
|
namespace Ryujinx.Audio.Renderer.Common
|
||||||
|
@ -77,6 +76,6 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Padding/Reserved.
|
/// Padding/Reserved.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ushort _padding;
|
private readonly ushort _padding;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,7 +23,7 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
|
|
||||||
if (size != 0)
|
if (size != 0)
|
||||||
{
|
{
|
||||||
ulong alignedOffset = BitUtils.AlignUp<ulong>(Offset, (ulong)align);
|
ulong alignedOffset = BitUtils.AlignUp(Offset, (ulong)align);
|
||||||
|
|
||||||
if (alignedOffset + size <= (ulong)BackingMemory.Length)
|
if (alignedOffset + size <= (ulong)BackingMemory.Length)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
Offset = alignedOffset + size;
|
Offset = alignedOffset + size;
|
||||||
|
|
||||||
// Clear the memory to be sure that is does not contain any garbage.
|
// Clear the memory to be sure that is does not contain any garbage.
|
||||||
result.Span.Fill(0);
|
result.Span.Clear();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||||
|
|
||||||
public static ulong GetTargetSize<T>(ulong currentSize, ulong count, int align) where T : unmanaged
|
public static ulong GetTargetSize<T>(ulong currentSize, ulong count, int align) where T : unmanaged
|
||||||
{
|
{
|
||||||
return BitUtils.AlignUp<ulong>(currentSize, (ulong)align) + (ulong)Unsafe.SizeOf<T>() * count;
|
return BitUtils.AlignUp(currentSize, (ulong)align) + (ulong)Unsafe.SizeOf<T>() * count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,11 +12,11 @@ namespace Ryujinx.Audio.Renderer.Device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly VirtualDevice[] Devices = new VirtualDevice[5]
|
public static readonly VirtualDevice[] Devices = new VirtualDevice[5]
|
||||||
{
|
{
|
||||||
new VirtualDevice("AudioStereoJackOutput", 2, true),
|
new("AudioStereoJackOutput", 2, true),
|
||||||
new VirtualDevice("AudioBuiltInSpeakerOutput", 2, false),
|
new("AudioBuiltInSpeakerOutput", 2, false),
|
||||||
new VirtualDevice("AudioTvOutput", 6, false),
|
new("AudioTvOutput", 6, false),
|
||||||
new VirtualDevice("AudioUsbDeviceOutput", 2, true),
|
new("AudioUsbDeviceOutput", 2, true),
|
||||||
new VirtualDevice("AudioExternalOutput", 6, true),
|
new("AudioExternalOutput", 6, true),
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -11,13 +11,15 @@ namespace Ryujinx.Audio.Renderer.Device
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The session registry, used to store the sessions of a given AppletResourceId.
|
/// The session registry, used to store the sessions of a given AppletResourceId.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Dictionary<ulong, VirtualDeviceSession[]> _sessionsRegistry = new Dictionary<ulong, VirtualDeviceSession[]>();
|
private readonly Dictionary<ulong, VirtualDeviceSession[]> _sessionsRegistry = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default <see cref="VirtualDevice"/>.
|
/// The default <see cref="VirtualDevice"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>This is used when the USB device is the default one on older revision.</remarks>
|
/// <remarks>This is used when the USB device is the default one on older revision.</remarks>
|
||||||
|
#pragma warning disable CA1822 // Mark member as static
|
||||||
public VirtualDevice DefaultDevice => VirtualDevice.Devices[0];
|
public VirtualDevice DefaultDevice => VirtualDevice.Devices[0];
|
||||||
|
#pragma warning restore CA1822
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current active <see cref="VirtualDevice"/>.
|
/// The current active <see cref="VirtualDevice"/>.
|
||||||
|
|
|
@ -12,7 +12,9 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
private const int SamplesPerFrame = 14;
|
private const int SamplesPerFrame = 14;
|
||||||
private const int NibblesPerFrame = SamplesPerFrame + 2;
|
private const int NibblesPerFrame = SamplesPerFrame + 2;
|
||||||
private const int BytesPerFrame = 8;
|
private const int BytesPerFrame = 8;
|
||||||
|
#pragma warning disable IDE0051 // Remove unused private member
|
||||||
private const int BitsPerFrame = BytesPerFrame * 8;
|
private const int BitsPerFrame = BytesPerFrame * 8;
|
||||||
|
#pragma warning restore IDE0051
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static uint GetAdpcmDataSize(int sampleCount)
|
public static uint GetAdpcmDataSize(int sampleCount)
|
||||||
|
@ -64,10 +66,14 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
private static short Saturate(int value)
|
private static short Saturate(int value)
|
||||||
{
|
{
|
||||||
if (value > short.MaxValue)
|
if (value > short.MaxValue)
|
||||||
|
{
|
||||||
value = short.MaxValue;
|
value = short.MaxValue;
|
||||||
|
}
|
||||||
|
|
||||||
if (value < short.MinValue)
|
if (value < short.MinValue)
|
||||||
|
{
|
||||||
value = short.MinValue;
|
value = short.MinValue;
|
||||||
|
}
|
||||||
|
|
||||||
return (short)value;
|
return (short)value;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +115,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
|
|
||||||
ReadOnlySpan<byte> targetInput;
|
ReadOnlySpan<byte> targetInput;
|
||||||
|
|
||||||
targetInput = input.Slice(nibbles / 2);
|
targetInput = input[(nibbles / 2)..];
|
||||||
|
|
||||||
while (remaining > 0)
|
while (remaining > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
Start,
|
Start,
|
||||||
Stop,
|
Stop,
|
||||||
RenderStart,
|
RenderStart,
|
||||||
RenderEnd
|
RenderEnd,
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RendererSession
|
private class RendererSession
|
||||||
|
@ -36,7 +36,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
|
|
||||||
private long _lastTime;
|
private long _lastTime;
|
||||||
private long _playbackEnds;
|
private long _playbackEnds;
|
||||||
private ManualResetEvent _event;
|
private readonly ManualResetEvent _event;
|
||||||
|
|
||||||
private ManualResetEvent _pauseEvent;
|
private ManualResetEvent _pauseEvent;
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
_event = new ManualResetEvent(false);
|
_event = new ManualResetEvent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable IDE0051 // Remove unused private member
|
||||||
private static uint GetHardwareChannelCount(IHardwareDeviceDriver deviceDriver)
|
private static uint GetHardwareChannelCount(IHardwareDeviceDriver deviceDriver)
|
||||||
{
|
{
|
||||||
// Get the real device driver (In case the compat layer is on top of it).
|
// Get the real device driver (In case the compat layer is on top of it).
|
||||||
|
@ -54,12 +55,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
{
|
{
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
// NOTE: We default to stereo as this will get downmixed to mono by the compat layer if it's not compatible.
|
||||||
// NOTE: We default to stereo as this will get downmixed to mono by the compat layer if it's not compatible.
|
return 2;
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#pragma warning restore IDE0051
|
||||||
|
|
||||||
public void Start(IHardwareDeviceDriver deviceDriver, float volume)
|
public void Start(IHardwareDeviceDriver deviceDriver, float volume)
|
||||||
{
|
{
|
||||||
|
@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
{
|
{
|
||||||
CommandList = commands,
|
CommandList = commands,
|
||||||
RenderingLimit = renderingLimit,
|
RenderingLimit = renderingLimit,
|
||||||
AppletResourceId = appletResourceId
|
AppletResourceId = appletResourceId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
{
|
{
|
||||||
_workerThread = new Thread(Work)
|
_workerThread = new Thread(Work)
|
||||||
{
|
{
|
||||||
Name = "AudioProcessor.Worker"
|
Name = "AudioProcessor.Worker",
|
||||||
};
|
};
|
||||||
|
|
||||||
_workerThread.Start();
|
_workerThread.Start();
|
||||||
|
@ -260,6 +260,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using Ryujinx.Audio.Common;
|
using Ryujinx.Audio.Common;
|
||||||
using Ryujinx.Audio.Renderer.Common;
|
using Ryujinx.Audio.Renderer.Common;
|
||||||
|
using Ryujinx.Audio.Renderer.Server.Voice;
|
||||||
using System;
|
using System;
|
||||||
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
|
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
|
||||||
|
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Renderer.Dsp.Command
|
namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
{
|
{
|
||||||
|
@ -29,7 +31,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
public DecodingBehaviour DecodingBehaviour { get; }
|
public DecodingBehaviour DecodingBehaviour { get; }
|
||||||
|
|
||||||
public AdpcmDataSourceCommandVersion1(ref Server.Voice.VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, int nodeId)
|
public AdpcmDataSourceCommandVersion1(ref VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, int nodeId)
|
||||||
{
|
{
|
||||||
Enabled = true;
|
Enabled = true;
|
||||||
NodeId = nodeId;
|
NodeId = nodeId;
|
||||||
|
@ -57,7 +59,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
{
|
{
|
||||||
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
|
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
|
||||||
|
|
||||||
DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
|
DataSourceHelper.WaveBufferInformation info = new()
|
||||||
{
|
{
|
||||||
SourceSampleRate = SampleRate,
|
SourceSampleRate = SampleRate,
|
||||||
SampleFormat = SampleFormat.Adpcm,
|
SampleFormat = SampleFormat.Adpcm,
|
||||||
|
|
|
@ -155,7 +155,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
if (readResult != context.SampleCount)
|
if (readResult != context.SampleCount)
|
||||||
{
|
{
|
||||||
outputBuffer.Slice((int)readResult, (int)context.SampleCount - (int)readResult).Fill(0);
|
outputBuffer[(int)readResult..(int)context.SampleCount].Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
return (IntPtr)((float*)_buffersMemoryHandle.Pointer + index * _sampleCount);
|
return (IntPtr)((float*)_buffersMemoryHandle.Pointer + index * _sampleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException(nameof(index), index, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
@ -149,6 +149,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
_buffersMemoryHandle.Dispose();
|
_buffersMemoryHandle.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
LimiterVersion2,
|
LimiterVersion2,
|
||||||
GroupedBiquadFilter,
|
GroupedBiquadFilter,
|
||||||
CaptureBuffer,
|
CaptureBuffer,
|
||||||
Compressor
|
Compressor,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
using Ryujinx.Audio.Renderer.Dsp.Effect;
|
using Ryujinx.Audio.Renderer.Dsp.Effect;
|
||||||
using Ryujinx.Audio.Renderer.Dsp.State;
|
using Ryujinx.Audio.Renderer.Dsp.State;
|
||||||
using Ryujinx.Audio.Renderer.Parameter.Effect;
|
using Ryujinx.Audio.Renderer.Parameter.Effect;
|
||||||
|
using Ryujinx.Audio.Renderer.Server.Effect;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
@ -51,11 +52,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
if (IsEffectEnabled)
|
if (IsEffectEnabled)
|
||||||
{
|
{
|
||||||
if (_parameter.Status == Server.Effect.UsageState.Invalid)
|
if (_parameter.Status == UsageState.Invalid)
|
||||||
{
|
{
|
||||||
state = new CompressorState(ref _parameter);
|
state = new CompressorState(ref _parameter);
|
||||||
}
|
}
|
||||||
else if (_parameter.Status == Server.Effect.UsageState.New)
|
else if (_parameter.Status == UsageState.New)
|
||||||
{
|
{
|
||||||
state.UpdateParameter(ref _parameter);
|
state.UpdateParameter(ref _parameter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using Ryujinx.Audio.Common;
|
using Ryujinx.Audio.Common;
|
||||||
using Ryujinx.Audio.Renderer.Common;
|
using Ryujinx.Audio.Renderer.Common;
|
||||||
|
using Ryujinx.Audio.Renderer.Server.Voice;
|
||||||
using System;
|
using System;
|
||||||
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
|
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
|
||||||
|
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Renderer.Dsp.Command
|
namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
{
|
{
|
||||||
|
@ -37,7 +39,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
public SampleRateConversionQuality SrcQuality { get; }
|
public SampleRateConversionQuality SrcQuality { get; }
|
||||||
|
|
||||||
public DataSourceVersion2Command(ref Server.Voice.VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
public DataSourceVersion2Command(ref VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||||
{
|
{
|
||||||
Enabled = true;
|
Enabled = true;
|
||||||
NodeId = nodeId;
|
NodeId = nodeId;
|
||||||
|
@ -72,24 +74,20 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
private static CommandType GetCommandTypeBySampleFormat(SampleFormat sampleFormat)
|
private static CommandType GetCommandTypeBySampleFormat(SampleFormat sampleFormat)
|
||||||
{
|
{
|
||||||
switch (sampleFormat)
|
return sampleFormat switch
|
||||||
{
|
{
|
||||||
case SampleFormat.Adpcm:
|
SampleFormat.Adpcm => CommandType.AdpcmDataSourceVersion2,
|
||||||
return CommandType.AdpcmDataSourceVersion2;
|
SampleFormat.PcmInt16 => CommandType.PcmInt16DataSourceVersion2,
|
||||||
case SampleFormat.PcmInt16:
|
SampleFormat.PcmFloat => CommandType.PcmFloatDataSourceVersion2,
|
||||||
return CommandType.PcmInt16DataSourceVersion2;
|
_ => throw new NotImplementedException($"{sampleFormat}"),
|
||||||
case SampleFormat.PcmFloat:
|
};
|
||||||
return CommandType.PcmFloatDataSourceVersion2;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{sampleFormat}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Process(CommandList context)
|
public void Process(CommandList context)
|
||||||
{
|
{
|
||||||
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
|
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
|
||||||
|
|
||||||
DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
|
DataSourceHelper.WaveBufferInformation info = new()
|
||||||
{
|
{
|
||||||
SourceSampleRate = SampleRate,
|
SourceSampleRate = SampleRate,
|
||||||
SampleFormat = SampleFormat,
|
SampleFormat = SampleFormat,
|
||||||
|
@ -99,7 +97,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
ExtraParameterSize = ExtraParameterSize,
|
ExtraParameterSize = ExtraParameterSize,
|
||||||
ChannelIndex = (int)ChannelIndex,
|
ChannelIndex = (int)ChannelIndex,
|
||||||
ChannelCount = (int)ChannelCount,
|
ChannelCount = (int)ChannelCount,
|
||||||
SrcQuality = SrcQuality
|
SrcQuality = SrcQuality,
|
||||||
};
|
};
|
||||||
|
|
||||||
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
|
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
|
||||||
|
|
|
@ -87,18 +87,18 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
|
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
|
||||||
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
|
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
|
||||||
|
|
||||||
Matrix2x2 delayFeedback = new Matrix2x2(delayFeedbackBaseGain, delayFeedbackCrossGain,
|
Matrix2x2 delayFeedback = new(delayFeedbackBaseGain, delayFeedbackCrossGain,
|
||||||
delayFeedbackCrossGain, delayFeedbackBaseGain);
|
delayFeedbackCrossGain, delayFeedbackBaseGain);
|
||||||
|
|
||||||
for (int i = 0; i < sampleCount; i++)
|
for (int i = 0; i < sampleCount; i++)
|
||||||
{
|
{
|
||||||
Vector2 channelInput = new Vector2
|
Vector2 channelInput = new()
|
||||||
{
|
{
|
||||||
X = *((float*)inputBuffers[0] + i) * 64,
|
X = *((float*)inputBuffers[0] + i) * 64,
|
||||||
Y = *((float*)inputBuffers[1] + i) * 64,
|
Y = *((float*)inputBuffers[1] + i) * 64,
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector2 delayLineValues = new Vector2()
|
Vector2 delayLineValues = new()
|
||||||
{
|
{
|
||||||
X = state.DelayLines[0].Read(),
|
X = state.DelayLines[0].Read(),
|
||||||
Y = state.DelayLines[1].Read(),
|
Y = state.DelayLines[1].Read(),
|
||||||
|
@ -124,7 +124,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
|
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
|
||||||
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
|
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
|
||||||
|
|
||||||
Matrix4x4 delayFeedback = new Matrix4x4(delayFeedbackBaseGain, delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f,
|
Matrix4x4 delayFeedback = new(delayFeedbackBaseGain, delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f,
|
||||||
delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain,
|
delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain,
|
||||||
delayFeedbackCrossGain, 0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain,
|
delayFeedbackCrossGain, 0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain,
|
||||||
0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain);
|
0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain);
|
||||||
|
@ -132,20 +132,20 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
for (int i = 0; i < sampleCount; i++)
|
for (int i = 0; i < sampleCount; i++)
|
||||||
{
|
{
|
||||||
Vector4 channelInput = new Vector4
|
Vector4 channelInput = new()
|
||||||
{
|
{
|
||||||
X = *((float*)inputBuffers[0] + i) * 64,
|
X = *((float*)inputBuffers[0] + i) * 64,
|
||||||
Y = *((float*)inputBuffers[1] + i) * 64,
|
Y = *((float*)inputBuffers[1] + i) * 64,
|
||||||
Z = *((float*)inputBuffers[2] + i) * 64,
|
Z = *((float*)inputBuffers[2] + i) * 64,
|
||||||
W = *((float*)inputBuffers[3] + i) * 64
|
W = *((float*)inputBuffers[3] + i) * 64,
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector4 delayLineValues = new Vector4()
|
Vector4 delayLineValues = new()
|
||||||
{
|
{
|
||||||
X = state.DelayLines[0].Read(),
|
X = state.DelayLines[0].Read(),
|
||||||
Y = state.DelayLines[1].Read(),
|
Y = state.DelayLines[1].Read(),
|
||||||
Z = state.DelayLines[2].Read(),
|
Z = state.DelayLines[2].Read(),
|
||||||
W = state.DelayLines[3].Read()
|
W = state.DelayLines[3].Read(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector4 temp = MatrixHelper.Transform(ref delayLineValues, ref delayFeedback) + channelInput * inGain;
|
Vector4 temp = MatrixHelper.Transform(ref delayLineValues, ref delayFeedback) + channelInput * inGain;
|
||||||
|
@ -171,7 +171,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
|
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
|
||||||
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
|
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
|
||||||
|
|
||||||
Matrix6x6 delayFeedback = new Matrix6x6(delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain, 0.0f, delayFeedbackCrossGain, 0.0f,
|
Matrix6x6 delayFeedback = new(delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain, 0.0f, delayFeedbackCrossGain, 0.0f,
|
||||||
0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain, 0.0f, 0.0f, delayFeedbackCrossGain,
|
0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain, 0.0f, 0.0f, delayFeedbackCrossGain,
|
||||||
delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, 0.0f, 0.0f,
|
delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, 0.0f, 0.0f,
|
||||||
0.0f, 0.0f, 0.0f, feedbackGain, 0.0f, 0.0f,
|
0.0f, 0.0f, 0.0f, feedbackGain, 0.0f, 0.0f,
|
||||||
|
@ -180,24 +180,24 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
for (int i = 0; i < sampleCount; i++)
|
for (int i = 0; i < sampleCount; i++)
|
||||||
{
|
{
|
||||||
Vector6 channelInput = new Vector6
|
Vector6 channelInput = new()
|
||||||
{
|
{
|
||||||
X = *((float*)inputBuffers[0] + i) * 64,
|
X = *((float*)inputBuffers[0] + i) * 64,
|
||||||
Y = *((float*)inputBuffers[1] + i) * 64,
|
Y = *((float*)inputBuffers[1] + i) * 64,
|
||||||
Z = *((float*)inputBuffers[2] + i) * 64,
|
Z = *((float*)inputBuffers[2] + i) * 64,
|
||||||
W = *((float*)inputBuffers[3] + i) * 64,
|
W = *((float*)inputBuffers[3] + i) * 64,
|
||||||
V = *((float*)inputBuffers[4] + i) * 64,
|
V = *((float*)inputBuffers[4] + i) * 64,
|
||||||
U = *((float*)inputBuffers[5] + i) * 64
|
U = *((float*)inputBuffers[5] + i) * 64,
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector6 delayLineValues = new Vector6
|
Vector6 delayLineValues = new()
|
||||||
{
|
{
|
||||||
X = state.DelayLines[0].Read(),
|
X = state.DelayLines[0].Read(),
|
||||||
Y = state.DelayLines[1].Read(),
|
Y = state.DelayLines[1].Read(),
|
||||||
Z = state.DelayLines[2].Read(),
|
Z = state.DelayLines[2].Read(),
|
||||||
W = state.DelayLines[3].Read(),
|
W = state.DelayLines[3].Read(),
|
||||||
V = state.DelayLines[4].Read(),
|
V = state.DelayLines[4].Read(),
|
||||||
U = state.DelayLines[5].Read()
|
U = state.DelayLines[5].Read(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector6 temp = MatrixHelper.Transform(ref delayLineValues, ref delayFeedback) + channelInput * inGain;
|
Vector6 temp = MatrixHelper.Transform(ref delayLineValues, ref delayFeedback) + channelInput * inGain;
|
||||||
|
|
|
@ -55,17 +55,15 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
return -depopValue;
|
return -depopValue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
for (int i = 0; i < sampleCount; i++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < sampleCount; i++)
|
depopValue = FloatingPointHelper.MultiplyRoundDown(Decay, depopValue);
|
||||||
{
|
|
||||||
depopValue = FloatingPointHelper.MultiplyRoundDown(Decay, depopValue);
|
|
||||||
|
|
||||||
buffer[i] += depopValue;
|
buffer[i] += depopValue;
|
||||||
}
|
|
||||||
|
|
||||||
return depopValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return depopValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Process(CommandList context)
|
public void Process(CommandList context)
|
||||||
|
|
|
@ -14,11 +14,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
public uint EstimatedProcessingTime { get; set; }
|
public uint EstimatedProcessingTime { get; set; }
|
||||||
|
|
||||||
private BiquadFilterParameter[] _parameters;
|
private readonly BiquadFilterParameter[] _parameters;
|
||||||
private Memory<BiquadFilterState> _biquadFilterStates;
|
private readonly Memory<BiquadFilterState> _biquadFilterStates;
|
||||||
private int _inputBufferIndex;
|
private readonly int _inputBufferIndex;
|
||||||
private int _outputBufferIndex;
|
private readonly int _outputBufferIndex;
|
||||||
private bool[] _isInitialized;
|
private readonly bool[] _isInitialized;
|
||||||
|
|
||||||
public GroupedBiquadFilterCommand(int baseIndex, ReadOnlySpan<BiquadFilterParameter> filters, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
|
public GroupedBiquadFilterCommand(int baseIndex, ReadOnlySpan<BiquadFilterParameter> filters, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Ryujinx.Audio.Renderer.Dsp.State;
|
using Ryujinx.Audio.Renderer.Dsp.State;
|
||||||
using Ryujinx.Audio.Renderer.Parameter.Effect;
|
using Ryujinx.Audio.Renderer.Parameter.Effect;
|
||||||
|
using Ryujinx.Audio.Renderer.Server.Effect;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
@ -50,13 +51,13 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
if (IsEffectEnabled)
|
if (IsEffectEnabled)
|
||||||
{
|
{
|
||||||
if (Parameter.Status == Server.Effect.UsageState.Invalid)
|
if (Parameter.Status == UsageState.Invalid)
|
||||||
{
|
{
|
||||||
state = new LimiterState(ref _parameter, WorkBuffer);
|
state = new LimiterState(ref _parameter, WorkBuffer);
|
||||||
}
|
}
|
||||||
else if (Parameter.Status == Server.Effect.UsageState.New)
|
else if (Parameter.Status == UsageState.New)
|
||||||
{
|
{
|
||||||
state.UpdateParameter(ref _parameter);
|
LimiterState.UpdateParameter(ref _parameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Ryujinx.Audio.Renderer.Dsp.State;
|
using Ryujinx.Audio.Renderer.Dsp.State;
|
||||||
using Ryujinx.Audio.Renderer.Parameter;
|
using Ryujinx.Audio.Renderer.Parameter;
|
||||||
using Ryujinx.Audio.Renderer.Parameter.Effect;
|
using Ryujinx.Audio.Renderer.Parameter.Effect;
|
||||||
|
using Ryujinx.Audio.Renderer.Server.Effect;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
@ -54,13 +55,13 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
if (IsEffectEnabled)
|
if (IsEffectEnabled)
|
||||||
{
|
{
|
||||||
if (Parameter.Status == Server.Effect.UsageState.Invalid)
|
if (Parameter.Status == UsageState.Invalid)
|
||||||
{
|
{
|
||||||
state = new LimiterState(ref _parameter, WorkBuffer);
|
state = new LimiterState(ref _parameter, WorkBuffer);
|
||||||
}
|
}
|
||||||
else if (Parameter.Status == Server.Effect.UsageState.New)
|
else if (Parameter.Status == UsageState.New)
|
||||||
{
|
{
|
||||||
state.UpdateParameter(ref _parameter);
|
LimiterState.UpdateParameter(ref _parameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private float ProcessMixRampGrouped(Span<float> outputBuffer, ReadOnlySpan<float> inputBuffer, float volume0, float volume1, int sampleCount)
|
private static float ProcessMixRampGrouped(Span<float> outputBuffer, ReadOnlySpan<float> inputBuffer, float volume0, float volume1, int sampleCount)
|
||||||
{
|
{
|
||||||
float ramp = (volume1 - volume0) / sampleCount;
|
float ramp = (volume1 - volume0) / sampleCount;
|
||||||
float volume = volume0;
|
float volume = volume0;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using Ryujinx.Audio.Common;
|
using Ryujinx.Audio.Common;
|
||||||
using Ryujinx.Audio.Renderer.Common;
|
using Ryujinx.Audio.Renderer.Common;
|
||||||
|
using Ryujinx.Audio.Renderer.Server.Voice;
|
||||||
using System;
|
using System;
|
||||||
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
|
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
|
||||||
|
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Renderer.Dsp.Command
|
namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
{
|
{
|
||||||
|
@ -28,7 +30,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
public Memory<VoiceUpdateState> State { get; }
|
public Memory<VoiceUpdateState> State { get; }
|
||||||
public DecodingBehaviour DecodingBehaviour { get; }
|
public DecodingBehaviour DecodingBehaviour { get; }
|
||||||
|
|
||||||
public PcmFloatDataSourceCommandVersion1(ref Server.Voice.VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
public PcmFloatDataSourceCommandVersion1(ref VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||||
{
|
{
|
||||||
Enabled = true;
|
Enabled = true;
|
||||||
NodeId = nodeId;
|
NodeId = nodeId;
|
||||||
|
@ -56,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
{
|
{
|
||||||
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
|
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
|
||||||
|
|
||||||
DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
|
DataSourceHelper.WaveBufferInformation info = new()
|
||||||
{
|
{
|
||||||
SourceSampleRate = SampleRate,
|
SourceSampleRate = SampleRate,
|
||||||
SampleFormat = SampleFormat.PcmFloat,
|
SampleFormat = SampleFormat.PcmFloat,
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using Ryujinx.Audio.Common;
|
using Ryujinx.Audio.Common;
|
||||||
using Ryujinx.Audio.Renderer.Common;
|
using Ryujinx.Audio.Renderer.Common;
|
||||||
|
using Ryujinx.Audio.Renderer.Server.Voice;
|
||||||
using System;
|
using System;
|
||||||
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
|
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
|
||||||
|
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Renderer.Dsp.Command
|
namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
{
|
{
|
||||||
|
@ -28,7 +30,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
public Memory<VoiceUpdateState> State { get; }
|
public Memory<VoiceUpdateState> State { get; }
|
||||||
public DecodingBehaviour DecodingBehaviour { get; }
|
public DecodingBehaviour DecodingBehaviour { get; }
|
||||||
|
|
||||||
public PcmInt16DataSourceCommandVersion1(ref Server.Voice.VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
public PcmInt16DataSourceCommandVersion1(ref VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||||
{
|
{
|
||||||
Enabled = true;
|
Enabled = true;
|
||||||
NodeId = nodeId;
|
NodeId = nodeId;
|
||||||
|
@ -56,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
{
|
{
|
||||||
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
|
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
|
||||||
|
|
||||||
DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
|
DataSourceHelper.WaveBufferInformation info = new()
|
||||||
{
|
{
|
||||||
SourceSampleRate = SampleRate,
|
SourceSampleRate = SampleRate,
|
||||||
SampleFormat = SampleFormat.PcmInt16,
|
SampleFormat = SampleFormat.PcmInt16,
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
{
|
{
|
||||||
Invalid,
|
Invalid,
|
||||||
Start,
|
Start,
|
||||||
End
|
End,
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
|
|
@ -9,21 +9,21 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
{
|
{
|
||||||
public class Reverb3dCommand : ICommand
|
public class Reverb3dCommand : ICommand
|
||||||
{
|
{
|
||||||
private static readonly int[] OutputEarlyIndicesTableMono = new int[20] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
private static readonly int[] _outputEarlyIndicesTableMono = new int[20] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
private static readonly int[] TargetEarlyDelayLineIndicesTableMono = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
|
private static readonly int[] _targetEarlyDelayLineIndicesTableMono = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
|
||||||
private static readonly int[] TargetOutputFeedbackIndicesTableMono = new int[1] { 0 };
|
private static readonly int[] _targetOutputFeedbackIndicesTableMono = new int[1] { 0 };
|
||||||
|
|
||||||
private static readonly int[] OutputEarlyIndicesTableStereo = new int[20] { 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1 };
|
private static readonly int[] _outputEarlyIndicesTableStereo = new int[20] { 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1 };
|
||||||
private static readonly int[] TargetEarlyDelayLineIndicesTableStereo = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
|
private static readonly int[] _targetEarlyDelayLineIndicesTableStereo = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
|
||||||
private static readonly int[] TargetOutputFeedbackIndicesTableStereo = new int[2] { 0, 1 };
|
private static readonly int[] _targetOutputFeedbackIndicesTableStereo = new int[2] { 0, 1 };
|
||||||
|
|
||||||
private static readonly int[] OutputEarlyIndicesTableQuadraphonic = new int[20] { 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3 };
|
private static readonly int[] _outputEarlyIndicesTableQuadraphonic = new int[20] { 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3 };
|
||||||
private static readonly int[] TargetEarlyDelayLineIndicesTableQuadraphonic = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
|
private static readonly int[] _targetEarlyDelayLineIndicesTableQuadraphonic = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
|
||||||
private static readonly int[] TargetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
|
private static readonly int[] _targetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
|
||||||
|
|
||||||
private static readonly int[] OutputEarlyIndicesTableSurround = new int[40] { 4, 5, 0, 5, 0, 5, 1, 5, 1, 5, 1, 5, 1, 5, 2, 5, 2, 5, 2, 5, 1, 5, 1, 5, 1, 5, 0, 5, 0, 5, 0, 5, 0, 5, 3, 5, 3, 5, 3, 5 };
|
private static readonly int[] _outputEarlyIndicesTableSurround = new int[40] { 4, 5, 0, 5, 0, 5, 1, 5, 1, 5, 1, 5, 1, 5, 2, 5, 2, 5, 2, 5, 1, 5, 1, 5, 1, 5, 0, 5, 0, 5, 0, 5, 0, 5, 3, 5, 3, 5, 3, 5 };
|
||||||
private static readonly int[] TargetEarlyDelayLineIndicesTableSurround = new int[40] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19 };
|
private static readonly int[] _targetEarlyDelayLineIndicesTableSurround = new int[40] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19 };
|
||||||
private static readonly int[] TargetOutputFeedbackIndicesTableSurround = new int[6] { 0, 1, 2, 3, -1, 3 };
|
private static readonly int[] _targetOutputFeedbackIndicesTableSurround = new int[6] { 0, 1, 2, 3, -1, 3 };
|
||||||
|
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
|
@ -73,25 +73,25 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverb3dMono(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverb3dMono(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableMono, TargetEarlyDelayLineIndicesTableMono, TargetOutputFeedbackIndicesTableMono);
|
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableMono, _targetEarlyDelayLineIndicesTableMono, _targetOutputFeedbackIndicesTableMono);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverb3dStereo(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverb3dStereo(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableStereo, TargetEarlyDelayLineIndicesTableStereo, TargetOutputFeedbackIndicesTableStereo);
|
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableStereo, _targetEarlyDelayLineIndicesTableStereo, _targetOutputFeedbackIndicesTableStereo);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverb3dQuadraphonic(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverb3dQuadraphonic(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableQuadraphonic, TargetEarlyDelayLineIndicesTableQuadraphonic, TargetOutputFeedbackIndicesTableQuadraphonic);
|
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableQuadraphonic, _targetEarlyDelayLineIndicesTableQuadraphonic, _targetOutputFeedbackIndicesTableQuadraphonic);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverb3dSurround(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverb3dSurround(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableSurround, TargetEarlyDelayLineIndicesTableSurround, TargetOutputFeedbackIndicesTableSurround);
|
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableSurround, _targetEarlyDelayLineIndicesTableSurround, _targetOutputFeedbackIndicesTableSurround);
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void ProcessReverb3dGeneric(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount, ReadOnlySpan<int> outputEarlyIndicesTable, ReadOnlySpan<int> targetEarlyDelayLineIndicesTable, ReadOnlySpan<int> targetOutputFeedbackIndicesTable)
|
private unsafe void ProcessReverb3dGeneric(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount, ReadOnlySpan<int> outputEarlyIndicesTable, ReadOnlySpan<int> targetEarlyDelayLineIndicesTable, ReadOnlySpan<int> targetOutputFeedbackIndicesTable)
|
||||||
|
@ -109,7 +109,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
|
for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
|
||||||
{
|
{
|
||||||
outputValues.Fill(0);
|
outputValues.Clear();
|
||||||
|
|
||||||
float tapOut = state.PreDelayLine.TapUnsafe(state.ReflectionDelayTime, DelayLineSampleIndexOffset);
|
float tapOut = state.PreDelayLine.TapUnsafe(state.ReflectionDelayTime, DelayLineSampleIndexOffset);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Ryujinx.Audio.Renderer.Dsp.State;
|
using Ryujinx.Audio.Renderer.Dsp.State;
|
||||||
using Ryujinx.Audio.Renderer.Parameter.Effect;
|
using Ryujinx.Audio.Renderer.Parameter.Effect;
|
||||||
|
using Ryujinx.Audio.Renderer.Server.Effect;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
@ -8,25 +9,25 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
{
|
{
|
||||||
public class ReverbCommand : ICommand
|
public class ReverbCommand : ICommand
|
||||||
{
|
{
|
||||||
private static readonly int[] OutputEarlyIndicesTableMono = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
private static readonly int[] _outputEarlyIndicesTableMono = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
private static readonly int[] TargetEarlyDelayLineIndicesTableMono = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
private static readonly int[] _targetEarlyDelayLineIndicesTableMono = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||||
private static readonly int[] OutputIndicesTableMono = new int[4] { 0, 0, 0, 0 };
|
private static readonly int[] _outputIndicesTableMono = new int[4] { 0, 0, 0, 0 };
|
||||||
private static readonly int[] TargetOutputFeedbackIndicesTableMono = new int[4] { 0, 1, 2, 3 };
|
private static readonly int[] _targetOutputFeedbackIndicesTableMono = new int[4] { 0, 1, 2, 3 };
|
||||||
|
|
||||||
private static readonly int[] OutputEarlyIndicesTableStereo = new int[10] { 0, 0, 1, 1, 0, 1, 0, 0, 1, 1 };
|
private static readonly int[] _outputEarlyIndicesTableStereo = new int[10] { 0, 0, 1, 1, 0, 1, 0, 0, 1, 1 };
|
||||||
private static readonly int[] TargetEarlyDelayLineIndicesTableStereo = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
private static readonly int[] _targetEarlyDelayLineIndicesTableStereo = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||||
private static readonly int[] OutputIndicesTableStereo = new int[4] { 0, 0, 1, 1 };
|
private static readonly int[] _outputIndicesTableStereo = new int[4] { 0, 0, 1, 1 };
|
||||||
private static readonly int[] TargetOutputFeedbackIndicesTableStereo = new int[4] { 2, 0, 3, 1 };
|
private static readonly int[] _targetOutputFeedbackIndicesTableStereo = new int[4] { 2, 0, 3, 1 };
|
||||||
|
|
||||||
private static readonly int[] OutputEarlyIndicesTableQuadraphonic = new int[10] { 0, 0, 1, 1, 0, 1, 2, 2, 3, 3 };
|
private static readonly int[] _outputEarlyIndicesTableQuadraphonic = new int[10] { 0, 0, 1, 1, 0, 1, 2, 2, 3, 3 };
|
||||||
private static readonly int[] TargetEarlyDelayLineIndicesTableQuadraphonic = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
private static readonly int[] _targetEarlyDelayLineIndicesTableQuadraphonic = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||||
private static readonly int[] OutputIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
|
private static readonly int[] _outputIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
|
||||||
private static readonly int[] TargetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
|
private static readonly int[] _targetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
|
||||||
|
|
||||||
private static readonly int[] OutputEarlyIndicesTableSurround = new int[20] { 0, 5, 0, 5, 1, 5, 1, 5, 4, 5, 4, 5, 2, 5, 2, 5, 3, 5, 3, 5 };
|
private static readonly int[] _outputEarlyIndicesTableSurround = new int[20] { 0, 5, 0, 5, 1, 5, 1, 5, 4, 5, 4, 5, 2, 5, 2, 5, 3, 5, 3, 5 };
|
||||||
private static readonly int[] TargetEarlyDelayLineIndicesTableSurround = new int[20] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9 };
|
private static readonly int[] _targetEarlyDelayLineIndicesTableSurround = new int[20] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9 };
|
||||||
private static readonly int[] OutputIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, 4, 5 };
|
private static readonly int[] _outputIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, 4, 5 };
|
||||||
private static readonly int[] TargetOutputFeedbackIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, -1, 3 };
|
private static readonly int[] _targetOutputFeedbackIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, -1, 3 };
|
||||||
|
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
|
@ -82,10 +83,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
outputBuffers,
|
outputBuffers,
|
||||||
inputBuffers,
|
inputBuffers,
|
||||||
sampleCount,
|
sampleCount,
|
||||||
OutputEarlyIndicesTableMono,
|
_outputEarlyIndicesTableMono,
|
||||||
TargetEarlyDelayLineIndicesTableMono,
|
_targetEarlyDelayLineIndicesTableMono,
|
||||||
TargetOutputFeedbackIndicesTableMono,
|
_targetOutputFeedbackIndicesTableMono,
|
||||||
OutputIndicesTableMono);
|
_outputIndicesTableMono);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
@ -95,10 +96,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
outputBuffers,
|
outputBuffers,
|
||||||
inputBuffers,
|
inputBuffers,
|
||||||
sampleCount,
|
sampleCount,
|
||||||
OutputEarlyIndicesTableStereo,
|
_outputEarlyIndicesTableStereo,
|
||||||
TargetEarlyDelayLineIndicesTableStereo,
|
_targetEarlyDelayLineIndicesTableStereo,
|
||||||
TargetOutputFeedbackIndicesTableStereo,
|
_targetOutputFeedbackIndicesTableStereo,
|
||||||
OutputIndicesTableStereo);
|
_outputIndicesTableStereo);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
@ -108,10 +109,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
outputBuffers,
|
outputBuffers,
|
||||||
inputBuffers,
|
inputBuffers,
|
||||||
sampleCount,
|
sampleCount,
|
||||||
OutputEarlyIndicesTableQuadraphonic,
|
_outputEarlyIndicesTableQuadraphonic,
|
||||||
TargetEarlyDelayLineIndicesTableQuadraphonic,
|
_targetEarlyDelayLineIndicesTableQuadraphonic,
|
||||||
TargetOutputFeedbackIndicesTableQuadraphonic,
|
_targetOutputFeedbackIndicesTableQuadraphonic,
|
||||||
OutputIndicesTableQuadraphonic);
|
_outputIndicesTableQuadraphonic);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
@ -121,10 +122,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
outputBuffers,
|
outputBuffers,
|
||||||
inputBuffers,
|
inputBuffers,
|
||||||
sampleCount,
|
sampleCount,
|
||||||
OutputEarlyIndicesTableSurround,
|
_outputEarlyIndicesTableSurround,
|
||||||
TargetEarlyDelayLineIndicesTableSurround,
|
_targetEarlyDelayLineIndicesTableSurround,
|
||||||
TargetOutputFeedbackIndicesTableSurround,
|
_targetOutputFeedbackIndicesTableSurround,
|
||||||
OutputIndicesTableSurround);
|
_outputIndicesTableSurround);
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void ProcessReverbGeneric(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount, ReadOnlySpan<int> outputEarlyIndicesTable, ReadOnlySpan<int> targetEarlyDelayLineIndicesTable, ReadOnlySpan<int> targetOutputFeedbackIndicesTable, ReadOnlySpan<int> outputIndicesTable)
|
private unsafe void ProcessReverbGeneric(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount, ReadOnlySpan<int> outputEarlyIndicesTable, ReadOnlySpan<int> targetEarlyDelayLineIndicesTable, ReadOnlySpan<int> targetOutputFeedbackIndicesTable, ReadOnlySpan<int> outputIndicesTable)
|
||||||
|
@ -143,7 +144,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
|
for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
|
||||||
{
|
{
|
||||||
outputValues.Fill(0);
|
outputValues.Clear();
|
||||||
|
|
||||||
for (int i = 0; i < targetEarlyDelayLineIndicesTable.Length; i++)
|
for (int i = 0; i < targetEarlyDelayLineIndicesTable.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -263,11 +264,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
if (IsEffectEnabled)
|
if (IsEffectEnabled)
|
||||||
{
|
{
|
||||||
if (Parameter.Status == Server.Effect.UsageState.Invalid)
|
if (Parameter.Status == UsageState.Invalid)
|
||||||
{
|
{
|
||||||
state = new ReverbState(ref _parameter, WorkBuffer, IsLongSizePreDelaySupported);
|
state = new ReverbState(ref _parameter, WorkBuffer, IsLongSizePreDelaySupported);
|
||||||
}
|
}
|
||||||
else if (Parameter.Status == Server.Effect.UsageState.New)
|
else if (Parameter.Status == UsageState.New)
|
||||||
{
|
{
|
||||||
state.UpdateParameter(ref _parameter);
|
state.UpdateParameter(ref _parameter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
|
|
||||||
if (!info.DecodingBehaviour.HasFlag(DecodingBehaviour.SkipPitchAndSampleRateConversion))
|
if (!info.DecodingBehaviour.HasFlag(DecodingBehaviour.SkipPitchAndSampleRateConversion))
|
||||||
{
|
{
|
||||||
voiceState.Pitch.AsSpan().Slice(0, pitchMaxLength).CopyTo(tempBuffer);
|
voiceState.Pitch.AsSpan()[..pitchMaxLength].CopyTo(tempBuffer);
|
||||||
tempBufferIndex += pitchMaxLength;
|
tempBufferIndex += pitchMaxLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
voiceState.LoopContext = memoryManager.Read<AdpcmLoopContext>(waveBuffer.Context);
|
voiceState.LoopContext = memoryManager.Read<AdpcmLoopContext>(waveBuffer.Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Span<short> tempSpan = tempBuffer.Slice(tempBufferIndex + y);
|
Span<short> tempSpan = tempBuffer[(tempBufferIndex + y)..];
|
||||||
|
|
||||||
int decodedSampleCount = -1;
|
int decodedSampleCount = -1;
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
decodedSampleCount = PcmHelper.Decode(tempSpan, waveBufferPcmFloat, targetSampleStartOffset, targetSampleEndOffset, info.ChannelIndex, info.ChannelCount);
|
decodedSampleCount = PcmHelper.Decode(tempSpan, waveBufferPcmFloat, targetSampleStartOffset, targetSampleEndOffset, info.ChannelIndex, info.ChannelCount);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Logger.Error?.Print(LogClass.AudioRenderer, $"Unsupported sample format " + info.SampleFormat);
|
Logger.Error?.Print(LogClass.AudioRenderer, "Unsupported sample format " + info.SampleFormat);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Span<int> outputSpanInt = MemoryMarshal.Cast<float, int>(outputBuffer.Slice(i));
|
Span<int> outputSpanInt = MemoryMarshal.Cast<float, int>(outputBuffer[i..]);
|
||||||
|
|
||||||
if (info.DecodingBehaviour.HasFlag(DecodingBehaviour.SkipPitchAndSampleRateConversion))
|
if (info.DecodingBehaviour.HasFlag(DecodingBehaviour.SkipPitchAndSampleRateConversion))
|
||||||
{
|
{
|
||||||
|
@ -231,9 +231,9 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Span<short> tempSpan = tempBuffer.Slice(tempBufferIndex + y);
|
Span<short> tempSpan = tempBuffer[(tempBufferIndex + y)..];
|
||||||
|
|
||||||
tempSpan.Slice(0, sampleCountToDecode - y).Fill(0);
|
tempSpan[..(sampleCountToDecode - y)].Clear();
|
||||||
|
|
||||||
ToFloat(outputBuffer, outputSpanInt, sampleCountToProcess);
|
ToFloat(outputBuffer, outputSpanInt, sampleCountToProcess);
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
|
||||||
{
|
{
|
||||||
public class DelayLine : IDelayLine
|
public class DelayLine : IDelayLine
|
||||||
{
|
{
|
||||||
private float[] _workBuffer;
|
private readonly float[] _workBuffer;
|
||||||
private uint _sampleRate;
|
private readonly uint _sampleRate;
|
||||||
private uint _currentSampleIndex;
|
private uint _currentSampleIndex;
|
||||||
private uint _lastSampleIndex;
|
private uint _lastSampleIndex;
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
|
||||||
{
|
{
|
||||||
public class DelayLine3d : IDelayLine
|
public class DelayLine3d : IDelayLine
|
||||||
{
|
{
|
||||||
private float[] _workBuffer;
|
private readonly float[] _workBuffer;
|
||||||
private uint _sampleRate;
|
private readonly uint _sampleRate;
|
||||||
private uint _currentSampleIndex;
|
private uint _currentSampleIndex;
|
||||||
private uint _lastSampleIndex;
|
private uint _lastSampleIndex;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System.Runtime.CompilerServices;
|
namespace Ryujinx.Audio.Renderer.Dsp.Effect
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Renderer.Dsp.Effect
|
|
||||||
{
|
{
|
||||||
public struct ExponentialMovingAverage
|
public struct ExponentialMovingAverage
|
||||||
{
|
{
|
||||||
|
@ -11,7 +9,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
|
||||||
_mean = mean;
|
_mean = mean;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float Read()
|
public readonly float Read()
|
||||||
{
|
{
|
||||||
return _mean;
|
return _mean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Renderer.Dsp
|
namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
|
@ -39,7 +38,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
{
|
{
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
else if (x <= -5.3f)
|
|
||||||
|
if (x <= -5.3f)
|
||||||
{
|
{
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Numerics;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Renderer.Dsp
|
namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
|
@ -62,7 +61,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
{
|
{
|
||||||
for (int i = 0; i < input.Length; i++)
|
for (int i = 0; i < input.Length; i++)
|
||||||
{
|
{
|
||||||
output[i] = ((int)input[i]) << 16;
|
output[i] = input[i] << 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
using System.Runtime.Intrinsics.X86;
|
using System.Runtime.Intrinsics.X86;
|
||||||
|
@ -11,8 +10,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
public static class ResamplerHelper
|
public static class ResamplerHelper
|
||||||
{
|
{
|
||||||
#region "Default Quality Lookup Tables"
|
#region "Default Quality Lookup Tables"
|
||||||
private static short[] _normalCurveLut0 = new short[]
|
private static readonly short[] _normalCurveLut0 = {
|
||||||
{
|
|
||||||
6600, 19426, 6722, 3, 6479, 19424, 6845, 9, 6359, 19419, 6968, 15, 6239, 19412, 7093, 22,
|
6600, 19426, 6722, 3, 6479, 19424, 6845, 9, 6359, 19419, 6968, 15, 6239, 19412, 7093, 22,
|
||||||
6121, 19403, 7219, 28, 6004, 19391, 7345, 34, 5888, 19377, 7472, 41, 5773, 19361, 7600, 48,
|
6121, 19403, 7219, 28, 6004, 19391, 7345, 34, 5888, 19377, 7472, 41, 5773, 19361, 7600, 48,
|
||||||
5659, 19342, 7728, 55, 5546, 19321, 7857, 62, 5434, 19298, 7987, 69, 5323, 19273, 8118, 77,
|
5659, 19342, 7728, 55, 5546, 19321, 7857, 62, 5434, 19298, 7987, 69, 5323, 19273, 8118, 77,
|
||||||
|
@ -44,11 +42,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
109, 8646, 19148, 4890, 101, 8513, 19183, 4997, 92, 8381, 19215, 5104, 84, 8249, 19245, 5213,
|
109, 8646, 19148, 4890, 101, 8513, 19183, 4997, 92, 8381, 19215, 5104, 84, 8249, 19245, 5213,
|
||||||
77, 8118, 19273, 5323, 69, 7987, 19298, 5434, 62, 7857, 19321, 5546, 55, 7728, 19342, 5659,
|
77, 8118, 19273, 5323, 69, 7987, 19298, 5434, 62, 7857, 19321, 5546, 55, 7728, 19342, 5659,
|
||||||
48, 7600, 19361, 5773, 41, 7472, 19377, 5888, 34, 7345, 19391, 6004, 28, 7219, 19403, 6121,
|
48, 7600, 19361, 5773, 41, 7472, 19377, 5888, 34, 7345, 19391, 6004, 28, 7219, 19403, 6121,
|
||||||
22, 7093, 19412, 6239, 15, 6968, 19419, 6359, 9, 6845, 19424, 6479, 3, 6722, 19426, 6600
|
22, 7093, 19412, 6239, 15, 6968, 19419, 6359, 9, 6845, 19424, 6479, 3, 6722, 19426, 6600,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static short[] _normalCurveLut1 = new short[]
|
private static readonly short[] _normalCurveLut1 = {
|
||||||
{
|
|
||||||
-68, 32639, 69, -5, -200, 32630, 212, -15, -328, 32613, 359, -26, -450, 32586, 512, -36,
|
-68, 32639, 69, -5, -200, 32630, 212, -15, -328, 32613, 359, -26, -450, 32586, 512, -36,
|
||||||
-568, 32551, 669, -47, -680, 32507, 832, -58, -788, 32454, 1000, -69, -891, 32393, 1174, -80,
|
-568, 32551, 669, -47, -680, 32507, 832, -58, -788, 32454, 1000, -69, -891, 32393, 1174, -80,
|
||||||
-990, 32323, 1352, -92, -1084, 32244, 1536, -103, -1173, 32157, 1724, -115, -1258, 32061, 1919, -128,
|
-990, 32323, 1352, -92, -1084, 32244, 1536, -103, -1173, 32157, 1724, -115, -1258, 32061, 1919, -128,
|
||||||
|
@ -80,11 +77,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
-180, 2747, 31593, -1554, -167, 2532, 31723, -1486, -153, 2322, 31844, -1414, -140, 2118, 31956, -1338,
|
-180, 2747, 31593, -1554, -167, 2532, 31723, -1486, -153, 2322, 31844, -1414, -140, 2118, 31956, -1338,
|
||||||
-128, 1919, 32061, -1258, -115, 1724, 32157, -1173, -103, 1536, 32244, -1084, -92, 1352, 32323, -990,
|
-128, 1919, 32061, -1258, -115, 1724, 32157, -1173, -103, 1536, 32244, -1084, -92, 1352, 32323, -990,
|
||||||
-80, 1174, 32393, -891, -69, 1000, 32454, -788, -58, 832, 32507, -680, -47, 669, 32551, -568,
|
-80, 1174, 32393, -891, -69, 1000, 32454, -788, -58, 832, 32507, -680, -47, 669, 32551, -568,
|
||||||
-36, 512, 32586, -450, -26, 359, 32613, -328, -15, 212, 32630, -200, -5, 69, 32639, -68
|
-36, 512, 32586, -450, -26, 359, 32613, -328, -15, 212, 32630, -200, -5, 69, 32639, -68,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static short[] _normalCurveLut2 = new short[]
|
private static readonly short[] _normalCurveLut2 = {
|
||||||
{
|
|
||||||
3195, 26287, 3329, -32, 3064, 26281, 3467, -34, 2936, 26270, 3608, -38, 2811, 26253, 3751, -42,
|
3195, 26287, 3329, -32, 3064, 26281, 3467, -34, 2936, 26270, 3608, -38, 2811, 26253, 3751, -42,
|
||||||
2688, 26230, 3897, -46, 2568, 26202, 4046, -50, 2451, 26169, 4199, -54, 2338, 26130, 4354, -58,
|
2688, 26230, 3897, -46, 2568, 26202, 4046, -50, 2451, 26169, 4199, -54, 2338, 26130, 4354, -58,
|
||||||
2227, 26085, 4512, -63, 2120, 26035, 4673, -67, 2015, 25980, 4837, -72, 1912, 25919, 5004, -76,
|
2227, 26085, 4512, -63, 2120, 26035, 4673, -67, 2015, 25980, 4837, -72, 1912, 25919, 5004, -76,
|
||||||
|
@ -116,13 +112,12 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
-98, 5701, 25621, 1531, -92, 5522, 25704, 1622, -87, 5347, 25780, 1716, -81, 5174, 25852, 1813,
|
-98, 5701, 25621, 1531, -92, 5522, 25704, 1622, -87, 5347, 25780, 1716, -81, 5174, 25852, 1813,
|
||||||
-76, 5004, 25919, 1912, -72, 4837, 25980, 2015, -67, 4673, 26035, 2120, -63, 4512, 26085, 2227,
|
-76, 5004, 25919, 1912, -72, 4837, 25980, 2015, -67, 4673, 26035, 2120, -63, 4512, 26085, 2227,
|
||||||
-58, 4354, 26130, 2338, -54, 4199, 26169, 2451, -50, 4046, 26202, 2568, -46, 3897, 26230, 2688,
|
-58, 4354, 26130, 2338, -54, 4199, 26169, 2451, -50, 4046, 26202, 2568, -46, 3897, 26230, 2688,
|
||||||
-42, 3751, 26253, 2811, -38, 3608, 26270, 2936, -34, 3467, 26281, 3064, -32, 3329, 26287, 3195
|
-42, 3751, 26253, 2811, -38, 3608, 26270, 2936, -34, 3467, 26281, 3064, -32, 3329, 26287, 3195,
|
||||||
};
|
};
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region "High Quality Lookup Tables"
|
#region "High Quality Lookup Tables"
|
||||||
private static short[] _highCurveLut0 = new short[]
|
private static readonly short[] _highCurveLut0 = {
|
||||||
{
|
|
||||||
-582, -23, 8740, 16386, 8833, 8, -590, 0, -573, -54, 8647, 16385, 8925, 40, -598, -1,
|
-582, -23, 8740, 16386, 8833, 8, -590, 0, -573, -54, 8647, 16385, 8925, 40, -598, -1,
|
||||||
-565, -84, 8555, 16383, 9018, 72, -606, -1, -557, -113, 8462, 16379, 9110, 105, -614, -2,
|
-565, -84, 8555, 16383, 9018, 72, -606, -1, -557, -113, 8462, 16379, 9110, 105, -614, -2,
|
||||||
-549, -142, 8370, 16375, 9203, 139, -622, -2, -541, -170, 8277, 16369, 9295, 173, -630, -3,
|
-549, -142, 8370, 16375, 9203, 139, -622, -2, -541, -170, 8277, 16369, 9295, 173, -630, -3,
|
||||||
|
@ -189,8 +184,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
-1, -598, 40, 8925, 16385, 8647, -54, -573, 0, -590, 8, 8833, 16386, 8740, -23, -582,
|
-1, -598, 40, 8925, 16385, 8647, -54, -573, 0, -590, 8, 8833, 16386, 8740, -23, -582,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static short[] _highCurveLut1 = new short[]
|
private static readonly short[] _highCurveLut1 = {
|
||||||
{
|
|
||||||
-12, 47, -134, 32767, 81, -16, 2, 0, -26, 108, -345, 32760, 301, -79, 17, -1,
|
-12, 47, -134, 32767, 81, -16, 2, 0, -26, 108, -345, 32760, 301, -79, 17, -1,
|
||||||
-40, 168, -552, 32745, 526, -144, 32, -2, -53, 226, -753, 32723, 755, -210, 47, -3,
|
-40, 168, -552, 32745, 526, -144, 32, -2, -53, 226, -753, 32723, 755, -210, 47, -3,
|
||||||
-66, 284, -950, 32694, 989, -277, 63, -5, -78, 340, -1143, 32658, 1226, -346, 79, -6,
|
-66, 284, -950, 32694, 989, -277, 63, -5, -78, 340, -1143, 32658, 1226, -346, 79, -6,
|
||||||
|
@ -257,8 +251,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
-1, 17, -79, 301, 32760, -345, 108, -26, 0, 2, -16, 81, 32767, -134, 47, -12,
|
-1, 17, -79, 301, 32760, -345, 108, -26, 0, 2, -16, 81, 32767, -134, 47, -12,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static short[] _highCurveLut2 = new short[]
|
private static readonly short[] _highCurveLut2 = {
|
||||||
{
|
|
||||||
418, -2538, 6118, 24615, 6298, -2563, 417, 0, 420, -2512, 5939, 24611, 6479, -2588, 415, 1,
|
418, -2538, 6118, 24615, 6298, -2563, 417, 0, 420, -2512, 5939, 24611, 6479, -2588, 415, 1,
|
||||||
421, -2485, 5761, 24605, 6662, -2612, 412, 2, 422, -2458, 5585, 24595, 6846, -2635, 409, 3,
|
421, -2485, 5761, 24605, 6662, -2612, 412, 2, 422, -2458, 5585, 24595, 6846, -2635, 409, 3,
|
||||||
423, -2430, 5410, 24582, 7030, -2658, 406, 4, 423, -2402, 5236, 24565, 7216, -2680, 403, 5,
|
423, -2430, 5410, 24582, 7030, -2658, 406, 4, 423, -2402, 5236, 24565, 7216, -2680, 403, 5,
|
||||||
|
@ -326,13 +319,13 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
};
|
};
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static float[] _normalCurveLut0F;
|
private static readonly float[] _normalCurveLut0F;
|
||||||
private static float[] _normalCurveLut1F;
|
private static readonly float[] _normalCurveLut1F;
|
||||||
private static float[] _normalCurveLut2F;
|
private static readonly float[] _normalCurveLut2F;
|
||||||
|
|
||||||
private static float[] _highCurveLut0F;
|
private static readonly float[] _highCurveLut0F;
|
||||||
private static float[] _highCurveLut1F;
|
private static readonly float[] _highCurveLut1F;
|
||||||
private static float[] _highCurveLut2F;
|
private static readonly float[] _highCurveLut2F;
|
||||||
|
|
||||||
static ResamplerHelper()
|
static ResamplerHelper()
|
||||||
{
|
{
|
||||||
|
@ -373,7 +366,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
{
|
{
|
||||||
return _normalCurveLut1F;
|
return _normalCurveLut1F;
|
||||||
}
|
}
|
||||||
else if (ratio > 1.333313f)
|
|
||||||
|
if (ratio > 1.333313f)
|
||||||
{
|
{
|
||||||
return _normalCurveLut0F;
|
return _normalCurveLut0F;
|
||||||
}
|
}
|
||||||
|
@ -514,7 +508,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
{
|
{
|
||||||
return _highCurveLut1F;
|
return _highCurveLut1F;
|
||||||
}
|
}
|
||||||
else if (ratio > 1.333313f)
|
|
||||||
|
if (ratio > 1.333313f)
|
||||||
{
|
{
|
||||||
return _highCurveLut0F;
|
return _highCurveLut0F;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
|
|
||||||
DetectorAverage.AsSpan().Fill(new ExponentialMovingAverage(0.0f));
|
DetectorAverage.AsSpan().Fill(new ExponentialMovingAverage(0.0f));
|
||||||
CompressionGainAverage.AsSpan().Fill(new ExponentialMovingAverage(1.0f));
|
CompressionGainAverage.AsSpan().Fill(new ExponentialMovingAverage(1.0f));
|
||||||
DelayedSampleBufferPosition.AsSpan().Fill(0);
|
DelayedSampleBufferPosition.AsSpan().Clear();
|
||||||
DelayedSampleBuffer.AsSpan().Fill(0.0f);
|
DelayedSampleBuffer.AsSpan().Clear();
|
||||||
|
|
||||||
UpdateParameter(ref parameter);
|
UpdateParameter(ref parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateParameter(ref LimiterParameter parameter) { }
|
public static void UpdateParameter(ref LimiterParameter parameter) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,11 +6,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
{
|
{
|
||||||
public class Reverb3dState
|
public class Reverb3dState
|
||||||
{
|
{
|
||||||
private readonly float[] FdnDelayMinTimes = new float[4] { 5.0f, 6.0f, 13.0f, 14.0f };
|
private readonly float[] _fdnDelayMinTimes = new float[4] { 5.0f, 6.0f, 13.0f, 14.0f };
|
||||||
private readonly float[] FdnDelayMaxTimes = new float[4] { 45.704f, 82.782f, 149.94f, 271.58f };
|
private readonly float[] _fdnDelayMaxTimes = new float[4] { 45.704f, 82.782f, 149.94f, 271.58f };
|
||||||
private readonly float[] DecayDelayMaxTimes1 = new float[4] { 17.0f, 13.0f, 9.0f, 7.0f };
|
private readonly float[] _decayDelayMaxTimes1 = new float[4] { 17.0f, 13.0f, 9.0f, 7.0f };
|
||||||
private readonly float[] DecayDelayMaxTimes2 = new float[4] { 19.0f, 11.0f, 10.0f, 6.0f };
|
private readonly float[] _decayDelayMaxTimes2 = new float[4] { 19.0f, 11.0f, 10.0f, 6.0f };
|
||||||
private readonly float[] EarlyDelayTimes = new float[20] { 0.017136f, 0.059154f, 0.16173f, 0.39019f, 0.42526f, 0.45541f, 0.68974f, 0.74591f, 0.83384f, 0.8595f, 0.0f, 0.075024f, 0.16879f, 0.2999f, 0.33744f, 0.3719f, 0.59901f, 0.71674f, 0.81786f, 0.85166f };
|
private readonly float[] _earlyDelayTimes = new float[20] { 0.017136f, 0.059154f, 0.16173f, 0.39019f, 0.42526f, 0.45541f, 0.68974f, 0.74591f, 0.83384f, 0.8595f, 0.0f, 0.075024f, 0.16879f, 0.2999f, 0.33744f, 0.3719f, 0.59901f, 0.71674f, 0.81786f, 0.85166f };
|
||||||
public readonly float[] EarlyGain = new float[20] { 0.67096f, 0.61027f, 1.0f, 0.35680f, 0.68361f, 0.65978f, 0.51939f, 0.24712f, 0.45945f, 0.45021f, 0.64196f, 0.54879f, 0.92925f, 0.38270f, 0.72867f, 0.69794f, 0.5464f, 0.24563f, 0.45214f, 0.44042f };
|
public readonly float[] EarlyGain = new float[20] { 0.67096f, 0.61027f, 1.0f, 0.35680f, 0.68361f, 0.65978f, 0.51939f, 0.24712f, 0.45945f, 0.45021f, 0.64196f, 0.54879f, 0.92925f, 0.38270f, 0.72867f, 0.69794f, 0.5464f, 0.24563f, 0.45214f, 0.44042f };
|
||||||
|
|
||||||
public IDelayLine[] FdnDelayLines { get; }
|
public IDelayLine[] FdnDelayLines { get; }
|
||||||
|
@ -46,9 +46,9 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
FdnDelayLines[i] = new DelayLine3d(sampleRate, FdnDelayMaxTimes[i]);
|
FdnDelayLines[i] = new DelayLine3d(sampleRate, _fdnDelayMaxTimes[i]);
|
||||||
DecayDelays1[i] = new DecayDelay(new DelayLine3d(sampleRate, DecayDelayMaxTimes1[i]));
|
DecayDelays1[i] = new DecayDelay(new DelayLine3d(sampleRate, _decayDelayMaxTimes1[i]));
|
||||||
DecayDelays2[i] = new DecayDelay(new DelayLine3d(sampleRate, DecayDelayMaxTimes2[i]));
|
DecayDelays2[i] = new DecayDelay(new DelayLine3d(sampleRate, _decayDelayMaxTimes2[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
PreDelayLine = new DelayLine3d(sampleRate, 400);
|
PreDelayLine = new DelayLine3d(sampleRate, 400);
|
||||||
|
@ -63,7 +63,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
|
|
||||||
EarlyDelayTime = new uint[20];
|
EarlyDelayTime = new uint[20];
|
||||||
DryGain = parameter.DryGain;
|
DryGain = parameter.DryGain;
|
||||||
PreviousFeedbackOutputDecayed.AsSpan().Fill(0);
|
PreviousFeedbackOutputDecayed.AsSpan().Clear();
|
||||||
PreviousPreDelayValue = 0;
|
PreviousPreDelayValue = 0;
|
||||||
|
|
||||||
EarlyReflectionsGain = FloatingPointHelper.Pow10(Math.Min(parameter.RoomGain + parameter.ReflectionsGain, 5000.0f) / 2000.0f);
|
EarlyReflectionsGain = FloatingPointHelper.Pow10(Math.Min(parameter.RoomGain + parameter.ReflectionsGain, 5000.0f) / 2000.0f);
|
||||||
|
@ -91,7 +91,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
|
|
||||||
for (int i = 0; i < FdnDelayLines.Length; i++)
|
for (int i = 0; i < FdnDelayLines.Length; i++)
|
||||||
{
|
{
|
||||||
FdnDelayLines[i].SetDelay(FdnDelayMinTimes[i] + (parameter.Density / 100 * (FdnDelayMaxTimes[i] - FdnDelayMinTimes[i])));
|
FdnDelayLines[i].SetDelay(_fdnDelayMinTimes[i] + (parameter.Density / 100 * (_fdnDelayMaxTimes[i] - _fdnDelayMinTimes[i])));
|
||||||
|
|
||||||
uint tempSampleCount = FdnDelayLines[i].CurrentSampleCount + DecayDelays1[i].CurrentSampleCount + DecayDelays2[i].CurrentSampleCount;
|
uint tempSampleCount = FdnDelayLines[i].CurrentSampleCount + DecayDelays1[i].CurrentSampleCount + DecayDelays2[i].CurrentSampleCount;
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
|
|
||||||
for (int i = 0; i < EarlyDelayTime.Length; i++)
|
for (int i = 0; i < EarlyDelayTime.Length; i++)
|
||||||
{
|
{
|
||||||
uint sampleCount = Math.Min(IDelayLine.GetSampleCount(sampleRate, (parameter.ReflectionDelay * 1000.0f) + (EarlyDelayTimes[i] * 1000.0f * ((parameter.ReverbDelayTime * 0.9998f) + 0.02f))), PreDelayLine.SampleCountMax);
|
uint sampleCount = Math.Min(IDelayLine.GetSampleCount(sampleRate, (parameter.ReflectionDelay * 1000.0f) + (_earlyDelayTimes[i] * 1000.0f * ((parameter.ReverbDelayTime * 0.9998f) + 0.02f))), PreDelayLine.SampleCountMax);
|
||||||
EarlyDelayTime[i] = sampleCount;
|
EarlyDelayTime[i] = sampleCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
{
|
{
|
||||||
public class ReverbState
|
public class ReverbState
|
||||||
{
|
{
|
||||||
private static readonly float[] FdnDelayTimes = new float[20]
|
private static readonly float[] _fdnDelayTimes = new float[20]
|
||||||
{
|
{
|
||||||
// Room
|
// Room
|
||||||
53.953247f, 79.192566f, 116.238770f, 130.615295f,
|
53.953247f, 79.192566f, 116.238770f, 130.615295f,
|
||||||
|
@ -21,7 +21,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
53.953247f, 79.192566f, 116.238770f, 170.615295f,
|
53.953247f, 79.192566f, 116.238770f, 170.615295f,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly float[] DecayDelayTimes = new float[20]
|
private static readonly float[] _decayDelayTimes = new float[20]
|
||||||
{
|
{
|
||||||
// Room
|
// Room
|
||||||
7f, 9f, 13f, 17f,
|
7f, 9f, 13f, 17f,
|
||||||
|
@ -35,7 +35,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
7f, 9f, 13f, 17f,
|
7f, 9f, 13f, 17f,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly float[] EarlyDelayTimes = new float[50]
|
private static readonly float[] _earlyDelayTimes = new float[50]
|
||||||
{
|
{
|
||||||
// Room
|
// Room
|
||||||
0.0f, 3.5f, 2.8f, 3.9f, 2.7f, 13.4f, 7.9f, 8.4f, 9.9f, 12.0f,
|
0.0f, 3.5f, 2.8f, 3.9f, 2.7f, 13.4f, 7.9f, 8.4f, 9.9f, 12.0f,
|
||||||
|
@ -46,10 +46,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
// Cathedral
|
// Cathedral
|
||||||
33.1f, 43.3f, 22.8f, 37.9f, 14.9f, 35.3f, 17.9f, 34.2f, 0.0f, 43.3f,
|
33.1f, 43.3f, 22.8f, 37.9f, 14.9f, 35.3f, 17.9f, 34.2f, 0.0f, 43.3f,
|
||||||
// Disabled
|
// Disabled
|
||||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
|
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly float[] EarlyGainBase = new float[50]
|
private static readonly float[] _earlyGainBase = new float[50]
|
||||||
{
|
{
|
||||||
// Room
|
// Room
|
||||||
0.70f, 0.68f, 0.70f, 0.68f, 0.70f, 0.68f, 0.70f, 0.68f, 0.68f, 0.68f,
|
0.70f, 0.68f, 0.70f, 0.68f, 0.70f, 0.68f, 0.70f, 0.68f, 0.68f, 0.68f,
|
||||||
|
@ -60,10 +60,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
// Cathedral
|
// Cathedral
|
||||||
0.93f, 0.92f, 0.87f, 0.86f, 0.94f, 0.81f, 0.80f, 0.77f, 0.76f, 0.65f,
|
0.93f, 0.92f, 0.87f, 0.86f, 0.94f, 0.81f, 0.80f, 0.77f, 0.76f, 0.65f,
|
||||||
// Disabled
|
// Disabled
|
||||||
0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f
|
0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly float[] PreDelayTimes = new float[5]
|
private static readonly float[] _preDelayTimes = new float[5]
|
||||||
{
|
{
|
||||||
// Room
|
// Room
|
||||||
12.5f,
|
12.5f,
|
||||||
|
@ -74,7 +74,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
// Cathedral
|
// Cathedral
|
||||||
50.0f,
|
50.0f,
|
||||||
// Disabled
|
// Disabled
|
||||||
0.0f
|
0.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
public DelayLine[] FdnDelayLines { get; }
|
public DelayLine[] FdnDelayLines { get; }
|
||||||
|
@ -93,14 +93,14 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
|
|
||||||
private const int FixedPointPrecision = 14;
|
private const int FixedPointPrecision = 14;
|
||||||
|
|
||||||
private ReadOnlySpan<float> GetFdnDelayTimesByLateMode(ReverbLateMode lateMode)
|
private static ReadOnlySpan<float> GetFdnDelayTimesByLateMode(ReverbLateMode lateMode)
|
||||||
{
|
{
|
||||||
return FdnDelayTimes.AsSpan((int)lateMode * 4, 4);
|
return _fdnDelayTimes.AsSpan((int)lateMode * 4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReadOnlySpan<float> GetDecayDelayTimesByLateMode(ReverbLateMode lateMode)
|
private static ReadOnlySpan<float> GetDecayDelayTimesByLateMode(ReverbLateMode lateMode)
|
||||||
{
|
{
|
||||||
return DecayDelayTimes.AsSpan((int)lateMode * 4, 4);
|
return _decayDelayTimes.AsSpan((int)lateMode * 4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReverbState(ref ReverbParameter parameter, ulong workBuffer, bool isLongSizePreDelaySupported)
|
public ReverbState(ref ReverbParameter parameter, ulong workBuffer, bool isLongSizePreDelaySupported)
|
||||||
|
@ -148,8 +148,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
EarlyDelayTime[i] = Math.Min(IDelayLine.GetSampleCount(sampleRate, EarlyDelayTimes[i] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax) + 1;
|
EarlyDelayTime[i] = Math.Min(IDelayLine.GetSampleCount(sampleRate, _earlyDelayTimes[i] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax) + 1;
|
||||||
EarlyGain[i] = EarlyGainBase[i] * earlyGain;
|
EarlyGain[i] = _earlyGainBase[i] * earlyGain;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameter.ChannelCount == 2)
|
if (parameter.ChannelCount == 2)
|
||||||
|
@ -158,7 +158,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||||
EarlyGain[5] = EarlyGain[5] * 0.5f;
|
EarlyGain[5] = EarlyGain[5] * 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
PreDelayLineDelayTime = Math.Min(IDelayLine.GetSampleCount(sampleRate, PreDelayTimes[(int)parameter.EarlyMode] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax);
|
PreDelayLineDelayTime = Math.Min(IDelayLine.GetSampleCount(sampleRate, _preDelayTimes[(int)parameter.EarlyMode] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax);
|
||||||
|
|
||||||
ReadOnlySpan<float> fdnDelayTimes = GetFdnDelayTimesByLateMode(parameter.LateMode);
|
ReadOnlySpan<float> fdnDelayTimes = GetFdnDelayTimesByLateMode(parameter.LateMode);
|
||||||
ReadOnlySpan<float> decayDelayTimes = GetDecayDelayTimesByLateMode(parameter.LateMode);
|
ReadOnlySpan<float> decayDelayTimes = GetDecayDelayTimesByLateMode(parameter.LateMode);
|
||||||
|
|
|
@ -13,11 +13,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
private const int FilterBankLength = 20;
|
private const int FilterBankLength = 20;
|
||||||
// Bank0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
// Bank0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
private const int Bank0CenterIndex = 9;
|
private const int Bank0CenterIndex = 9;
|
||||||
private static readonly Array20<float> Bank1 = PrecomputeFilterBank(1.0f / 6.0f);
|
private static readonly Array20<float> _bank1 = PrecomputeFilterBank(1.0f / 6.0f);
|
||||||
private static readonly Array20<float> Bank2 = PrecomputeFilterBank(2.0f / 6.0f);
|
private static readonly Array20<float> _bank2 = PrecomputeFilterBank(2.0f / 6.0f);
|
||||||
private static readonly Array20<float> Bank3 = PrecomputeFilterBank(3.0f / 6.0f);
|
private static readonly Array20<float> _bank3 = PrecomputeFilterBank(3.0f / 6.0f);
|
||||||
private static readonly Array20<float> Bank4 = PrecomputeFilterBank(4.0f / 6.0f);
|
private static readonly Array20<float> _bank4 = PrecomputeFilterBank(4.0f / 6.0f);
|
||||||
private static readonly Array20<float> Bank5 = PrecomputeFilterBank(5.0f / 6.0f);
|
private static readonly Array20<float> _bank5 = PrecomputeFilterBank(5.0f / 6.0f);
|
||||||
|
|
||||||
private static Array20<float> PrecomputeFilterBank(float offset)
|
private static Array20<float> PrecomputeFilterBank(float offset)
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
return A0 + A1 * MathF.Cos(2 * MathF.PI * x) + A2 * MathF.Cos(4 * MathF.PI * x);
|
return A0 + A1 * MathF.Cos(2 * MathF.PI * x) + A2 * MathF.Cos(4 * MathF.PI * x);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array20<float> result = new Array20<float>();
|
Array20<float> result = new();
|
||||||
|
|
||||||
for (int i = 0; i < FilterBankLength; i++)
|
for (int i = 0; i < FilterBankLength; i++)
|
||||||
{
|
{
|
||||||
|
@ -58,10 +58,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
{
|
{
|
||||||
state.Scale = inputSampleCount switch
|
state.Scale = inputSampleCount switch
|
||||||
{
|
{
|
||||||
40 => 6.0f,
|
40 => 6.0f,
|
||||||
80 => 3.0f,
|
80 => 3.0f,
|
||||||
160 => 1.5f,
|
160 => 1.5f,
|
||||||
_ => throw new ArgumentOutOfRangeException()
|
_ => throw new ArgumentOutOfRangeException(nameof(inputSampleCount), inputSampleCount, null),
|
||||||
};
|
};
|
||||||
state.Initialized = true;
|
state.Initialized = true;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
void NextInput(ref UpsamplerBufferState state, float input)
|
void NextInput(ref UpsamplerBufferState state, float input)
|
||||||
{
|
{
|
||||||
state.History.AsSpan().Slice(1).CopyTo(state.History.AsSpan());
|
state.History.AsSpan()[1..].CopyTo(state.History.AsSpan());
|
||||||
state.History[HistoryLength - 1] = input;
|
state.History[HistoryLength - 1] = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,19 +123,19 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
outputBuffer[i] = state.History[Bank0CenterIndex];
|
outputBuffer[i] = state.History[Bank0CenterIndex];
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
outputBuffer[i] = DoFilterBank(ref state, Bank1);
|
outputBuffer[i] = DoFilterBank(ref state, _bank1);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
outputBuffer[i] = DoFilterBank(ref state, Bank2);
|
outputBuffer[i] = DoFilterBank(ref state, _bank2);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
outputBuffer[i] = DoFilterBank(ref state, Bank3);
|
outputBuffer[i] = DoFilterBank(ref state, _bank3);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
outputBuffer[i] = DoFilterBank(ref state, Bank4);
|
outputBuffer[i] = DoFilterBank(ref state, _bank4);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
outputBuffer[i] = DoFilterBank(ref state, Bank5);
|
outputBuffer[i] = DoFilterBank(ref state, _bank5);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,10 +152,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
outputBuffer[i] = state.History[Bank0CenterIndex];
|
outputBuffer[i] = state.History[Bank0CenterIndex];
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
outputBuffer[i] = DoFilterBank(ref state, Bank2);
|
outputBuffer[i] = DoFilterBank(ref state, _bank2);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
outputBuffer[i] = DoFilterBank(ref state, Bank4);
|
outputBuffer[i] = DoFilterBank(ref state, _bank4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,11 +173,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
outputBuffer[i] = state.History[Bank0CenterIndex];
|
outputBuffer[i] = state.History[Bank0CenterIndex];
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
outputBuffer[i] = DoFilterBank(ref state, Bank4);
|
outputBuffer[i] = DoFilterBank(ref state, _bank4);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
NextInput(ref state, inputBuffer[inputBufferIndex++]);
|
NextInput(ref state, inputBuffer[inputBufferIndex++]);
|
||||||
outputBuffer[i] = DoFilterBank(ref state, Bank2);
|
outputBuffer[i] = DoFilterBank(ref state, _bank2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException(nameof(state), state.Scale, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/unused
|
/// Reserved/unused
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private byte _reserved;
|
private readonly byte _reserved;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The target rendering device.
|
/// The target rendering device.
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private byte _reserved;
|
private readonly byte _reserved;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Biquad filter numerator (b0, b1, b2).
|
/// Biquad filter numerator (b0, b1, b2).
|
||||||
|
|
|
@ -98,7 +98,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// Check if the <see cref="ChannelCount"/> is valid.
|
/// Check if the <see cref="ChannelCount"/> is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the <see cref="ChannelCount"/> is valid.</returns>
|
/// <returns>Returns true if the <see cref="ChannelCount"/> is valid.</returns>
|
||||||
public bool IsChannelCountValid()
|
public readonly bool IsChannelCountValid()
|
||||||
{
|
{
|
||||||
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
|
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// Check if the <see cref="ChannelCountMax"/> is valid.
|
/// Check if the <see cref="ChannelCountMax"/> is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the <see cref="ChannelCountMax"/> is valid.</returns>
|
/// <returns>Returns true if the <see cref="ChannelCountMax"/> is valid.</returns>
|
||||||
public bool IsChannelCountMaxValid()
|
public readonly bool IsChannelCountMaxValid()
|
||||||
{
|
{
|
||||||
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
|
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// Check if the <see cref="ChannelCount"/> is valid.
|
/// Check if the <see cref="ChannelCount"/> is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the <see cref="ChannelCount"/> is valid.</returns>
|
/// <returns>Returns true if the <see cref="ChannelCount"/> is valid.</returns>
|
||||||
public bool IsChannelCountValid()
|
public readonly bool IsChannelCountValid()
|
||||||
{
|
{
|
||||||
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
|
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// Check if the <see cref="ChannelCountMax"/> is valid.
|
/// Check if the <see cref="ChannelCountMax"/> is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the <see cref="ChannelCountMax"/> is valid.</returns>
|
/// <returns>Returns true if the <see cref="ChannelCountMax"/> is valid.</returns>
|
||||||
public bool IsChannelCountMaxValid()
|
public readonly bool IsChannelCountMaxValid()
|
||||||
{
|
{
|
||||||
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
|
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,13 +115,13 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private byte _reserved;
|
private readonly byte _reserved;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the <see cref="ChannelCount"/> is valid.
|
/// Check if the <see cref="ChannelCount"/> is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the <see cref="ChannelCount"/> is valid.</returns>
|
/// <returns>Returns true if the <see cref="ChannelCount"/> is valid.</returns>
|
||||||
public bool IsChannelCountValid()
|
public readonly bool IsChannelCountValid()
|
||||||
{
|
{
|
||||||
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
|
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// Check if the <see cref="ChannelCountMax"/> is valid.
|
/// Check if the <see cref="ChannelCountMax"/> is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the <see cref="ChannelCountMax"/> is valid.</returns>
|
/// <returns>Returns true if the <see cref="ChannelCountMax"/> is valid.</returns>
|
||||||
public bool IsChannelCountMaxValid()
|
public readonly bool IsChannelCountMaxValid()
|
||||||
{
|
{
|
||||||
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
|
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
InputMax.AsSpan().Fill(0.0f);
|
InputMax.AsSpan().Clear();
|
||||||
CompressionGainMin.AsSpan().Fill(1.0f);
|
CompressionGainMin.AsSpan().Fill(1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/unused.
|
/// Reserved/unused.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private uint _reserved;
|
private readonly uint _reserved;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The target sample rate.
|
/// The target sample rate.
|
||||||
|
@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// Check if the <see cref="ChannelCount"/> is valid.
|
/// Check if the <see cref="ChannelCount"/> is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the <see cref="ChannelCount"/> is valid.</returns>
|
/// <returns>Returns true if the <see cref="ChannelCount"/> is valid.</returns>
|
||||||
public bool IsChannelCountValid()
|
public readonly bool IsChannelCountValid()
|
||||||
{
|
{
|
||||||
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
|
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// Check if the <see cref="ChannelCountMax"/> is valid.
|
/// Check if the <see cref="ChannelCountMax"/> is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the <see cref="ChannelCountMax"/> is valid.</returns>
|
/// <returns>Returns true if the <see cref="ChannelCountMax"/> is valid.</returns>
|
||||||
public bool IsChannelCountMaxValid()
|
public readonly bool IsChannelCountMaxValid()
|
||||||
{
|
{
|
||||||
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
|
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// Check if the <see cref="ChannelCount"/> is valid.
|
/// Check if the <see cref="ChannelCount"/> is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the <see cref="ChannelCount"/> is valid.</returns>
|
/// <returns>Returns true if the <see cref="ChannelCount"/> is valid.</returns>
|
||||||
public bool IsChannelCountValid()
|
public readonly bool IsChannelCountValid()
|
||||||
{
|
{
|
||||||
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
|
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
|
||||||
/// Check if the <see cref="ChannelCountMax"/> is valid.
|
/// Check if the <see cref="ChannelCountMax"/> is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the <see cref="ChannelCountMax"/> is valid.</returns>
|
/// <returns>Returns true if the <see cref="ChannelCountMax"/> is valid.</returns>
|
||||||
public bool IsChannelCountMaxValid()
|
public readonly bool IsChannelCountMaxValid()
|
||||||
{
|
{
|
||||||
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
|
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private byte _reserved1;
|
private readonly byte _reserved1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The target mix id of the effect.
|
/// The target mix id of the effect.
|
||||||
|
@ -58,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private uint _reserved2;
|
private readonly uint _reserved2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specific data storage.
|
/// Specific data storage.
|
||||||
|
@ -70,19 +70,19 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
|
|
||||||
public Span<byte> SpecificData => SpanHelpers.AsSpan<SpecificDataStruct, byte>(ref _specificDataStart);
|
public Span<byte> SpecificData => SpanHelpers.AsSpan<SpecificDataStruct, byte>(ref _specificDataStart);
|
||||||
|
|
||||||
EffectType IEffectInParameter.Type => Type;
|
readonly EffectType IEffectInParameter.Type => Type;
|
||||||
|
|
||||||
bool IEffectInParameter.IsNew => IsNew;
|
readonly bool IEffectInParameter.IsNew => IsNew;
|
||||||
|
|
||||||
bool IEffectInParameter.IsEnabled => IsEnabled;
|
readonly bool IEffectInParameter.IsEnabled => IsEnabled;
|
||||||
|
|
||||||
int IEffectInParameter.MixId => MixId;
|
readonly int IEffectInParameter.MixId => MixId;
|
||||||
|
|
||||||
ulong IEffectInParameter.BufferBase => BufferBase;
|
readonly ulong IEffectInParameter.BufferBase => BufferBase;
|
||||||
|
|
||||||
ulong IEffectInParameter.BufferSize => BufferSize;
|
readonly ulong IEffectInParameter.BufferSize => BufferSize;
|
||||||
|
|
||||||
uint IEffectInParameter.ProcessingOrder => ProcessingOrder;
|
readonly uint IEffectInParameter.ProcessingOrder => ProcessingOrder;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the given channel count is valid.
|
/// Check if the given channel count is valid.
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private byte _reserved1;
|
private readonly byte _reserved1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The target mix id of the effect.
|
/// The target mix id of the effect.
|
||||||
|
@ -58,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private uint _reserved2;
|
private readonly uint _reserved2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specific data storage.
|
/// Specific data storage.
|
||||||
|
@ -70,19 +70,19 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
|
|
||||||
public Span<byte> SpecificData => SpanHelpers.AsSpan<SpecificDataStruct, byte>(ref _specificDataStart);
|
public Span<byte> SpecificData => SpanHelpers.AsSpan<SpecificDataStruct, byte>(ref _specificDataStart);
|
||||||
|
|
||||||
EffectType IEffectInParameter.Type => Type;
|
readonly EffectType IEffectInParameter.Type => Type;
|
||||||
|
|
||||||
bool IEffectInParameter.IsNew => IsNew;
|
readonly bool IEffectInParameter.IsNew => IsNew;
|
||||||
|
|
||||||
bool IEffectInParameter.IsEnabled => IsEnabled;
|
readonly bool IEffectInParameter.IsEnabled => IsEnabled;
|
||||||
|
|
||||||
int IEffectInParameter.MixId => MixId;
|
readonly int IEffectInParameter.MixId => MixId;
|
||||||
|
|
||||||
ulong IEffectInParameter.BufferBase => BufferBase;
|
readonly ulong IEffectInParameter.BufferBase => BufferBase;
|
||||||
|
|
||||||
ulong IEffectInParameter.BufferSize => BufferSize;
|
readonly ulong IEffectInParameter.BufferSize => BufferSize;
|
||||||
|
|
||||||
uint IEffectInParameter.ProcessingOrder => ProcessingOrder;
|
readonly uint IEffectInParameter.ProcessingOrder => ProcessingOrder;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the given channel count is valid.
|
/// Check if the given channel count is valid.
|
||||||
|
|
|
@ -18,6 +18,6 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private unsafe fixed byte _reserved[15];
|
private unsafe fixed byte _reserved[15];
|
||||||
|
|
||||||
EffectState IEffectOutStatus.State { get => State; set => State = value; }
|
EffectState IEffectOutStatus.State { readonly get => State; set => State = value; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,6 +23,6 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EffectResultState ResultState;
|
public EffectResultState ResultState;
|
||||||
|
|
||||||
EffectState IEffectOutStatus.State { get => State; set => State = value; }
|
EffectState IEffectOutStatus.State { readonly get => State; set => State = value; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,6 +13,6 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The effect is disabled.
|
/// The effect is disabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Disabled = 4
|
Disabled = 4,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -41,7 +41,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ushort _reserved1;
|
private readonly ushort _reserved1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The id of the mix.
|
/// The id of the mix.
|
||||||
|
@ -61,7 +61,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ulong _reserved2;
|
private readonly ulong _reserved2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Mix buffer volumes storage.
|
/// Mix buffer volumes storage.
|
||||||
|
@ -81,7 +81,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private uint _reserved3;
|
private readonly uint _reserved3;
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 4 * Constants.MixBufferCountMax * Constants.MixBufferCountMax, Pack = 1)]
|
[StructLayout(LayoutKind.Sequential, Size = 4 * Constants.MixBufferCountMax * Constants.MixBufferCountMax, Pack = 1)]
|
||||||
private struct MixVolumeArray { }
|
private struct MixVolumeArray { }
|
||||||
|
|
|
@ -16,6 +16,6 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/Unused.
|
/// Reserved/Unused.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ulong _reserved;
|
private readonly ulong _reserved;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@ using Ryujinx.Audio.Common;
|
||||||
using Ryujinx.Audio.Renderer.Common;
|
using Ryujinx.Audio.Renderer.Common;
|
||||||
using Ryujinx.Common.Memory;
|
using Ryujinx.Common.Memory;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using CpuAddress = System.UInt64;
|
using CpuAddress = System.UInt64;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Renderer.Parameter.Sink
|
namespace Ryujinx.Audio.Renderer.Parameter.Sink
|
||||||
|
@ -41,7 +40,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Sink
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The target <see cref="SampleFormat"/>.
|
/// The target <see cref="SampleFormat"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>Only <see cref="SampleFormat.PcmInt16"/> is supported.</remarks>
|
/// <remarks>Only <see cref="Audio.Common.SampleFormat.PcmInt16"/> is supported.</remarks>
|
||||||
public SampleFormat SampleFormat;
|
public SampleFormat SampleFormat;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -57,6 +56,6 @@ namespace Ryujinx.Audio.Renderer.Parameter.Sink
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ushort _reserved2;
|
private readonly ushort _reserved2;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,7 +19,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Sink
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private byte _padding;
|
private readonly byte _padding;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The total count of channels to output to the device.
|
/// The total count of channels to output to the device.
|
||||||
|
@ -34,7 +34,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Sink
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private byte _reserved;
|
private readonly byte _reserved;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set to true if the user controls Surround to Stereo downmixing coefficients.
|
/// Set to true if the user controls Surround to Stereo downmixing coefficients.
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ushort _reserved1;
|
private readonly ushort _reserved1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The node id of the sink.
|
/// The node id of the sink.
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private uint _padding;
|
private readonly uint _padding;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/padding.
|
/// Reserved/padding.
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// Check if the magic is valid.
|
/// Check if the magic is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the magic is valid.</returns>
|
/// <returns>Returns true if the magic is valid.</returns>
|
||||||
public bool IsMagicValid()
|
public readonly bool IsMagicValid()
|
||||||
{
|
{
|
||||||
return Magic == ValidMagic;
|
return Magic == ValidMagic;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// Check if the magic is valid.
|
/// Check if the magic is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the magic is valid.</returns>
|
/// <returns>Returns true if the magic is valid.</returns>
|
||||||
public bool IsMagicValid()
|
public readonly bool IsMagicValid()
|
||||||
{
|
{
|
||||||
return Magic == ValidMagic;
|
return Magic == ValidMagic;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// Check if the magic is valid.
|
/// Check if the magic is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the magic is valid.</returns>
|
/// <returns>Returns true if the magic is valid.</returns>
|
||||||
public bool IsMagicValid()
|
public readonly bool IsMagicValid()
|
||||||
{
|
{
|
||||||
return Magic == ValidMagic;
|
return Magic == ValidMagic;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/unused.
|
/// Reserved/unused.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private uint _reserved1;
|
private readonly uint _reserved1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// User state address required by the data source.
|
/// User state address required by the data source.
|
||||||
|
@ -143,7 +143,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/unused.
|
/// Reserved/unused.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ushort _reserved2;
|
private readonly ushort _reserved2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Change the behaviour of the voice.
|
/// Change the behaviour of the voice.
|
||||||
|
@ -222,7 +222,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reserved/unused.
|
/// Reserved/unused.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private byte _reserved;
|
private readonly byte _reserved;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If set to anything other than 0, specifies how many times to loop the wavebuffer.
|
/// If set to anything other than 0, specifies how many times to loop the wavebuffer.
|
||||||
|
@ -260,7 +260,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <typeparam name="T">The PCM sample type</typeparam>
|
/// <typeparam name="T">The PCM sample type</typeparam>
|
||||||
/// <returns>Returns true if the sample offset are in range of the size.</returns>
|
/// <returns>Returns true if the sample offset are in range of the size.</returns>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private bool IsSampleOffsetInRangeForPcm<T>() where T : unmanaged
|
private readonly bool IsSampleOffsetInRangeForPcm<T>() where T : unmanaged
|
||||||
{
|
{
|
||||||
uint dataTypeSize = (uint)Unsafe.SizeOf<T>();
|
uint dataTypeSize = (uint)Unsafe.SizeOf<T>();
|
||||||
|
|
||||||
|
@ -273,27 +273,15 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="format">The target <see cref="SampleFormat"/></param>
|
/// <param name="format">The target <see cref="SampleFormat"/></param>
|
||||||
/// <returns>Returns true if the sample offset are in range of the size.</returns>
|
/// <returns>Returns true if the sample offset are in range of the size.</returns>
|
||||||
public bool IsSampleOffsetValid(SampleFormat format)
|
public readonly bool IsSampleOffsetValid(SampleFormat format)
|
||||||
{
|
{
|
||||||
bool result;
|
return format switch
|
||||||
|
|
||||||
switch (format)
|
|
||||||
{
|
{
|
||||||
case SampleFormat.PcmInt16:
|
SampleFormat.PcmInt16 => IsSampleOffsetInRangeForPcm<ushort>(),
|
||||||
result = IsSampleOffsetInRangeForPcm<ushort>();
|
SampleFormat.PcmFloat => IsSampleOffsetInRangeForPcm<float>(),
|
||||||
break;
|
SampleFormat.Adpcm => AdpcmHelper.GetAdpcmDataSize((int)StartSampleOffset) <= Size && AdpcmHelper.GetAdpcmDataSize((int)EndSampleOffset) <= Size,
|
||||||
case SampleFormat.PcmFloat:
|
_ => throw new NotImplementedException($"{format} not implemented!"),
|
||||||
result = IsSampleOffsetInRangeForPcm<float>();
|
};
|
||||||
break;
|
|
||||||
case SampleFormat.Adpcm:
|
|
||||||
result = AdpcmHelper.GetAdpcmDataSize((int)StartSampleOffset) <= Size &&
|
|
||||||
AdpcmHelper.GetAdpcmDataSize((int)EndSampleOffset) <= Size;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{format} not implemented!");
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +304,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Skip pitch and Sample Rate Conversion (SRC).
|
/// Skip pitch and Sample Rate Conversion (SRC).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
SkipPitchAndSampleRateConversion = 2
|
SkipPitchAndSampleRateConversion = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -338,7 +326,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resample interpolating 1 samples per output sample.
|
/// Resample interpolating 1 samples per output sample.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Low
|
Low,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,7 +19,6 @@ using System;
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
using CpuAddress = System.UInt64;
|
using CpuAddress = System.UInt64;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Renderer.Server
|
namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
@ -30,19 +29,21 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
private AudioRendererRenderingDevice _renderingDevice;
|
private AudioRendererRenderingDevice _renderingDevice;
|
||||||
private AudioRendererExecutionMode _executionMode;
|
private AudioRendererExecutionMode _executionMode;
|
||||||
private IWritableEvent _systemEvent;
|
private readonly IWritableEvent _systemEvent;
|
||||||
private MemoryPoolState _dspMemoryPoolState;
|
private MemoryPoolState _dspMemoryPoolState;
|
||||||
private VoiceContext _voiceContext;
|
private readonly VoiceContext _voiceContext;
|
||||||
private MixContext _mixContext;
|
private readonly MixContext _mixContext;
|
||||||
private SinkContext _sinkContext;
|
private readonly SinkContext _sinkContext;
|
||||||
private SplitterContext _splitterContext;
|
private readonly SplitterContext _splitterContext;
|
||||||
private EffectContext _effectContext;
|
private readonly EffectContext _effectContext;
|
||||||
private PerformanceManager _performanceManager;
|
private PerformanceManager _performanceManager;
|
||||||
private UpsamplerManager _upsamplerManager;
|
private UpsamplerManager _upsamplerManager;
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
private BehaviourContext _behaviourContext;
|
private BehaviourContext _behaviourContext;
|
||||||
|
#pragma warning disable IDE0052 // Remove unread private member
|
||||||
private ulong _totalElapsedTicksUpdating;
|
private ulong _totalElapsedTicksUpdating;
|
||||||
private ulong _totalElapsedTicks;
|
private ulong _totalElapsedTicks;
|
||||||
|
#pragma warning restore IDE0052
|
||||||
private int _sessionId;
|
private int _sessionId;
|
||||||
private Memory<MemoryPoolState> _memoryPools;
|
private Memory<MemoryPoolState> _memoryPools;
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
private ulong _elapsedFrameCount;
|
private ulong _elapsedFrameCount;
|
||||||
private ulong _renderingStartTick;
|
private ulong _renderingStartTick;
|
||||||
|
|
||||||
private AudioRendererManager _manager;
|
private readonly AudioRendererManager _manager;
|
||||||
|
|
||||||
private int _disposeState;
|
private int _disposeState;
|
||||||
|
|
||||||
|
@ -143,12 +144,12 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
WorkBufferAllocator workBufferAllocator;
|
WorkBufferAllocator workBufferAllocator;
|
||||||
|
|
||||||
workBufferMemory.Span.Fill(0);
|
workBufferMemory.Span.Clear();
|
||||||
_workBufferMemoryPin = workBufferMemory.Pin();
|
_workBufferMemoryPin = workBufferMemory.Pin();
|
||||||
|
|
||||||
workBufferAllocator = new WorkBufferAllocator(workBufferMemory);
|
workBufferAllocator = new WorkBufferAllocator(workBufferMemory);
|
||||||
|
|
||||||
PoolMapper poolMapper = new PoolMapper(processHandle, false);
|
PoolMapper poolMapper = new(processHandle, false);
|
||||||
poolMapper.InitializeSystemPool(ref _dspMemoryPoolState, workBuffer, workBufferSize);
|
poolMapper.InitializeSystemPool(ref _dspMemoryPoolState, workBuffer, workBufferSize);
|
||||||
|
|
||||||
_mixBuffer = workBufferAllocator.Allocate<float>(_sampleCount * (_voiceChannelCountMax + _mixBufferCount), 0x10);
|
_mixBuffer = workBufferAllocator.Allocate<float>(_sampleCount * (_voiceChannelCountMax + _mixBufferCount), 0x10);
|
||||||
|
@ -244,9 +245,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
foreach (ref MixState mix in mixes.Span)
|
foreach (ref MixState mix in mixes.Span)
|
||||||
{
|
{
|
||||||
mix = new MixState(effectProcessingOrderArray.Slice(0, (int)parameter.EffectCount), ref _behaviourContext);
|
mix = new MixState(effectProcessingOrderArray[..(int)parameter.EffectCount], ref _behaviourContext);
|
||||||
|
|
||||||
effectProcessingOrderArray = effectProcessingOrderArray.Slice((int)parameter.EffectCount);
|
effectProcessingOrderArray = effectProcessingOrderArray[(int)parameter.EffectCount..];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,26 +342,15 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
_elapsedFrameCount = 0;
|
_elapsedFrameCount = 0;
|
||||||
_voiceDropParameter = 1.0f;
|
_voiceDropParameter = 1.0f;
|
||||||
|
|
||||||
switch (_behaviourContext.GetCommandProcessingTimeEstimatorVersion())
|
_commandProcessingTimeEstimator = _behaviourContext.GetCommandProcessingTimeEstimatorVersion() switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => new CommandProcessingTimeEstimatorVersion1(_sampleCount, _mixBufferCount),
|
||||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion1(_sampleCount, _mixBufferCount);
|
2 => new CommandProcessingTimeEstimatorVersion2(_sampleCount, _mixBufferCount),
|
||||||
break;
|
3 => new CommandProcessingTimeEstimatorVersion3(_sampleCount, _mixBufferCount),
|
||||||
case 2:
|
4 => new CommandProcessingTimeEstimatorVersion4(_sampleCount, _mixBufferCount),
|
||||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion2(_sampleCount, _mixBufferCount);
|
5 => new CommandProcessingTimeEstimatorVersion5(_sampleCount, _mixBufferCount),
|
||||||
break;
|
_ => throw new NotImplementedException($"Unsupported processing time estimator version {_behaviourContext.GetCommandProcessingTimeEstimatorVersion()}."),
|
||||||
case 3:
|
};
|
||||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion3(_sampleCount, _mixBufferCount);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion4(_sampleCount, _mixBufferCount);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion5(_sampleCount, _mixBufferCount);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"Unsupported processing time estimator version {_behaviourContext.GetCommandProcessingTimeEstimatorVersion()}.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
@ -402,9 +392,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
ulong updateStartTicks = GetSystemTicks();
|
ulong updateStartTicks = GetSystemTicks();
|
||||||
|
|
||||||
output.Span.Fill(0);
|
output.Span.Clear();
|
||||||
|
|
||||||
StateUpdater stateUpdater = new StateUpdater(input, output, _processHandle, _behaviourContext);
|
StateUpdater stateUpdater = new(input, output, _processHandle, _behaviourContext);
|
||||||
|
|
||||||
ResultCode result;
|
ResultCode result;
|
||||||
|
|
||||||
|
@ -609,9 +599,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
_renderingStartTick = 0;
|
_renderingStartTick = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandBuffer commandBuffer = new CommandBuffer(commandList, _commandProcessingTimeEstimator);
|
CommandBuffer commandBuffer = new(commandList, _commandProcessingTimeEstimator);
|
||||||
|
|
||||||
CommandGenerator commandGenerator = new CommandGenerator(commandBuffer, GetContext(), _voiceContext, _mixContext, _effectContext, _sinkContext, _splitterContext, _performanceManager);
|
CommandGenerator commandGenerator = new(commandBuffer, GetContext(), _voiceContext, _mixContext, _effectContext, _sinkContext, _splitterContext, _performanceManager);
|
||||||
|
|
||||||
_voiceContext.Sort();
|
_voiceContext.Sort();
|
||||||
commandGenerator.GenerateVoices();
|
commandGenerator.GenerateVoices();
|
||||||
|
@ -731,7 +721,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
DepopBuffer = _depopBuffer,
|
DepopBuffer = _depopBuffer,
|
||||||
MixBufferCount = GetMixBufferCount(),
|
MixBufferCount = GetMixBufferCount(),
|
||||||
SessionId = _sessionId,
|
SessionId = _sessionId,
|
||||||
UpsamplerManager = _upsamplerManager
|
UpsamplerManager = _upsamplerManager,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,7 +732,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public static ulong GetWorkBufferSize(ref AudioRendererConfiguration parameter)
|
public static ulong GetWorkBufferSize(ref AudioRendererConfiguration parameter)
|
||||||
{
|
{
|
||||||
BehaviourContext behaviourContext = new BehaviourContext();
|
BehaviourContext behaviourContext = new();
|
||||||
|
|
||||||
behaviourContext.SetUserRevision(parameter.Revision);
|
behaviourContext.SetUserRevision(parameter.Revision);
|
||||||
|
|
||||||
|
@ -813,6 +803,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@ -828,7 +820,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
Stop();
|
Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolMapper mapper = new PoolMapper(_processHandle, false);
|
PoolMapper mapper = new(_processHandle, false);
|
||||||
mapper.Unmap(ref _dspMemoryPoolState);
|
mapper.Unmap(ref _dspMemoryPoolState);
|
||||||
|
|
||||||
PoolMapper.ClearUsageState(_memoryPools);
|
PoolMapper.ClearUsageState(_memoryPools);
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The session ids allocation table.
|
/// The session ids allocation table.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int[] _sessionIds;
|
private readonly int[] _sessionIds;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The events linked to each session.
|
/// The events linked to each session.
|
||||||
|
@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="AudioRenderSystem"/> sessions instances.
|
/// The <see cref="AudioRenderSystem"/> sessions instances.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AudioRenderSystem[] _sessions;
|
private readonly AudioRenderSystem[] _sessions;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The count of active sessions.
|
/// The count of active sessions.
|
||||||
|
@ -186,7 +186,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
_workerThread = new Thread(SendCommands)
|
_workerThread = new Thread(SendCommands)
|
||||||
{
|
{
|
||||||
Name = "AudioRendererManager.Worker"
|
Name = "AudioRendererManager.Worker",
|
||||||
};
|
};
|
||||||
|
|
||||||
_workerThread.Start();
|
_workerThread.Start();
|
||||||
|
@ -317,7 +317,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
int sessionId = AcquireSessionId();
|
int sessionId = AcquireSessionId();
|
||||||
|
|
||||||
AudioRenderSystem audioRenderer = new AudioRenderSystem(this, _sessionsSystemEvent[sessionId]);
|
AudioRenderSystem audioRenderer = new(this, _sessionsSystemEvent[sessionId]);
|
||||||
|
|
||||||
// TODO: Eventually, we should try to use the guest supplied work buffer instead of allocating
|
// TODO: Eventually, we should try to use the guest supplied work buffer instead of allocating
|
||||||
// our own. However, it was causing problems on some applications that would unmap the memory
|
// our own. However, it was causing problems on some applications that would unmap the memory
|
||||||
|
@ -367,6 +367,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
|
|
@ -125,7 +125,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Error storage.
|
/// Error storage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ErrorInfo[] _errorInfos;
|
private readonly ErrorInfo[] _errorInfos;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current position in the <see cref="_errorInfos"/> array.
|
/// Current position in the <see cref="_errorInfos"/> array.
|
||||||
|
@ -254,7 +254,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
return 0.80f;
|
return 0.80f;
|
||||||
}
|
}
|
||||||
else if (CheckFeatureSupported(UserRevision, BaseRevisionMagic + Revision4))
|
|
||||||
|
if (CheckFeatureSupported(UserRevision, BaseRevisionMagic + Revision4))
|
||||||
{
|
{
|
||||||
return 0.75f;
|
return 0.75f;
|
||||||
}
|
}
|
||||||
|
@ -299,10 +300,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -436,7 +435,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
errorInfos[i] = new ErrorInfo
|
errorInfos[i] = new ErrorInfo
|
||||||
{
|
{
|
||||||
ErrorCode = 0,
|
ErrorCode = 0,
|
||||||
ExtraErrorInfo = 0
|
ExtraErrorInfo = 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The command processing time estimator in use.
|
/// The command processing time estimator in use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ICommandProcessingTimeEstimator _commandProcessingTimeEstimator;
|
private readonly ICommandProcessingTimeEstimator _commandProcessingTimeEstimator;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The estimated total processing time.
|
/// The estimated total processing time.
|
||||||
|
@ -61,7 +61,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateClearMixBuffer(int nodeId)
|
public void GenerateClearMixBuffer(int nodeId)
|
||||||
{
|
{
|
||||||
ClearMixBufferCommand command = new ClearMixBufferCommand(nodeId);
|
ClearMixBufferCommand command = new(nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="wasPlaying">Set to true if the voice was playing previously.</param>
|
/// <param name="wasPlaying">Set to true if the voice was playing previously.</param>
|
||||||
public void GenerateDepopPrepare(Memory<VoiceUpdateState> state, Memory<float> depopBuffer, uint bufferCount, uint bufferOffset, int nodeId, bool wasPlaying)
|
public void GenerateDepopPrepare(Memory<VoiceUpdateState> state, Memory<float> depopBuffer, uint bufferCount, uint bufferOffset, int nodeId, bool wasPlaying)
|
||||||
{
|
{
|
||||||
DepopPrepareCommand command = new DepopPrepareCommand(state, depopBuffer, bufferCount, bufferOffset, nodeId, wasPlaying);
|
DepopPrepareCommand command = new(state, depopBuffer, bufferCount, bufferOffset, nodeId, wasPlaying);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GeneratePerformance(ref PerformanceEntryAddresses performanceEntryAddresses, PerformanceCommand.Type type, int nodeId)
|
public void GeneratePerformance(ref PerformanceEntryAddresses performanceEntryAddresses, PerformanceCommand.Type type, int nodeId)
|
||||||
{
|
{
|
||||||
PerformanceCommand command = new PerformanceCommand(ref performanceEntryAddresses, type, nodeId);
|
PerformanceCommand command = new(ref performanceEntryAddresses, type, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateVolumeRamp(float previousVolume, float volume, uint bufferIndex, int nodeId)
|
public void GenerateVolumeRamp(float previousVolume, float volume, uint bufferIndex, int nodeId)
|
||||||
{
|
{
|
||||||
VolumeRampCommand command = new VolumeRampCommand(previousVolume, volume, bufferIndex, nodeId);
|
VolumeRampCommand command = new(previousVolume, volume, bufferIndex, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateDataSourceVersion2(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
public void GenerateDataSourceVersion2(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||||
{
|
{
|
||||||
DataSourceVersion2Command command = new DataSourceVersion2Command(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
DataSourceVersion2Command command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GeneratePcmInt16DataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
public void GeneratePcmInt16DataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||||
{
|
{
|
||||||
PcmInt16DataSourceCommandVersion1 command = new PcmInt16DataSourceCommandVersion1(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
PcmInt16DataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GeneratePcmFloatDataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
public void GeneratePcmFloatDataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||||
{
|
{
|
||||||
PcmFloatDataSourceCommandVersion1 command = new PcmFloatDataSourceCommandVersion1(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
PcmFloatDataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateAdpcmDataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, int nodeId)
|
public void GenerateAdpcmDataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, int nodeId)
|
||||||
{
|
{
|
||||||
AdpcmDataSourceCommandVersion1 command = new AdpcmDataSourceCommandVersion1(ref voiceState, state, outputBufferIndex, nodeId);
|
AdpcmDataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateBiquadFilter(int baseIndex, ref BiquadFilterParameter filter, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, bool needInitialization, int nodeId)
|
public void GenerateBiquadFilter(int baseIndex, ref BiquadFilterParameter filter, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, bool needInitialization, int nodeId)
|
||||||
{
|
{
|
||||||
BiquadFilterCommand command = new BiquadFilterCommand(baseIndex, ref filter, biquadFilterStateMemory, inputBufferOffset, outputBufferOffset, needInitialization, nodeId);
|
BiquadFilterCommand command = new(baseIndex, ref filter, biquadFilterStateMemory, inputBufferOffset, outputBufferOffset, needInitialization, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateGroupedBiquadFilter(int baseIndex, ReadOnlySpan<BiquadFilterParameter> filters, Memory<BiquadFilterState> biquadFilterStatesMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
|
public void GenerateGroupedBiquadFilter(int baseIndex, ReadOnlySpan<BiquadFilterParameter> filters, Memory<BiquadFilterState> biquadFilterStatesMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
|
||||||
{
|
{
|
||||||
GroupedBiquadFilterCommand command = new GroupedBiquadFilterCommand(baseIndex, filters, biquadFilterStatesMemory, inputBufferOffset, outputBufferOffset, isInitialized, nodeId);
|
GroupedBiquadFilterCommand command = new(baseIndex, filters, biquadFilterStatesMemory, inputBufferOffset, outputBufferOffset, isInitialized, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateMixRampGrouped(uint mixBufferCount, uint inputBufferIndex, uint outputBufferIndex, Span<float> previousVolume, Span<float> volume, Memory<VoiceUpdateState> state, int nodeId)
|
public void GenerateMixRampGrouped(uint mixBufferCount, uint inputBufferIndex, uint outputBufferIndex, Span<float> previousVolume, Span<float> volume, Memory<VoiceUpdateState> state, int nodeId)
|
||||||
{
|
{
|
||||||
MixRampGroupedCommand command = new MixRampGroupedCommand(mixBufferCount, inputBufferIndex, outputBufferIndex, previousVolume, volume, state, nodeId);
|
MixRampGroupedCommand command = new(mixBufferCount, inputBufferIndex, outputBufferIndex, previousVolume, volume, state, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateMixRamp(float previousVolume, float volume, uint inputBufferIndex, uint outputBufferIndex, int lastSampleIndex, Memory<VoiceUpdateState> state, int nodeId)
|
public void GenerateMixRamp(float previousVolume, float volume, uint inputBufferIndex, uint outputBufferIndex, int lastSampleIndex, Memory<VoiceUpdateState> state, int nodeId)
|
||||||
{
|
{
|
||||||
MixRampCommand command = new MixRampCommand(previousVolume, volume, inputBufferIndex, outputBufferIndex, lastSampleIndex, state, nodeId);
|
MixRampCommand command = new(previousVolume, volume, inputBufferIndex, outputBufferIndex, lastSampleIndex, state, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="sampleRate">The target sample rate in use.</param>
|
/// <param name="sampleRate">The target sample rate in use.</param>
|
||||||
public void GenerateDepopForMixBuffersCommand(Memory<float> depopBuffer, uint bufferOffset, uint bufferCount, int nodeId, uint sampleRate)
|
public void GenerateDepopForMixBuffersCommand(Memory<float> depopBuffer, uint bufferOffset, uint bufferCount, int nodeId, uint sampleRate)
|
||||||
{
|
{
|
||||||
DepopForMixBuffersCommand command = new DepopForMixBuffersCommand(depopBuffer, bufferOffset, bufferCount, nodeId, sampleRate);
|
DepopForMixBuffersCommand command = new(depopBuffer, bufferOffset, bufferCount, nodeId, sampleRate);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateCopyMixBuffer(uint inputBufferIndex, uint outputBufferIndex, int nodeId)
|
public void GenerateCopyMixBuffer(uint inputBufferIndex, uint outputBufferIndex, int nodeId)
|
||||||
{
|
{
|
||||||
CopyMixBufferCommand command = new CopyMixBufferCommand(inputBufferIndex, outputBufferIndex, nodeId);
|
CopyMixBufferCommand command = new(inputBufferIndex, outputBufferIndex, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="volume">The mix volume.</param>
|
/// <param name="volume">The mix volume.</param>
|
||||||
public void GenerateMix(uint inputBufferIndex, uint outputBufferIndex, int nodeId, float volume)
|
public void GenerateMix(uint inputBufferIndex, uint outputBufferIndex, int nodeId, float volume)
|
||||||
{
|
{
|
||||||
MixCommand command = new MixCommand(inputBufferIndex, outputBufferIndex, nodeId, volume);
|
MixCommand command = new(inputBufferIndex, outputBufferIndex, nodeId, volume);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
if (parameter.IsChannelCountValid())
|
if (parameter.IsChannelCountValid())
|
||||||
{
|
{
|
||||||
ReverbCommand command = new ReverbCommand(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, isLongSizePreDelaySupported, newEffectChannelMappingSupported);
|
ReverbCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, isLongSizePreDelaySupported, newEffectChannelMappingSupported);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
if (parameter.IsChannelCountValid())
|
if (parameter.IsChannelCountValid())
|
||||||
{
|
{
|
||||||
Reverb3dCommand command = new Reverb3dCommand(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
Reverb3dCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
if (parameter.IsChannelCountValid())
|
if (parameter.IsChannelCountValid())
|
||||||
{
|
{
|
||||||
DelayCommand command = new DelayCommand(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
DelayCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
if (parameter.IsChannelCountValid())
|
if (parameter.IsChannelCountValid())
|
||||||
{
|
{
|
||||||
LimiterCommandVersion1 command = new LimiterCommandVersion1(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId);
|
LimiterCommandVersion1 command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
if (parameter.IsChannelCountValid())
|
if (parameter.IsChannelCountValid())
|
||||||
{
|
{
|
||||||
LimiterCommandVersion2 command = new LimiterCommandVersion2(bufferOffset, parameter, state, effectResultState, isEnabled, workBuffer, nodeId);
|
LimiterCommandVersion2 command = new(bufferOffset, parameter, state, effectResultState, isEnabled, workBuffer, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
if (state.SendBufferInfoBase != 0 && state.ReturnBufferInfoBase != 0)
|
if (state.SendBufferInfoBase != 0 && state.ReturnBufferInfoBase != 0)
|
||||||
{
|
{
|
||||||
AuxiliaryBufferCommand command = new AuxiliaryBufferCommand(bufferOffset, inputBufferOffset, outputBufferOffset, ref state, isEnabled, countMax, outputBuffer, inputBuffer, updateCount, writeOffset, nodeId);
|
AuxiliaryBufferCommand command = new(bufferOffset, inputBufferOffset, outputBufferOffset, ref state, isEnabled, countMax, outputBuffer, inputBuffer, updateCount, writeOffset, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
if (sendBufferInfo != 0)
|
if (sendBufferInfo != 0)
|
||||||
{
|
{
|
||||||
CaptureBufferCommand command = new CaptureBufferCommand(bufferOffset, inputBufferOffset, sendBufferInfo, isEnabled, countMax, outputBuffer, updateCount, writeOffset, nodeId);
|
CaptureBufferCommand command = new(bufferOffset, inputBufferOffset, sendBufferInfo, isEnabled, countMax, outputBuffer, updateCount, writeOffset, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -473,7 +473,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
if (parameter.IsChannelCountValid())
|
if (parameter.IsChannelCountValid())
|
||||||
{
|
{
|
||||||
CompressorCommand command = new CompressorCommand(bufferOffset, parameter, state, isEnabled, nodeId);
|
CompressorCommand command = new(bufferOffset, parameter, state, isEnabled, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateVolume(float volume, uint bufferOffset, int nodeId)
|
public void GenerateVolume(float volume, uint bufferOffset, int nodeId)
|
||||||
{
|
{
|
||||||
VolumeCommand command = new VolumeCommand(volume, bufferOffset, nodeId);
|
VolumeCommand command = new(volume, bufferOffset, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -504,7 +504,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateCircularBuffer(uint bufferOffset, CircularBufferSink sink, int nodeId)
|
public void GenerateCircularBuffer(uint bufferOffset, CircularBufferSink sink, int nodeId)
|
||||||
{
|
{
|
||||||
CircularBufferSinkCommand command = new CircularBufferSinkCommand(bufferOffset, ref sink.Parameter, ref sink.CircularBufferAddressInfo, sink.CurrentWriteOffset, nodeId);
|
CircularBufferSinkCommand command = new(bufferOffset, ref sink.Parameter, ref sink.CircularBufferAddressInfo, sink.CurrentWriteOffset, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -521,7 +521,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateDownMixSurroundToStereo(uint bufferOffset, Span<byte> inputBufferOffset, Span<byte> outputBufferOffset, float[] downMixParameter, int nodeId)
|
public void GenerateDownMixSurroundToStereo(uint bufferOffset, Span<byte> inputBufferOffset, Span<byte> outputBufferOffset, float[] downMixParameter, int nodeId)
|
||||||
{
|
{
|
||||||
DownMixSurroundToStereoCommand command = new DownMixSurroundToStereoCommand(bufferOffset, inputBufferOffset, outputBufferOffset, downMixParameter, nodeId);
|
DownMixSurroundToStereoCommand command = new(bufferOffset, inputBufferOffset, outputBufferOffset, downMixParameter, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateUpsample(uint bufferOffset, UpsamplerState upsampler, uint inputCount, Span<byte> inputBufferOffset, uint bufferCountPerSample, uint sampleCount, uint sampleRate, int nodeId)
|
public void GenerateUpsample(uint bufferOffset, UpsamplerState upsampler, uint inputCount, Span<byte> inputBufferOffset, uint bufferCountPerSample, uint sampleCount, uint sampleRate, int nodeId)
|
||||||
{
|
{
|
||||||
UpsampleCommand command = new UpsampleCommand(bufferOffset, upsampler, inputCount, inputBufferOffset, bufferCountPerSample, sampleCount, sampleRate, nodeId);
|
UpsampleCommand command = new(bufferOffset, upsampler, inputCount, inputBufferOffset, bufferCountPerSample, sampleCount, sampleRate, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// <param name="nodeId">The node id associated to this command.</param>
|
/// <param name="nodeId">The node id associated to this command.</param>
|
||||||
public void GenerateDeviceSink(uint bufferOffset, DeviceSink sink, int sessionId, Memory<float> buffer, int nodeId)
|
public void GenerateDeviceSink(uint bufferOffset, DeviceSink sink, int sessionId, Memory<float> buffer, int nodeId)
|
||||||
{
|
{
|
||||||
DeviceSinkCommand command = new DeviceSinkCommand(bufferOffset, sink, sessionId, buffer, nodeId);
|
DeviceSinkCommand command = new(bufferOffset, sink, sessionId, buffer, nodeId);
|
||||||
|
|
||||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,14 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
public class CommandGenerator
|
public class CommandGenerator
|
||||||
{
|
{
|
||||||
private CommandBuffer _commandBuffer;
|
private readonly CommandBuffer _commandBuffer;
|
||||||
private RendererSystemContext _rendererContext;
|
private readonly RendererSystemContext _rendererContext;
|
||||||
private VoiceContext _voiceContext;
|
private readonly VoiceContext _voiceContext;
|
||||||
private MixContext _mixContext;
|
private readonly MixContext _mixContext;
|
||||||
private EffectContext _effectContext;
|
private readonly EffectContext _effectContext;
|
||||||
private SinkContext _sinkContext;
|
private readonly SinkContext _sinkContext;
|
||||||
private SplitterContext _splitterContext;
|
private readonly SplitterContext _splitterContext;
|
||||||
private PerformanceManager _performanceManager;
|
private readonly PerformanceManager _performanceManager;
|
||||||
|
|
||||||
public CommandGenerator(CommandBuffer commandBuffer, RendererSystemContext rendererContext, VoiceContext voiceContext, MixContext mixContext, EffectContext effectContext, SinkContext sinkContext, SplitterContext splitterContext, PerformanceManager performanceManager)
|
public CommandGenerator(CommandBuffer commandBuffer, RendererSystemContext rendererContext, VoiceContext voiceContext, MixContext mixContext, EffectContext effectContext, SinkContext sinkContext, SplitterContext splitterContext, PerformanceManager performanceManager)
|
||||||
{
|
{
|
||||||
|
@ -138,7 +138,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
if (supportsOptimizedPath && voiceState.BiquadFilters[0].Enable && voiceState.BiquadFilters[1].Enable)
|
if (supportsOptimizedPath && voiceState.BiquadFilters[0].Enable && voiceState.BiquadFilters[1].Enable)
|
||||||
{
|
{
|
||||||
Memory<byte> biquadStateRawMemory = SpanMemoryManager<byte>.Cast(state).Slice(VoiceUpdateState.BiquadStateOffset, VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount);
|
Memory<byte> biquadStateRawMemory = SpanMemoryManager<byte>.Cast(state)[..(VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount)];
|
||||||
Memory<BiquadFilterState> stateMemory = SpanMemoryManager<BiquadFilterState>.Cast(biquadStateRawMemory);
|
Memory<BiquadFilterState> stateMemory = SpanMemoryManager<BiquadFilterState>.Cast(biquadStateRawMemory);
|
||||||
|
|
||||||
_commandBuffer.GenerateGroupedBiquadFilter(baseIndex, voiceState.BiquadFilters.AsSpan(), stateMemory, bufferOffset, bufferOffset, voiceState.BiquadFilterNeedInitialization, nodeId);
|
_commandBuffer.GenerateGroupedBiquadFilter(baseIndex, voiceState.BiquadFilters.AsSpan(), stateMemory, bufferOffset, bufferOffset, voiceState.BiquadFilterNeedInitialization, nodeId);
|
||||||
|
@ -151,7 +151,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
if (filter.Enable)
|
if (filter.Enable)
|
||||||
{
|
{
|
||||||
Memory<byte> biquadStateRawMemory = SpanMemoryManager<byte>.Cast(state).Slice(VoiceUpdateState.BiquadStateOffset, VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount);
|
Memory<byte> biquadStateRawMemory = SpanMemoryManager<byte>.Cast(state)[..(VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount)];
|
||||||
|
|
||||||
Memory<BiquadFilterState> stateMemory = SpanMemoryManager<BiquadFilterState>.Cast(biquadStateRawMemory);
|
Memory<BiquadFilterState> stateMemory = SpanMemoryManager<BiquadFilterState>.Cast(biquadStateRawMemory);
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
bool performanceInitialized = false;
|
bool performanceInitialized = false;
|
||||||
|
|
||||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
PerformanceEntryAddresses performanceEntry = new();
|
||||||
|
|
||||||
if (_performanceManager != null && _performanceManager.IsTargetNodeId(nodeId) && _performanceManager.GetNextEntry(out performanceEntry, dataSourceDetailType, PerformanceEntryType.Voice, nodeId))
|
if (_performanceManager != null && _performanceManager.IsTargetNodeId(nodeId) && _performanceManager.GetNextEntry(out performanceEntry, dataSourceDetailType, PerformanceEntryType.Voice, nodeId))
|
||||||
{
|
{
|
||||||
|
@ -371,7 +371,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
int nodeId = sortedState.NodeId;
|
int nodeId = sortedState.NodeId;
|
||||||
|
|
||||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
PerformanceEntryAddresses performanceEntry = new();
|
||||||
|
|
||||||
bool performanceInitialized = false;
|
bool performanceInitialized = false;
|
||||||
|
|
||||||
|
@ -502,9 +502,11 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
bool needInitialization = effect.Parameter.Status == UsageState.Invalid ||
|
bool needInitialization = effect.Parameter.Status == UsageState.Invalid ||
|
||||||
(effect.Parameter.Status == UsageState.New && !_rendererContext.BehaviourContext.IsBiquadFilterEffectStateClearBugFixed());
|
(effect.Parameter.Status == UsageState.New && !_rendererContext.BehaviourContext.IsBiquadFilterEffectStateClearBugFixed());
|
||||||
|
|
||||||
BiquadFilterParameter parameter = new BiquadFilterParameter();
|
BiquadFilterParameter parameter = new()
|
||||||
|
{
|
||||||
|
Enable = true,
|
||||||
|
};
|
||||||
|
|
||||||
parameter.Enable = true;
|
|
||||||
effect.Parameter.Denominator.AsSpan().CopyTo(parameter.Denominator.AsSpan());
|
effect.Parameter.Denominator.AsSpan().CopyTo(parameter.Denominator.AsSpan());
|
||||||
effect.Parameter.Numerator.AsSpan().CopyTo(parameter.Numerator.AsSpan());
|
effect.Parameter.Numerator.AsSpan().CopyTo(parameter.Numerator.AsSpan());
|
||||||
|
|
||||||
|
@ -623,7 +625,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
bool isFinalMix = mix.MixId == Constants.FinalMixId;
|
bool isFinalMix = mix.MixId == Constants.FinalMixId;
|
||||||
|
|
||||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
PerformanceEntryAddresses performanceEntry = new();
|
||||||
|
|
||||||
bool performanceInitialized = false;
|
bool performanceInitialized = false;
|
||||||
|
|
||||||
|
@ -789,7 +791,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
GenerateEffects(ref subMix);
|
GenerateEffects(ref subMix);
|
||||||
|
|
||||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
PerformanceEntryAddresses performanceEntry = new();
|
||||||
|
|
||||||
int nodeId = subMix.NodeId;
|
int nodeId = subMix.NodeId;
|
||||||
|
|
||||||
|
@ -820,7 +822,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
int nodeId = sortedState.NodeId;
|
int nodeId = sortedState.NodeId;
|
||||||
|
|
||||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
PerformanceEntryAddresses performanceEntry = new();
|
||||||
|
|
||||||
bool performanceInitialized = false;
|
bool performanceInitialized = false;
|
||||||
|
|
||||||
|
@ -853,7 +855,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
GenerateEffects(ref finalMix);
|
GenerateEffects(ref finalMix);
|
||||||
|
|
||||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
PerformanceEntryAddresses performanceEntry = new();
|
||||||
|
|
||||||
int nodeId = finalMix.NodeId;
|
int nodeId = finalMix.NodeId;
|
||||||
|
|
||||||
|
@ -901,7 +903,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
int nodeId = _mixContext.GetFinalState().NodeId;
|
int nodeId = _mixContext.GetFinalState().NodeId;
|
||||||
|
|
||||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
PerformanceEntryAddresses performanceEntry = new();
|
||||||
|
|
||||||
bool performanceInitialized = false;
|
bool performanceInitialized = false;
|
||||||
|
|
||||||
|
@ -977,7 +979,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
bool performanceInitialized = false;
|
bool performanceInitialized = false;
|
||||||
|
|
||||||
PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
|
PerformanceEntryAddresses performanceEntry = new();
|
||||||
|
|
||||||
if (_performanceManager != null && _performanceManager.GetNextEntry(out performanceEntry, PerformanceEntryType.Sink, sink.NodeId))
|
if (_performanceManager != null && _performanceManager.GetNextEntry(out performanceEntry, PerformanceEntryType.Sink, sink.NodeId))
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,8 +8,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CommandProcessingTimeEstimatorVersion1 : ICommandProcessingTimeEstimator
|
public class CommandProcessingTimeEstimatorVersion1 : ICommandProcessingTimeEstimator
|
||||||
{
|
{
|
||||||
private uint _sampleCount;
|
private readonly uint _sampleCount;
|
||||||
private uint _bufferCount;
|
private readonly uint _bufferCount;
|
||||||
|
|
||||||
public CommandProcessingTimeEstimatorVersion1(uint sampleCount, uint bufferCount)
|
public CommandProcessingTimeEstimatorVersion1(uint sampleCount, uint bufferCount)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,8 +9,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CommandProcessingTimeEstimatorVersion2 : ICommandProcessingTimeEstimator
|
public class CommandProcessingTimeEstimatorVersion2 : ICommandProcessingTimeEstimator
|
||||||
{
|
{
|
||||||
private uint _sampleCount;
|
private readonly uint _sampleCount;
|
||||||
private uint _bufferCount;
|
private readonly uint _bufferCount;
|
||||||
|
|
||||||
public CommandProcessingTimeEstimatorVersion2(uint sampleCount, uint bufferCount)
|
public CommandProcessingTimeEstimatorVersion2(uint sampleCount, uint bufferCount)
|
||||||
{
|
{
|
||||||
|
@ -189,71 +189,47 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)41636.0f,
|
||||||
return (uint)41636.0f;
|
2 => (uint)97861.0f,
|
||||||
case 2:
|
4 => (uint)192520.0f,
|
||||||
return (uint)97861.0f;
|
6 => (uint)301760.0f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)192520.0f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)301760.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)578.53f,
|
||||||
{
|
2 => (uint)663.06f,
|
||||||
case 1:
|
4 => (uint)703.98f,
|
||||||
return (uint)578.53f;
|
6 => (uint)760.03f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)663.06f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)703.98f;
|
|
||||||
case 6:
|
|
||||||
return (uint)760.03f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)8770.3f,
|
||||||
return (uint)8770.3f;
|
2 => (uint)25741.0f,
|
||||||
case 2:
|
4 => (uint)47551.0f,
|
||||||
return (uint)25741.0f;
|
6 => (uint)81629.0f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)47551.0f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)81629.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)521.28f,
|
||||||
{
|
2 => (uint)585.4f,
|
||||||
case 1:
|
4 => (uint)629.88f,
|
||||||
return (uint)521.28f;
|
6 => (uint)713.57f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)585.4f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)629.88f;
|
|
||||||
case 6:
|
|
||||||
return (uint)713.57f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(ReverbCommand command)
|
public uint Estimate(ReverbCommand command)
|
||||||
|
@ -264,71 +240,47 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)97192.0f,
|
||||||
return (uint)97192.0f;
|
2 => (uint)103280.0f,
|
||||||
case 2:
|
4 => (uint)109580.0f,
|
||||||
return (uint)103280.0f;
|
6 => (uint)115070.0f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)109580.0f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)115070.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)492.01f,
|
||||||
{
|
2 => (uint)554.46f,
|
||||||
case 1:
|
4 => (uint)595.86f,
|
||||||
return (uint)492.01f;
|
6 => (uint)656.62f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)554.46f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)595.86f;
|
|
||||||
case 6:
|
|
||||||
return (uint)656.62f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)136460.0f,
|
||||||
return (uint)136460.0f;
|
2 => (uint)145750.0f,
|
||||||
case 2:
|
4 => (uint)154800.0f,
|
||||||
return (uint)145750.0f;
|
6 => (uint)161970.0f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)154800.0f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)161970.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)495.79f,
|
||||||
{
|
2 => (uint)527.16f,
|
||||||
case 1:
|
4 => (uint)598.75f,
|
||||||
return (uint)495.79f;
|
6 => (uint)666.03f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)527.16f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)598.75f;
|
|
||||||
case 6:
|
|
||||||
return (uint)666.03f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(Reverb3dCommand command)
|
public uint Estimate(Reverb3dCommand command)
|
||||||
|
@ -339,70 +291,46 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)138840.0f,
|
||||||
return (uint)138840.0f;
|
2 => (uint)135430.0f,
|
||||||
case 2:
|
4 => (uint)199180.0f,
|
||||||
return (uint)135430.0f;
|
6 => (uint)247350.0f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)199180.0f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)247350.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)718.7f,
|
||||||
{
|
2 => (uint)751.3f,
|
||||||
case 1:
|
4 => (uint)797.46f,
|
||||||
return (uint)718.7f;
|
6 => (uint)867.43f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)751.3f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)797.46f;
|
|
||||||
case 6:
|
|
||||||
return (uint)867.43f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)199950.0f,
|
||||||
return (uint)199950.0f;
|
2 => (uint)195200.0f,
|
||||||
case 2:
|
4 => (uint)290580.0f,
|
||||||
return (uint)195200.0f;
|
6 => (uint)363490.0f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)290580.0f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)363490.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)534.24f,
|
||||||
{
|
2 => (uint)570.87f,
|
||||||
case 1:
|
4 => (uint)660.93f,
|
||||||
return (uint)534.24f;
|
6 => (uint)694.6f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)570.87f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)660.93f;
|
|
||||||
case 6:
|
|
||||||
return (uint)694.6f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(AuxiliaryBufferCommand command)
|
public uint Estimate(AuxiliaryBufferCommand command)
|
||||||
|
|
|
@ -12,20 +12,20 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CommandProcessingTimeEstimatorVersion3 : ICommandProcessingTimeEstimator
|
public class CommandProcessingTimeEstimatorVersion3 : ICommandProcessingTimeEstimator
|
||||||
{
|
{
|
||||||
protected uint _sampleCount;
|
protected uint SampleCount;
|
||||||
protected uint _bufferCount;
|
protected uint BufferCount;
|
||||||
|
|
||||||
public CommandProcessingTimeEstimatorVersion3(uint sampleCount, uint bufferCount)
|
public CommandProcessingTimeEstimatorVersion3(uint sampleCount, uint bufferCount)
|
||||||
{
|
{
|
||||||
_sampleCount = sampleCount;
|
SampleCount = sampleCount;
|
||||||
_bufferCount = bufferCount;
|
BufferCount = bufferCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(PerformanceCommand command)
|
public uint Estimate(PerformanceCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)498.17f;
|
return (uint)498.17f;
|
||||||
}
|
}
|
||||||
|
@ -35,24 +35,24 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public uint Estimate(ClearMixBufferCommand command)
|
public uint Estimate(ClearMixBufferCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
float costPerBuffer = 440.68f;
|
float costPerBuffer = 440.68f;
|
||||||
float baseCost = 0;
|
float baseCost = 0;
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
costPerBuffer = 266.65f;
|
costPerBuffer = 266.65f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint)(baseCost + costPerBuffer * _bufferCount);
|
return (uint)(baseCost + costPerBuffer * BufferCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(BiquadFilterCommand command)
|
public uint Estimate(BiquadFilterCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)4173.2f;
|
return (uint)4173.2f;
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
{
|
{
|
||||||
float costPerSample = 6.4434f;
|
float costPerSample = 6.4434f;
|
||||||
|
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
costPerSample = 6.708f;
|
costPerSample = 6.708f;
|
||||||
}
|
}
|
||||||
|
@ -81,14 +81,14 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint)(_sampleCount * costPerSample * volumeCount);
|
return (uint)(SampleCount * costPerSample * volumeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(MixRampCommand command)
|
public uint Estimate(MixRampCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)1968.7f;
|
return (uint)1968.7f;
|
||||||
}
|
}
|
||||||
|
@ -103,9 +103,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public uint Estimate(VolumeRampCommand command)
|
public uint Estimate(VolumeRampCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)1425.3f;
|
return (uint)1425.3f;
|
||||||
}
|
}
|
||||||
|
@ -115,41 +115,41 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public uint Estimate(PcmInt16DataSourceCommandVersion1 command)
|
public uint Estimate(PcmInt16DataSourceCommandVersion1 command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
float costPerSample = 710.143f;
|
float costPerSample = 710.143f;
|
||||||
float baseCost = 7853.286f;
|
float baseCost = 7853.286f;
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
costPerSample = 427.52f;
|
costPerSample = 427.52f;
|
||||||
baseCost = 6329.442f;
|
baseCost = 6329.442f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f))));
|
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(AdpcmDataSourceCommandVersion1 command)
|
public uint Estimate(AdpcmDataSourceCommandVersion1 command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
float costPerSample = 3564.1f;
|
float costPerSample = 3564.1f;
|
||||||
float baseCost = 9736.702f;
|
float baseCost = 9736.702f;
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
costPerSample = 2125.6f;
|
costPerSample = 2125.6f;
|
||||||
baseCost = 7913.808f;
|
baseCost = 7913.808f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f))));
|
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(DepopForMixBuffersCommand command)
|
public uint Estimate(DepopForMixBuffersCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)739.64f;
|
return (uint)739.64f;
|
||||||
}
|
}
|
||||||
|
@ -159,9 +159,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public uint Estimate(CopyMixBufferCommand command)
|
public uint Estimate(CopyMixBufferCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)842.59f;
|
return (uint)842.59f;
|
||||||
}
|
}
|
||||||
|
@ -171,9 +171,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public uint Estimate(MixCommand command)
|
public uint Estimate(MixCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)1402.8f;
|
return (uint)1402.8f;
|
||||||
}
|
}
|
||||||
|
@ -183,231 +183,159 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public virtual uint Estimate(DelayCommand command)
|
public virtual uint Estimate(DelayCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)8929.04f,
|
||||||
return (uint)8929.04f;
|
2 => (uint)25500.75f,
|
||||||
case 2:
|
4 => (uint)47759.62f,
|
||||||
return (uint)25500.75f;
|
6 => (uint)82203.07f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)47759.62f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)82203.07f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)1295.20f,
|
||||||
{
|
2 => (uint)1213.60f,
|
||||||
case 1:
|
4 => (uint)942.03f,
|
||||||
return (uint)1295.20f;
|
6 => (uint)1001.55f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)1213.60f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)942.03f;
|
|
||||||
case 6:
|
|
||||||
return (uint)1001.55f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)11941.05f,
|
||||||
return (uint)11941.05f;
|
2 => (uint)37197.37f,
|
||||||
case 2:
|
4 => (uint)69749.84f,
|
||||||
return (uint)37197.37f;
|
6 => (uint)120042.40f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)69749.84f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)120042.40f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)997.67f,
|
||||||
{
|
2 => (uint)977.63f,
|
||||||
case 1:
|
4 => (uint)792.30f,
|
||||||
return (uint)997.67f;
|
6 => (uint)875.43f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)977.63f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)792.30f;
|
|
||||||
case 6:
|
|
||||||
return (uint)875.43f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual uint Estimate(ReverbCommand command)
|
public virtual uint Estimate(ReverbCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)81475.05f,
|
||||||
return (uint)81475.05f;
|
2 => (uint)84975.0f,
|
||||||
case 2:
|
4 => (uint)91625.15f,
|
||||||
return (uint)84975.0f;
|
6 => (uint)95332.27f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)91625.15f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)95332.27f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)536.30f,
|
||||||
{
|
2 => (uint)588.70f,
|
||||||
case 1:
|
4 => (uint)643.70f,
|
||||||
return (uint)536.30f;
|
6 => (uint)706.0f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)588.70f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)643.70f;
|
|
||||||
case 6:
|
|
||||||
return (uint)706.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)120174.47f,
|
||||||
return (uint)120174.47f;
|
2 => (uint)25262.22f,
|
||||||
case 2:
|
4 => (uint)135751.23f,
|
||||||
return (uint)25262.22f;
|
6 => (uint)141129.23f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)135751.23f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)141129.23f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)617.64f,
|
||||||
{
|
2 => (uint)659.54f,
|
||||||
case 1:
|
4 => (uint)711.43f,
|
||||||
return (uint)617.64f;
|
6 => (uint)778.07f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)659.54f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)711.43f;
|
|
||||||
case 6:
|
|
||||||
return (uint)778.07f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual uint Estimate(Reverb3dCommand command)
|
public virtual uint Estimate(Reverb3dCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)116754.0f,
|
||||||
return (uint)116754.0f;
|
2 => (uint)125912.05f,
|
||||||
case 2:
|
4 => (uint)146336.03f,
|
||||||
return (uint)125912.05f;
|
6 => (uint)165812.66f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)146336.03f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)165812.66f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)734.0f,
|
||||||
{
|
2 => (uint)766.62f,
|
||||||
case 1:
|
4 => (uint)797.46f,
|
||||||
return (uint)734.0f;
|
6 => (uint)867.43f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)766.62f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)797.46f;
|
|
||||||
case 6:
|
|
||||||
return (uint)867.43f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)170292.34f,
|
||||||
return (uint)170292.34f;
|
2 => (uint)183875.63f,
|
||||||
case 2:
|
4 => (uint)214696.19f,
|
||||||
return (uint)183875.63f;
|
6 => (uint)243846.77f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)214696.19f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)243846.77f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)508.47f,
|
||||||
{
|
2 => (uint)582.45f,
|
||||||
case 1:
|
4 => (uint)626.42f,
|
||||||
return (uint)508.47f;
|
6 => (uint)682.47f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)582.45f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)626.42f;
|
|
||||||
case 6:
|
|
||||||
return (uint)682.47f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(AuxiliaryBufferCommand command)
|
public uint Estimate(AuxiliaryBufferCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
|
@ -427,9 +355,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public uint Estimate(VolumeCommand command)
|
public uint Estimate(VolumeCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)1311.1f;
|
return (uint)1311.1f;
|
||||||
}
|
}
|
||||||
|
@ -439,12 +367,12 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public uint Estimate(CircularBufferSinkCommand command)
|
public uint Estimate(CircularBufferSinkCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
float costPerBuffer = 770.26f;
|
float costPerBuffer = 770.26f;
|
||||||
float baseCost = 0f;
|
float baseCost = 0f;
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
costPerBuffer = 531.07f;
|
costPerBuffer = 531.07f;
|
||||||
}
|
}
|
||||||
|
@ -454,9 +382,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public uint Estimate(DownMixSurroundToStereoCommand command)
|
public uint Estimate(DownMixSurroundToStereoCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)9949.7f;
|
return (uint)9949.7f;
|
||||||
}
|
}
|
||||||
|
@ -466,9 +394,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public uint Estimate(UpsampleCommand command)
|
public uint Estimate(UpsampleCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)312990.0f;
|
return (uint)312990.0f;
|
||||||
}
|
}
|
||||||
|
@ -478,12 +406,12 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public uint Estimate(DeviceSinkCommand command)
|
public uint Estimate(DeviceSinkCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
Debug.Assert(command.InputCount == 2 || command.InputCount == 6);
|
Debug.Assert(command.InputCount == 2 || command.InputCount == 6);
|
||||||
|
|
||||||
if (command.InputCount == 2)
|
if (command.InputCount == 2)
|
||||||
{
|
{
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)8980.0f;
|
return (uint)8980.0f;
|
||||||
}
|
}
|
||||||
|
@ -491,7 +419,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
return (uint)9221.9f;
|
return (uint)9221.9f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)9177.9f;
|
return (uint)9177.9f;
|
||||||
}
|
}
|
||||||
|
@ -501,27 +429,27 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public uint Estimate(PcmFloatDataSourceCommandVersion1 command)
|
public uint Estimate(PcmFloatDataSourceCommandVersion1 command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
float costPerSample = 3490.9f;
|
float costPerSample = 3490.9f;
|
||||||
float baseCost = 10090.9f;
|
float baseCost = 10090.9f;
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
costPerSample = 2310.4f;
|
costPerSample = 2310.4f;
|
||||||
baseCost = 7845.25f;
|
baseCost = 7845.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f))));
|
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(DataSourceVersion2Command command)
|
public uint Estimate(DataSourceVersion2Command command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
(float baseCost, float costPerSample) = GetCostByFormat(_sampleCount, command.SampleFormat, command.SrcQuality);
|
(float baseCost, float costPerSample) = GetCostByFormat(SampleCount, command.SampleFormat, command.SrcQuality);
|
||||||
|
|
||||||
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f) - 1.0f)));
|
return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f) - 1.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (float, float) GetCostByFormat(uint sampleCount, SampleFormat format, SampleRateConversionQuality quality)
|
private static (float, float) GetCostByFormat(uint sampleCount, SampleFormat format, SampleRateConversionQuality quality)
|
||||||
|
@ -618,124 +546,90 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
private uint EstimateLimiterCommandCommon(LimiterParameter parameter, bool enabled)
|
private uint EstimateLimiterCommandCommon(LimiterParameter parameter, bool enabled)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
switch (parameter.ChannelCount)
|
return parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)21392.0f,
|
||||||
return (uint)21392.0f;
|
2 => (uint)26829.0f,
|
||||||
case 2:
|
4 => (uint)32405.0f,
|
||||||
return (uint)26829.0f;
|
6 => (uint)52219.0f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{parameter.ChannelCount}"),
|
||||||
return (uint)32405.0f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)52219.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (parameter.ChannelCount)
|
1 => (uint)897.0f,
|
||||||
{
|
2 => (uint)931.55f,
|
||||||
case 1:
|
4 => (uint)975.39f,
|
||||||
return (uint)897.0f;
|
6 => (uint)1016.8f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{parameter.ChannelCount}"),
|
||||||
return (uint)931.55f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)975.39f;
|
|
||||||
case 6:
|
|
||||||
return (uint)1016.8f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
switch (parameter.ChannelCount)
|
return parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)30556.0f,
|
||||||
return (uint)30556.0f;
|
2 => (uint)39011.0f,
|
||||||
case 2:
|
4 => (uint)48270.0f,
|
||||||
return (uint)39011.0f;
|
6 => (uint)76712.0f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{parameter.ChannelCount}"),
|
||||||
return (uint)48270.0f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)76712.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (parameter.ChannelCount)
|
1 => (uint)874.43f,
|
||||||
{
|
2 => (uint)921.55f,
|
||||||
case 1:
|
4 => (uint)945.26f,
|
||||||
return (uint)874.43f;
|
6 => (uint)992.26f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{parameter.ChannelCount}"),
|
||||||
return (uint)921.55f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)945.26f;
|
|
||||||
case 6:
|
|
||||||
return (uint)992.26f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(LimiterCommandVersion1 command)
|
public uint Estimate(LimiterCommandVersion1 command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
return EstimateLimiterCommandCommon(command.Parameter, command.IsEffectEnabled);
|
return EstimateLimiterCommandCommon(command.Parameter, command.IsEffectEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint Estimate(LimiterCommandVersion2 command)
|
public uint Estimate(LimiterCommandVersion2 command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (!command.Parameter.StatisticsEnabled || !command.IsEffectEnabled)
|
if (!command.Parameter.StatisticsEnabled || !command.IsEffectEnabled)
|
||||||
{
|
{
|
||||||
return EstimateLimiterCommandCommon(command.Parameter, command.IsEffectEnabled);
|
return EstimateLimiterCommandCommon(command.Parameter, command.IsEffectEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)23309.0f,
|
||||||
return (uint)23309.0f;
|
2 => (uint)29954.0f,
|
||||||
case 2:
|
4 => (uint)35807.0f,
|
||||||
return (uint)29954.0f;
|
6 => (uint)58340.0f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)35807.0f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)58340.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => (uint)33526.0f,
|
||||||
return (uint)33526.0f;
|
2 => (uint)43549.0f,
|
||||||
case 2:
|
4 => (uint)52190.0f,
|
||||||
return (uint)43549.0f;
|
6 => (uint)85527.0f,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)52190.0f;
|
};
|
||||||
case 6:
|
|
||||||
return (uint)85527.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual uint Estimate(GroupedBiquadFilterCommand command)
|
public virtual uint Estimate(GroupedBiquadFilterCommand command)
|
||||||
|
|
|
@ -12,9 +12,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public override uint Estimate(GroupedBiquadFilterCommand command)
|
public override uint Estimate(GroupedBiquadFilterCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
return (uint)7424.5f;
|
return (uint)7424.5f;
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public override uint Estimate(CaptureBufferCommand command)
|
public override uint Estimate(CaptureBufferCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,298 +13,202 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||||
|
|
||||||
public override uint Estimate(DelayCommand command)
|
public override uint Estimate(DelayCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => 8929,
|
||||||
return 8929;
|
2 => 25501,
|
||||||
case 2:
|
4 => 47760,
|
||||||
return 25501;
|
6 => 82203,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return 47760;
|
};
|
||||||
case 6:
|
|
||||||
return 82203;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)1295.20f,
|
||||||
{
|
2 => (uint)1213.60f,
|
||||||
case 1:
|
4 => (uint)942.03f,
|
||||||
return (uint)1295.20f;
|
6 => (uint)1001.6f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)1213.60f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)942.03f;
|
|
||||||
case 6:
|
|
||||||
return (uint)1001.6f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => 11941,
|
||||||
return 11941;
|
2 => 37197,
|
||||||
case 2:
|
4 => 69750,
|
||||||
return 37197;
|
6 => 12004,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return 69750;
|
};
|
||||||
case 6:
|
|
||||||
return 12004;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)997.67f,
|
||||||
{
|
2 => (uint)977.63f,
|
||||||
case 1:
|
4 => (uint)792.31f,
|
||||||
return (uint)997.67f;
|
6 => (uint)875.43f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)977.63f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)792.31f;
|
|
||||||
case 6:
|
|
||||||
return (uint)875.43f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override uint Estimate(ReverbCommand command)
|
public override uint Estimate(ReverbCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => 81475,
|
||||||
return 81475;
|
2 => 84975,
|
||||||
case 2:
|
4 => 91625,
|
||||||
return 84975;
|
6 => 95332,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return 91625;
|
};
|
||||||
case 6:
|
|
||||||
return 95332;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)536.30f,
|
||||||
{
|
2 => (uint)588.80f,
|
||||||
case 1:
|
4 => (uint)643.70f,
|
||||||
return (uint)536.30f;
|
6 => (uint)706.0f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)588.80f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)643.70f;
|
|
||||||
case 6:
|
|
||||||
return (uint)706.0f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => 120170,
|
||||||
return 120170;
|
2 => 125260,
|
||||||
case 2:
|
4 => 135750,
|
||||||
return 125260;
|
6 => 141130,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return 135750;
|
};
|
||||||
case 6:
|
|
||||||
return 141130;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)617.64f,
|
||||||
{
|
2 => (uint)659.54f,
|
||||||
case 1:
|
4 => (uint)711.44f,
|
||||||
return (uint)617.64f;
|
6 => (uint)778.07f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)659.54f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)711.44f;
|
|
||||||
case 6:
|
|
||||||
return (uint)778.07f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override uint Estimate(Reverb3dCommand command)
|
public override uint Estimate(Reverb3dCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => 116750,
|
||||||
return 116750;
|
2 => 125910,
|
||||||
case 2:
|
4 => 146340,
|
||||||
return 125910;
|
6 => 165810,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return 146340;
|
};
|
||||||
case 6:
|
|
||||||
return 165810;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => 735,
|
||||||
{
|
2 => (uint)766.62f,
|
||||||
case 1:
|
4 => (uint)834.07f,
|
||||||
return 735;
|
6 => (uint)875.44f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)766.62f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)834.07f;
|
|
||||||
case 6:
|
|
||||||
return (uint)875.44f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => 170290,
|
||||||
return 170290;
|
2 => 183880,
|
||||||
case 2:
|
4 => 214700,
|
||||||
return 183880;
|
6 => 243850,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return 214700;
|
};
|
||||||
case 6:
|
|
||||||
return 243850;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)508.47f,
|
||||||
{
|
2 => (uint)582.45f,
|
||||||
case 1:
|
4 => (uint)626.42f,
|
||||||
return (uint)508.47f;
|
6 => (uint)682.47f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)582.45f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)626.42f;
|
|
||||||
case 6:
|
|
||||||
return (uint)682.47f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override uint Estimate(CompressorCommand command)
|
public override uint Estimate(CompressorCommand command)
|
||||||
{
|
{
|
||||||
Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
|
Debug.Assert(SampleCount == 160 || SampleCount == 240);
|
||||||
|
|
||||||
if (_sampleCount == 160)
|
if (SampleCount == 160)
|
||||||
{
|
{
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => 34431,
|
||||||
return 34431;
|
2 => 44253,
|
||||||
case 2:
|
4 => 63827,
|
||||||
return 44253;
|
6 => 83361,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return 63827;
|
};
|
||||||
case 6:
|
|
||||||
return 83361;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)630.12f,
|
||||||
{
|
2 => (uint)638.27f,
|
||||||
case 1:
|
4 => (uint)705.86f,
|
||||||
return (uint)630.12f;
|
6 => (uint)782.02f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)638.27f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)705.86f;
|
|
||||||
case 6:
|
|
||||||
return (uint)782.02f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.Enabled)
|
if (command.Enabled)
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => 51095,
|
||||||
return 51095;
|
2 => 65693,
|
||||||
case 2:
|
4 => 95383,
|
||||||
return 65693;
|
6 => 124510,
|
||||||
case 4:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return 95383;
|
};
|
||||||
case 6:
|
|
||||||
return 124510;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return command.Parameter.ChannelCount switch
|
||||||
{
|
{
|
||||||
switch (command.Parameter.ChannelCount)
|
1 => (uint)840.14f,
|
||||||
{
|
2 => (uint)826.1f,
|
||||||
case 1:
|
4 => (uint)901.88f,
|
||||||
return (uint)840.14f;
|
6 => (uint)965.29f,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
|
||||||
return (uint)826.1f;
|
};
|
||||||
case 4:
|
|
||||||
return (uint)901.88f;
|
|
||||||
case 6:
|
|
||||||
return (uint)965.29f;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{command.Parameter.ChannelCount}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -58,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||||
{
|
{
|
||||||
ulong bufferSize = (ulong)Unsafe.SizeOf<int>() * Parameter.BufferStorageSize + (ulong)Unsafe.SizeOf<AuxiliaryBufferHeader>();
|
ulong bufferSize = (ulong)Unsafe.SizeOf<int>() * Parameter.BufferStorageSize + (ulong)Unsafe.SizeOf<AuxiliaryBufferHeader>();
|
||||||
|
|
||||||
bool sendBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], Parameter.SendBufferInfoAddress, bufferSize);
|
bool sendBufferUnmapped = !mapper.TryAttachBuffer(out _, ref WorkBuffers[0], Parameter.SendBufferInfoAddress, bufferSize);
|
||||||
bool returnBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[1], Parameter.ReturnBufferInfoAddress, bufferSize);
|
bool returnBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[1], Parameter.ReturnBufferInfoAddress, bufferSize);
|
||||||
|
|
||||||
BufferUnmapped = sendBufferUnmapped && returnBufferUnmapped;
|
BufferUnmapped = sendBufferUnmapped && returnBufferUnmapped;
|
||||||
|
|
|
@ -244,29 +244,19 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||||
/// <returns>The <see cref="PerformanceDetailType"/> associated to the <see cref="Type"/> of this effect.</returns>
|
/// <returns>The <see cref="PerformanceDetailType"/> associated to the <see cref="Type"/> of this effect.</returns>
|
||||||
public PerformanceDetailType GetPerformanceDetailType()
|
public PerformanceDetailType GetPerformanceDetailType()
|
||||||
{
|
{
|
||||||
switch (Type)
|
return Type switch
|
||||||
{
|
{
|
||||||
case EffectType.BiquadFilter:
|
EffectType.BiquadFilter => PerformanceDetailType.BiquadFilter,
|
||||||
return PerformanceDetailType.BiquadFilter;
|
EffectType.AuxiliaryBuffer => PerformanceDetailType.Aux,
|
||||||
case EffectType.AuxiliaryBuffer:
|
EffectType.Delay => PerformanceDetailType.Delay,
|
||||||
return PerformanceDetailType.Aux;
|
EffectType.Reverb => PerformanceDetailType.Reverb,
|
||||||
case EffectType.Delay:
|
EffectType.Reverb3d => PerformanceDetailType.Reverb3d,
|
||||||
return PerformanceDetailType.Delay;
|
EffectType.BufferMix => PerformanceDetailType.Mix,
|
||||||
case EffectType.Reverb:
|
EffectType.Limiter => PerformanceDetailType.Limiter,
|
||||||
return PerformanceDetailType.Reverb;
|
EffectType.CaptureBuffer => PerformanceDetailType.CaptureBuffer,
|
||||||
case EffectType.Reverb3d:
|
EffectType.Compressor => PerformanceDetailType.Compressor,
|
||||||
return PerformanceDetailType.Reverb3d;
|
_ => throw new NotImplementedException($"{Type}"),
|
||||||
case EffectType.BufferMix:
|
};
|
||||||
return PerformanceDetailType.Mix;
|
|
||||||
case EffectType.Limiter:
|
|
||||||
return PerformanceDetailType.Limiter;
|
|
||||||
case EffectType.CaptureBuffer:
|
|
||||||
return PerformanceDetailType.CaptureBuffer;
|
|
||||||
case EffectType.Compressor:
|
|
||||||
return PerformanceDetailType.Compressor;
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"{Type}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,6 +23,6 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The effect is disabled.
|
/// The effect is disabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Disabled
|
Disabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,9 +27,9 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DspAddress ForceMappedDspAddress;
|
public DspAddress ForceMappedDspAddress;
|
||||||
|
|
||||||
private unsafe ref MemoryPoolState MemoryPoolState => ref *_memoryPools;
|
private readonly unsafe ref MemoryPoolState MemoryPoolState => ref *_memoryPools;
|
||||||
|
|
||||||
public unsafe bool HasMemoryPoolState => (IntPtr)_memoryPools != IntPtr.Zero;
|
public readonly unsafe bool HasMemoryPoolState => (IntPtr)_memoryPools != IntPtr.Zero;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create an new empty <see cref="AddressInfo"/>.
|
/// Create an new empty <see cref="AddressInfo"/>.
|
||||||
|
@ -55,7 +55,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||||
CpuAddress = cpuAddress,
|
CpuAddress = cpuAddress,
|
||||||
_memoryPools = MemoryPoolState.Null,
|
_memoryPools = MemoryPoolState.Null,
|
||||||
Size = size,
|
Size = size,
|
||||||
ForceMappedDspAddress = 0
|
ForceMappedDspAddress = 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||||
/// Check if the <see cref="MemoryPoolState"/> is mapped.
|
/// Check if the <see cref="MemoryPoolState"/> is mapped.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if the <see cref="MemoryPoolState"/> is mapped.</returns>
|
/// <returns>Returns true if the <see cref="MemoryPoolState"/> is mapped.</returns>
|
||||||
public bool HasMappedMemoryPool()
|
public readonly bool HasMappedMemoryPool()
|
||||||
{
|
{
|
||||||
return HasMemoryPoolState && MemoryPoolState.IsMapped();
|
return HasMemoryPoolState && MemoryPoolState.IsMapped();
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="markUsed">If true, mark the <see cref="MemoryPoolState"/> as used.</param>
|
/// <param name="markUsed">If true, mark the <see cref="MemoryPoolState"/> as used.</param>
|
||||||
/// <returns>Returns the DSP address associated to the <see cref="AddressInfo"/>.</returns>
|
/// <returns>Returns the DSP address associated to the <see cref="AddressInfo"/>.</returns>
|
||||||
public DspAddress GetReference(bool markUsed)
|
public readonly DspAddress GetReference(bool markUsed)
|
||||||
{
|
{
|
||||||
if (!HasMappedMemoryPool())
|
if (!HasMappedMemoryPool())
|
||||||
{
|
{
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue