aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2024-05-17 16:46:43 -0300
committerGitHub <noreply@github.com>2024-05-17 16:46:43 -0300
commit4d84df94873a070f6f5c199438f957b24d8cf8a9 (patch)
tree3e4b4cc9585526c63f3a9fdb3a150bfd721a5030 /src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs
parent9ec8b2c01a0b00f3a33d9a23b9f5ff3758520484 (diff)
Update audio renderer to REV12: Add support for splitter biquad filter (#6813)
* Update audio renderer to REV12: Add support for splitter biquad filter * Formatting * Official names * Update BiquadFilterState size + other fixes * Update tests * Update comment for version 2 * Size test for SplitterDestinationVersion2 * Should use Volume1 if no ramp
Diffstat (limited to 'src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs')
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs124
1 files changed, 119 insertions, 5 deletions
diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs b/src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs
index f4174a91..702f0546 100644
--- a/src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs
@@ -204,7 +204,7 @@ namespace Ryujinx.Audio.Renderer.Server
}
/// <summary>
- /// Create a new <see cref="GroupedBiquadFilterCommand"/>.
+ /// Create a new <see cref="MultiTapBiquadFilterCommand"/>.
/// </summary>
/// <param name="baseIndex">The base index of the input and output buffer.</param>
/// <param name="filters">The biquad filter parameters.</param>
@@ -213,9 +213,9 @@ namespace Ryujinx.Audio.Renderer.Server
/// <param name="outputBufferOffset">The output buffer offset.</param>
/// <param name="isInitialized">Set to true if the biquad filter state is initialized.</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 GenerateMultiTapBiquadFilter(int baseIndex, ReadOnlySpan<BiquadFilterParameter> filters, Memory<BiquadFilterState> biquadFilterStatesMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
{
- GroupedBiquadFilterCommand command = new(baseIndex, filters, biquadFilterStatesMemory, inputBufferOffset, outputBufferOffset, isInitialized, nodeId);
+ MultiTapBiquadFilterCommand command = new(baseIndex, filters, biquadFilterStatesMemory, inputBufferOffset, outputBufferOffset, isInitialized, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -232,7 +232,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// <param name="volume">The new volume.</param>
/// <param name="state">The <see cref="VoiceUpdateState"/> to generate the command from.</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, ReadOnlySpan<float> previousVolume, ReadOnlySpan<float> volume, Memory<VoiceUpdateState> state, int nodeId)
{
MixRampGroupedCommand command = new(mixBufferCount, inputBufferIndex, outputBufferIndex, previousVolume, volume, state, nodeId);
@@ -261,6 +261,120 @@ namespace Ryujinx.Audio.Renderer.Server
}
/// <summary>
+ /// Generate a new <see cref="BiquadFilterAndMixCommand"/>.
+ /// </summary>
+ /// <param name="previousVolume">The previous volume.</param>
+ /// <param name="volume">The new volume.</param>
+ /// <param name="inputBufferIndex">The input buffer index.</param>
+ /// <param name="outputBufferIndex">The output buffer index.</param>
+ /// <param name="lastSampleIndex">The index in the <see cref="VoiceUpdateState.LastSamples"/> array to store the ramped sample.</param>
+ /// <param name="state">The <see cref="VoiceUpdateState"/> to generate the command from.</param>
+ /// <param name="filter">The biquad filter parameter.</param>
+ /// <param name="biquadFilterState">The biquad state.</param>
+ /// <param name="previousBiquadFilterState">The previous biquad state.</param>
+ /// <param name="needInitialization">Set to true if the biquad filter state needs to be initialized.</param>
+ /// <param name="hasVolumeRamp">Set to true if the mix has volume ramp, and <paramref name="previousVolume"/> should be taken into account.</param>
+ /// <param name="isFirstMixBuffer">Set to true if the buffer is the first mix buffer.</param>
+ /// <param name="nodeId">The node id associated to this command.</param>
+ public void GenerateBiquadFilterAndMix(
+ float previousVolume,
+ float volume,
+ uint inputBufferIndex,
+ uint outputBufferIndex,
+ int lastSampleIndex,
+ Memory<VoiceUpdateState> state,
+ ref BiquadFilterParameter filter,
+ Memory<BiquadFilterState> biquadFilterState,
+ Memory<BiquadFilterState> previousBiquadFilterState,
+ bool needInitialization,
+ bool hasVolumeRamp,
+ bool isFirstMixBuffer,
+ int nodeId)
+ {
+ BiquadFilterAndMixCommand command = new(
+ previousVolume,
+ volume,
+ inputBufferIndex,
+ outputBufferIndex,
+ lastSampleIndex,
+ state,
+ ref filter,
+ biquadFilterState,
+ previousBiquadFilterState,
+ needInitialization,
+ hasVolumeRamp,
+ isFirstMixBuffer,
+ nodeId);
+
+ command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
+
+ AddCommand(command);
+ }
+
+ /// <summary>
+ /// Generate a new <see cref="MultiTapBiquadFilterAndMixCommand"/>.
+ /// </summary>
+ /// <param name="previousVolume">The previous volume.</param>
+ /// <param name="volume">The new volume.</param>
+ /// <param name="inputBufferIndex">The input buffer index.</param>
+ /// <param name="outputBufferIndex">The output buffer index.</param>
+ /// <param name="lastSampleIndex">The index in the <see cref="VoiceUpdateState.LastSamples"/> array to store the ramped sample.</param>
+ /// <param name="state">The <see cref="VoiceUpdateState"/> to generate the command from.</param>
+ /// <param name="filter0">First biquad filter parameter.</param>
+ /// <param name="filter1">Second biquad filter parameter.</param>
+ /// <param name="biquadFilterState0">First biquad state.</param>
+ /// <param name="biquadFilterState1">Second biquad state.</param>
+ /// <param name="previousBiquadFilterState0">First previous biquad state.</param>
+ /// <param name="previousBiquadFilterState1">Second previous biquad state.</param>
+ /// <param name="needInitialization0">Set to true if the first biquad filter state needs to be initialized.</param>
+ /// <param name="needInitialization1">Set to true if the second biquad filter state needs to be initialized.</param>
+ /// <param name="hasVolumeRamp">Set to true if the mix has volume ramp, and <paramref name="previousVolume"/> should be taken into account.</param>
+ /// <param name="isFirstMixBuffer">Set to true if the buffer is the first mix buffer.</param>
+ /// <param name="nodeId">The node id associated to this command.</param>
+ public void GenerateMultiTapBiquadFilterAndMix(
+ float previousVolume,
+ float volume,
+ uint inputBufferIndex,
+ uint outputBufferIndex,
+ int lastSampleIndex,
+ Memory<VoiceUpdateState> state,
+ ref BiquadFilterParameter filter0,
+ ref BiquadFilterParameter filter1,
+ Memory<BiquadFilterState> biquadFilterState0,
+ Memory<BiquadFilterState> biquadFilterState1,
+ Memory<BiquadFilterState> previousBiquadFilterState0,
+ Memory<BiquadFilterState> previousBiquadFilterState1,
+ bool needInitialization0,
+ bool needInitialization1,
+ bool hasVolumeRamp,
+ bool isFirstMixBuffer,
+ int nodeId)
+ {
+ MultiTapBiquadFilterAndMixCommand command = new(
+ previousVolume,
+ volume,
+ inputBufferIndex,
+ outputBufferIndex,
+ lastSampleIndex,
+ state,
+ ref filter0,
+ ref filter1,
+ biquadFilterState0,
+ biquadFilterState1,
+ previousBiquadFilterState0,
+ previousBiquadFilterState1,
+ needInitialization0,
+ needInitialization1,
+ hasVolumeRamp,
+ isFirstMixBuffer,
+ nodeId);
+
+ command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
+
+ AddCommand(command);
+ }
+
+ /// <summary>
/// Generate a new <see cref="DepopForMixBuffersCommand"/>.
/// </summary>
/// <param name="depopBuffer">The depop buffer.</param>
@@ -268,7 +382,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// <param name="bufferCount">The buffer count.</param>
/// <param name="nodeId">The node id associated to this command.</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 GenerateDepopForMixBuffers(Memory<float> depopBuffer, uint bufferOffset, uint bufferCount, int nodeId, uint sampleRate)
{
DepopForMixBuffersCommand command = new(depopBuffer, bufferOffset, bufferCount, nodeId, sampleRate);