mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-05 01:42:03 +00:00
a389dd59bd
* Amadeus: Final Act This is my requiem, I present to you Amadeus, a complete reimplementation of the Audio Renderer! This reimplementation is based on my reversing of every version of the audio system module that I carried for the past 10 months. This supports every revision (at the time of writing REV1 to REV8 included) and all features proposed by the Audio Renderer on real hardware. Because this component could be used outside an emulation context, and to avoid possible "inspirations" not crediting the project, I decided to license the Ryujinx.Audio.Renderer project under LGPLv3. - FE3H voices in videos and chapter intro are not present. - Games that use two audio renderer **at the same time** are probably going to have issues right now **until we rewrite the audio output interface** (Crash Team Racing is the only known game to use two renderer at the same time). - Persona 5 Scrambler now goes ingame but audio is garbage. This is caused by the fact that the game engine is syncing audio and video in a really aggressive way. This will disappears the day this game run at full speed. * Make timing more precise when sleeping on Windows Improve precision to a 1ms resolution on Windows NT based OS. This is used to avoid having totally erratic timings and unify all Windows users to the same resolution. NOTE: This is only active when emulation is running.
167 lines
5.4 KiB
C#
167 lines
5.4 KiB
C#
//
|
|
// Copyright (c) 2019-2020 Ryujinx
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Lesser General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
//
|
|
|
|
using Ryujinx.Audio.Renderer.Utils;
|
|
using Ryujinx.Common;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace Ryujinx.Audio.Renderer.Common
|
|
{
|
|
/// <summary>
|
|
/// Represents a adjacent matrix.
|
|
/// </summary>
|
|
/// <remarks>This is used for splitter routing.</remarks>
|
|
public class EdgeMatrix
|
|
{
|
|
/// <summary>
|
|
/// Backing <see cref="BitArray"/> used for node connections.
|
|
/// </summary>
|
|
private BitArray _storage;
|
|
|
|
/// <summary>
|
|
/// The count of nodes of the current instance.
|
|
/// </summary>
|
|
private int _nodeCount;
|
|
|
|
/// <summary>
|
|
/// Get the required work buffer size memory needed for the <see cref="EdgeMatrix"/>.
|
|
/// </summary>
|
|
/// <param name="nodeCount">The count of nodes.</param>
|
|
/// <returns>The size required for the given <paramref name="nodeCount"/>.</returns>
|
|
public static int GetWorkBufferSize(int nodeCount)
|
|
{
|
|
int size = BitUtils.AlignUp(nodeCount * nodeCount, RendererConstants.BufferAlignment);
|
|
|
|
return size / Unsafe.SizeOf<byte>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes the <see cref="EdgeMatrix"/> instance with backing memory.
|
|
/// </summary>
|
|
/// <param name="edgeMatrixWorkBuffer">The backing memory.</param>
|
|
/// <param name="nodeCount">The count of nodes.</param>
|
|
public void Initialize(Memory<byte> edgeMatrixWorkBuffer, int nodeCount)
|
|
{
|
|
Debug.Assert(edgeMatrixWorkBuffer.Length >= GetWorkBufferSize(nodeCount));
|
|
|
|
_storage = new BitArray(edgeMatrixWorkBuffer);
|
|
|
|
_nodeCount = nodeCount;
|
|
|
|
_storage.Reset();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Test if the bit at the given index is set.
|
|
/// </summary>
|
|
/// <param name="index">A bit index.</param>
|
|
/// <returns>Returns true if the bit at the given index is set</returns>
|
|
public bool Test(int index)
|
|
{
|
|
return _storage.Test(index);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reset all bits in the storage.
|
|
/// </summary>
|
|
public void Reset()
|
|
{
|
|
_storage.Reset();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reset the bit at the given index.
|
|
/// </summary>
|
|
/// <param name="index">A bit index.</param>
|
|
public void Reset(int index)
|
|
{
|
|
_storage.Reset(index);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the bit at the given index.
|
|
/// </summary>
|
|
/// <param name="index">A bit index.</param>
|
|
public void Set(int index)
|
|
{
|
|
_storage.Set(index);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Connect a given source to a given destination.
|
|
/// </summary>
|
|
/// <param name="source">The source index.</param>
|
|
/// <param name="destination">The destination index.</param>
|
|
public void Connect(int source, int destination)
|
|
{
|
|
Debug.Assert(source < _nodeCount);
|
|
Debug.Assert(destination < _nodeCount);
|
|
|
|
_storage.Set(_nodeCount * source + destination);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if the given source is connected to the given destination.
|
|
/// </summary>
|
|
/// <param name="source">The source index.</param>
|
|
/// <param name="destination">The destination index.</param>
|
|
/// <returns>Returns true if the given source is connected to the given destination.</returns>
|
|
public bool Connected(int source, int destination)
|
|
{
|
|
Debug.Assert(source < _nodeCount);
|
|
Debug.Assert(destination < _nodeCount);
|
|
|
|
return _storage.Test(_nodeCount * source + destination);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Disconnect a given source from a given destination.
|
|
/// </summary>
|
|
/// <param name="source">The source index.</param>
|
|
/// <param name="destination">The destination index.</param>
|
|
public void Disconnect(int source, int destination)
|
|
{
|
|
Debug.Assert(source < _nodeCount);
|
|
Debug.Assert(destination < _nodeCount);
|
|
|
|
_storage.Reset(_nodeCount * source + destination);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove all edges from a given source.
|
|
/// </summary>
|
|
/// <param name="source">The source index.</param>
|
|
public void RemoveEdges(int source)
|
|
{
|
|
for (int i = 0; i < _nodeCount; i++)
|
|
{
|
|
Disconnect(source, i);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the total node count.
|
|
/// </summary>
|
|
/// <returns>The total node count.</returns>
|
|
public int GetNodeCount()
|
|
{
|
|
return _nodeCount;
|
|
}
|
|
}
|
|
}
|