Compare commits

...

23 Commits

Author SHA1 Message Date
4cf2419e6c HLE: Fix corrupted Mii structs (#5468)
* StructArrayHelpers: Add PureAttribute to all AsSpan() methods

* Fix broken Mii structs
2023-07-19 22:02:31 -03:00
440abac9f8 chore: Update Ryujinx.SDL2-CS to 2.28.1 (#5453) 2023-07-18 16:08:48 +02:00
732714349e [Hotfix] sockets: Resolve empty port requests to 0 again (#5459) 2023-07-17 20:47:47 +02:00
016262514d cpu: Hotfix missing ToNearest rounding mode cases 2023-07-16 20:39:08 +01:00
326749498b [Ryujinx.HLE] Address dotnet-format issues (#5380)
* 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 or silence dotnet format IDE1006 warnings

* Address dotnet format CA1816 warnings

* Address or silence dotnet format CA2208 warnings

* Address or silence dotnet format CA1806 and a few CA1854 warnings

* Address dotnet format CA2211 warnings

* Address dotnet format CA1822 warnings

* Address or silence dotnet format CA1069 warnings

* Make dotnet format succeed in style mode

* Address or silence dotnet format CA2211 warnings

* Address review comments

* Address dotnet format CA2208 warnings properly

* Make ProcessResult readonly

* 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

* Add previously silenced warnings back

I have no clue how these disappeared

* Revert formatting changes for while and for-loops

* Format if-blocks correctly

* Run dotnet format style after rebase

* Run dotnet format whitespace after rebase

* Run dotnet format style after rebase

* Run dotnet format analyzers after rebase

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Disable 'prefer switch expression' rule

* Add comments to disabled warnings

* Fix a few disabled warnings

* Fix naming rule violation, Convert shader properties to auto-property and convert values to const

* 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

* Run dotnet format after rebase

* Use using declaration instead of block syntax

* Address IDE0251 warnings

* Address a few disabled IDE0060 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

* First dotnet format pass

* Fix naming rule violations

* Fix typo

* Add trailing commas, use targeted new and use array initializer

* Fix build issues

* Fix remaining build issues

* Remove SuppressMessage for CA1069 where possible

* Address dotnet format issues

* Address formatting issues

Co-authored-by: Ac_K <acoustik666@gmail.com>

* Add GetHashCode implementation for RenderingSurfaceInfo

* Explicitly silence CA1822 for every affected method in Syscall

* Address formatting issues in Demangler.cs

* Address review feedback

Co-authored-by: Ac_K <acoustik666@gmail.com>

* Revert marking service methods as static

* Next dotnet format pass

* Address review feedback

---------

Co-authored-by: Ac_K <acoustik666@gmail.com>
2023-07-16 19:31:14 +02:00
fec8291c17 infra: do not assign developers team for now
Hopefully fix PR triage for real...
2023-07-14 11:32:14 +02:00
c5d9e67cb2 Fix some Vulkan validation errors (#5452)
* Fix some validation errors and silence the annoying pipeline barrier error

* Remove bogus decref/incref on index buffer state

* Make unsafe blit opt-in rather than opt-out

* Remove Vulkan debugger messages blacklist

* Adjust GetImageUsage to not set the storage bit for multisample textures if not supported
2023-07-14 09:08:52 +02:00
e5261228d7 infra: Fix team name in reviewer.yml 2023-07-12 19:22:09 +02:00
e61c09bc85 infra: Fix PR triage once and for all (#5442)
Switch to a custom made python script that query GitHub API to grab latest state of the PR after label assign.
2023-07-12 18:31:08 +02:00
ac2444f908 Move ShaderBinaries into individual .spv files (#5280)
* Move ShaderBinaries into individual spv files

* Rename binaries directory, remove variables and add helper method instead

* Update .csproj file

* Move ShaderBinaries into individual spv files

* Rename binaries directory, remove variables and add helper method instead

* Split shader binaries into folders, use string.Join to create filepath

* Move files back to general binaries folder

* Remove ShaderSource suffix from file names

---------

Co-authored-by: Egor Alekseychik <e.alekseychik@syberry.com>
Co-authored-by: Gabriel A <gab.dark.100@gmail.com>
2023-07-11 14:41:18 -03:00
9c6071a645 Move support buffer update out of the backends (#5411)
* Move support buffer update out of the backends

* Fix render scale init and remove redundant state from SupportBufferUpdater

* Stop passing texture scale to the backends

* XML docs for SupportBufferUpdater
2023-07-11 14:07:41 -03:00
fa32ef9275 MacOS: Allow barriers inside a render pass for non-Apple GPUs and don't treat as TBDR (#5440)
* MoltenVK: Allow barriers inside a render pass on non-Apple GPUs

* Don't treat all non-Apple GPUs using MoltenVK as TBDR
2023-07-11 03:10:23 +02:00
7805d27e67 MacOS: Fix rendering on AMD GPUs (#5446)
* MacOS: Fix rendering on AMD GPUs

* Only disable MultiViewPort on MoltenVK for AMD GPUs
2023-07-11 03:00:19 +02:00
6c515e1822 [Ryujinx.Ava] Address dotnet-format issues (#5361)
* 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

* Silence dotnet format IDE0059 warnings

* Address or silence dotnet format IDE1006 warnings

* Address dotnet format CA1816 warnings

* Address dotnet format CA1822 warnings

* Address or silence dotnet format CA1069 warnings

* Make dotnet format succeed in style mode

* Address dotnet format CA1401 warnings

* Address remaining dotnet format analyzer warnings

* Address review comments

* dotnet-format fixes after rebase

* 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

* Another rebase, another dotnet format run

* Run dotnet format whitespace after rebase

* Run dotnet format style 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 IDE0260 warnings

* Address a few disabled IDE0060 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

* dotnet format pass with new editorconfig

* Fix naming style issues

* Apply suggestions from code review

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Revert one suggestion

* Second dotnet format pass and fix build issues

* Final pass of dotnet format

* Add trailing commas

* Fix formatting issues

* Keep unnecessary assignment in IconColorPicker.cs

* Use using declarations and extend resource lifetimes

* Fix rebase issues

* Adjust comment spacing

* Fix typo

* Fix naming issues

* Apply suggestions from code review

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Revert unintentional change

* Remove unused file

* Remove static keyword from ViewModels

Binding of static members doesn't work and is silently ignored.

---------

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2023-07-07 23:03:27 +02:00
8a363b5df2 Revert "sdl: set SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS to 0 (#5433)" (#5439)
This reverts commit 2b5abac809.
2023-07-06 18:08:14 +02:00
2b5abac809 sdl: set SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS to 0 (#5433)
Nintendo controllers notoriously have the A/B and X/Y buttons swapped, compared to the standard.
In order to combat this, when setting the default controller layout, Ryujinx checks whether the controller name contains "Nintendo", and swaps the mapping accordingly.
However, the reason the mapping is inverted in the first place is because SDL has `SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS` set to 1 by default. By setting it to 0, the mapping will be based on the buttons' position instead.
So, by doing it (and removing the `isNintendoStyle` variable), we get the following advantages:
- The mapping will be the same on all controllers, removing the need to adjust custom mappings depending on what controller is used
- Users who already set `SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS` to 0 globally for other games/applications (like me) won't have a wrong default mapping
- Checking whether the controller name contains "Nintendo" is ugly

Disadvantages:
- Breaks the controller configuration for existing users who are using a Nintendo controller
2023-07-06 17:11:26 +02:00
c19c8bbade Headless: Add support for fullscreen option (#5339)
* Headless: Added support for fullscreen option

* Headless: cleanup of fullscreen support

* Headless: fullscreen support : implemented proposed changes

* Headless: fullscreen support: cleanup

* Headless: fullscreen support: fix for OpenGL scaling

* Headless: fullscreen support: cleanup

* Headless: fullscreen support: cleanup

* Headless: fullscreen support: add. macOS fullscreen fix

* Headless: fullscreen support: cleanup

* Headless: fullscreen support: cleanup

* Headless: fullscreen support: cleanup
2023-07-06 12:10:15 +02:00
1c7a90ef35 Stop identifying shader textures with handle and cbuf, use binding instead (#5266)
* Stop identifying shader textures with handle and cbuf, use binding instead

* Remove now unused code

* Consider image operations as having accurate type information too

I don't know why that was not the case before

* Fix missing unscale on InsertCoordNormalization, stop calling SetUsageFlagsForTextureQuery when not needed

* Shader cache version bump

* Change get texture methods to return descriptors created from ResourceManager state

 This is required to ensure that reserved textures and images will not be bound as a guest texture/image

* Fix BindlessElimination.SetHandle inserting coords at the wrong place
2023-07-03 14:29:27 -03:00
3b46bb73f7 [Ryujinx.Graphics.Gpu] Address dotnet-format issues (#5367)
* 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 CA1069 warnings

* Address or silence dotnet format CA2211 warnings

* Address remaining dotnet format analyzer 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 style after rebase

* Another rebase, another dotnet format run

* Run dotnet format style after rebase

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Disable 'prefer switch expression' rule

* Add comments to disabled warnings

* Remove a few unused parameters

* Replace MmeShadowScratch with Array256<uint>

* 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

* Run dotnet format after rebase

* 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

* First pass of dotnet format

* Add unsafe dotnet format changes

* Fix typos

* Add trailing commas

* Disable formatting for FormatTable

* Address review feedback
2023-07-02 02:47:54 +02:00
2457cfc911 Fix naming issue in ControllerWindow (#5424) 2023-07-02 02:26:32 +02:00
515fc32b21 [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>
2023-07-02 01:27:18 +02:00
0684b00b3c [Ryujinx] Address dotnet-format issues (#5395)
* 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

* Address dotnet format CA1816 warnings

* Address or silence dotnet format CA2208 warnings

* Address or silence dotnet format CA1806 and a few CA1854 warnings

* Address dotnet format CA1822 warnings

* Make dotnet format succeed in style mode

* Address dotnet format CA2208 warnings properly

* 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

* Another rebase, another dotnet format run

* Run dotnet format whitespace after rebase

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Add comments to disabled warnings

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"

This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.

* dotnet format whitespace after rebase

* First dotnet format pass

* Fix build issues

* Apply suggestions from code review

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Second dotnet format pass

* Update src/Ryujinx/Modules/Updater/Updater.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Add trailing commas and improve formatting

* Fix formatting and naming issues

* Rename nvStutterWorkaround to nvidiaStutterWorkaround

* Use using declarations and extend resource lifetimes

* Fix GTK issues

* Add formatting for generated files

* Add trailing commas

---------

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2023-07-02 00:25:07 +02:00
02b5c7ea89 [Ryujinx.Horizon] Address dotnet-format issues (#5381)
* 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 CA1822 warnings

* 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

* Revert formatting changes for while and for-loops

* Run dotnet format whitespace after rebase

* Run dotnet format style 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

* 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

* First dotnet format pass

* Add trailing commas and fix formatting issues

* Convert if-else chain to switch block

* Address review feedback
2023-07-01 12:42:10 +02:00
1726 changed files with 16066 additions and 18635 deletions

View File

@ -1,8 +0,0 @@
addReviewers: true
reviewers:
- marysaka
filterLabels:
include:
- audio

View File

@ -1,11 +0,0 @@
addReviewers: true
reviewers:
- gdkchan
- riperiperi
- marysaka
- LDj3SNuD
filterLabels:
include:
- cpu

View File

@ -1,4 +0,0 @@
addReviewers: true
reviewers:
- Ryujinx/developers

View File

@ -1,10 +0,0 @@
addReviewers: true
reviewers:
- gdkchan
- riperiperi
- marysaka
filterLabels:
include:
- gpu

View File

@ -1,11 +0,0 @@
addReviewers: true
reviewers:
- Ack77
- emmauss
- TSRBerry
- marysaka
filterLabels:
include:
- gui

View File

@ -1,11 +0,0 @@
addReviewers: true
reviewers:
- gdkchan
- Ack77
- marysaka
- TSRBerry
filterLabels:
include:
- horizon

View File

@ -1,9 +0,0 @@
addReviewers: true
reviewers:
- marysaka
- TSRBerry
filterLabels:
include:
- infra

32
.github/reviewers.yml vendored Normal file
View File

@ -0,0 +1,32 @@
audio:
- marysaka
cpu:
- gdkchan
- riperiperi
- marysaka
- LDj3SNuD
gpu:
- gdkchan
- riperiperi
- marysaka
gui:
- Ack77
- emmauss
- TSRBerry
- marysaka
horizon:
- gdkchan
- Ack77
- marysaka
- TSRBerry
infra:
- marysaka
- TSRBerry
default:
- marysaka

79
.github/update_reviewers.py vendored Normal file
View File

@ -0,0 +1,79 @@
from pathlib import Path
from typing import List, Set
from github import Github
from github.Repository import Repository
from github.GithubException import GithubException
import sys
import yaml
def add_reviewers(
reviewers: Set[str], team_reviewers: Set[str], new_entries: List[str]
):
for reviewer in new_entries:
if reviewer.startswith("@"):
team_reviewers.add(reviewer[1:])
else:
reviewers.add(reviewer)
def update_reviewers(config, repo: Repository, pr_id: int) -> int:
pull_request = repo.get_pull(pr_id)
if not pull_request:
sys.stderr.writable(f"Unknown PR #{pr_id}\n")
return 1
pull_request_author = pull_request.user.login
reviewers = set()
team_reviewers = set()
for label in pull_request.labels:
if label.name in config:
add_reviewers(reviewers, team_reviewers, config[label.name])
if "default" in config:
add_reviewers(reviewers, team_reviewers, config["default"])
if pull_request_author in reviewers:
reviewers.remove(pull_request_author)
try:
reviewers = list(reviewers)
team_reviewers = list(team_reviewers)
print(
f"Attempting to assign reviewers ({reviewers}) and team_reviewers ({team_reviewers})"
)
pull_request.create_review_request(reviewers, team_reviewers)
return 0
except GithubException as e:
sys.stderr.write(f"Cannot assign review request for PR #{pr_id}: {e}\n")
return 1
if __name__ == "__main__":
if len(sys.argv) != 5:
sys.stderr.write("usage: <token> <repo_path> <pr_id> <config_path>\n")
sys.exit(1)
token = sys.argv[1]
repo_path = sys.argv[2]
pr_id = int(sys.argv[3])
config_path = Path(sys.argv[4])
g = Github(token)
repo = g.get_repo(repo_path)
if not repo:
sys.stderr.write("Repository not found!\n")
sys.exit(1)
if not config_path.exists():
sys.stderr.write(f'Config "{config_path}" not found!\n')
sys.exit(1)
with open(config_path, "r") as f:
config = yaml.safe_load(f)
sys.exit(update_reviewers(config, repo, pr_id))

View File

@ -12,43 +12,23 @@ jobs:
runs-on: ubuntu-latest
steps:
# Grab sources to get update_reviewers.py and reviewers.yml
- name: Fetch sources
uses: actions/checkout@v3
with:
# Ensure we pin the source origin as pull_request_target run under forks.
fetch-depth: 0
repository: Ryujinx/Ryujinx
ref: master
- name: Update labels based on changes
uses: actions/labeler@v4
with:
sync-labels: true
dot: true
- name: Auto Assign [Audio]
uses: kentaro-m/auto-assign-action@v1.2.5
with:
configuration-path: '.github/assign/audio.yml'
- name: Auto Assign [CPU]
uses: kentaro-m/auto-assign-action@v1.2.5
with:
configuration-path: '.github/assign/cpu.yml'
- name: Auto Assign [GPU]
uses: kentaro-m/auto-assign-action@v1.2.5
with:
configuration-path: '.github/assign/gpu.yml'
- name: Auto Assign [GUI]
uses: kentaro-m/auto-assign-action@v1.2.5
with:
configuration-path: '.github/assign/gui.yml'
- name: Auto Assign [Horizon]
uses: kentaro-m/auto-assign-action@v1.2.5
with:
configuration-path: '.github/assign/horizon.yml'
- name: Auto Assign [Infra]
uses: kentaro-m/auto-assign-action@v1.2.5
with:
configuration-path: '.github/assign/infra.yml'
- name: Auto Assign [Global]
uses: kentaro-m/auto-assign-action@v1.2.5
with:
configuration-path: '.github/assign/global.yml'
- name: Assign reviewers
run: |
pip3 install PyGithub
python3 .github/update_reviewers.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.event.pull_request.number }} .github/reviewers.yml
shell: bash

View File

@ -34,7 +34,7 @@
<PackageVersion Include="Ryujinx.Graphics.Nvdec.Dependencies" Version="5.0.1-build13" />
<PackageVersion Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Version="1.2.0" />
<PackageVersion Include="Ryujinx.GtkSharp" Version="3.24.24.59-ryujinx" />
<PackageVersion Include="Ryujinx.SDL2-CS" Version="2.26.3-build25" />
<PackageVersion Include="Ryujinx.SDL2-CS" Version="2.28.1-build28" />
<PackageVersion Include="shaderc.net" Version="0.1.0" />
<PackageVersion Include="SharpZipLib" Version="1.4.2" />
<PackageVersion Include="Silk.NET.Vulkan" Version="2.16.0" />

View File

@ -1448,6 +1448,7 @@ namespace ARMeilleure.Instructions
{
var overflowToInf = fpcr.GetRoundingMode() switch
{
FPRoundingMode.ToNearest => true,
FPRoundingMode.TowardsPlusInfinity => !sign,
FPRoundingMode.TowardsMinusInfinity => sign,
FPRoundingMode.TowardsZero => false,
@ -2879,6 +2880,7 @@ namespace ARMeilleure.Instructions
{
var overflowToInf = fpcr.GetRoundingMode() switch
{
FPRoundingMode.ToNearest => true,
FPRoundingMode.TowardsPlusInfinity => !sign,
FPRoundingMode.TowardsMinusInfinity => sign,
FPRoundingMode.TowardsZero => false,

View File

@ -16,17 +16,17 @@ namespace Ryujinx.Audio
/// <summary>
/// Events signaled when the driver played audio buffers.
/// </summary>
private ManualResetEvent[] _updateRequiredEvents;
private readonly ManualResetEvent[] _updateRequiredEvents;
/// <summary>
/// Action to execute when the driver played audio buffers.
/// </summary>
private Action[] _actions;
private readonly Action[] _actions;
/// <summary>
/// The worker thread in charge of handling sessions update.
/// </summary>
private Thread _workerThread;
private readonly Thread _workerThread;
private bool _isRunning;
@ -44,7 +44,7 @@ namespace Ryujinx.Audio
_workerThread = new Thread(Update)
{
Name = "AudioManager.Worker"
Name = "AudioManager.Worker",
};
}
@ -115,6 +115,7 @@ namespace Ryujinx.Audio
public void Dispose()
{
GC.SuppressFinalize(this);
Dispose(true);
}
@ -129,4 +130,4 @@ namespace Ryujinx.Audio
}
}
}
}
}

View File

@ -23,4 +23,4 @@ namespace Ryujinx.Audio.Backends.Common
return bufferSize / GetSampleSize(format) / channelCount;
}
}
}
}

View File

@ -163,4 +163,4 @@ namespace Ryujinx.Audio.Backends.Common
}
}
}
}
}

View File

@ -66,14 +66,11 @@ namespace Ryujinx.Audio.Backends.Common
return false;
}
if (buffer.Data == null)
{
buffer.Data = samples;
}
buffer.Data ??= samples;
return true;
}
public virtual void UnregisterBuffer(AudioBuffer buffer) { }
}
}
}

View File

@ -6,14 +6,13 @@ using Ryujinx.Common.Logging;
using Ryujinx.Memory;
using System;
using System.Threading;
using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
namespace Ryujinx.Audio.Backends.CompatLayer
{
public class CompatLayerHardwareDeviceDriver : IHardwareDeviceDriver
{
private IHardwareDeviceDriver _realDriver;
private readonly IHardwareDeviceDriver _realDriver;
public static bool IsSupported => true;
@ -24,6 +23,7 @@ namespace Ryujinx.Audio.Backends.CompatLayer
public void Dispose()
{
GC.SuppressFinalize(this);
_realDriver.Dispose();
}
@ -49,7 +49,7 @@ namespace Ryujinx.Audio.Backends.CompatLayer
6 => SelectHardwareChannelCount(2),
2 => SelectHardwareChannelCount(1),
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...");
return new DummyHardwareDeviceSessionInput(this, memoryManager, sampleFormat, sampleRate, channelCount);
return new DummyHardwareDeviceSessionInput(this, memoryManager);
}
throw new NotImplementedException();
@ -138,12 +138,12 @@ namespace Ryujinx.Audio.Backends.CompatLayer
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.
realSession.Dispose();
return new DummyHardwareDeviceSessionInput(this, memoryManager, sampleFormat, sampleRate, channelCount);
return new DummyHardwareDeviceSessionInput(this, memoryManager);
}
// It must be a HardwareDeviceSessionOutputBase.
@ -183,4 +183,4 @@ namespace Ryujinx.Audio.Backends.CompatLayer
return direction == Direction.Input || direction == Direction.Output;
}
}
}
}

View File

@ -8,9 +8,9 @@ namespace Ryujinx.Audio.Backends.CompatLayer
{
class CompatLayerHardwareDeviceSession : HardwareDeviceSessionOutputBase
{
private HardwareDeviceSessionOutputBase _realSession;
private SampleFormat _userSampleFormat;
private uint _userChannelCount;
private readonly HardwareDeviceSessionOutputBase _realSession;
private readonly SampleFormat _userSampleFormat;
private readonly uint _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();
}
AudioBuffer fakeBuffer = new AudioBuffer
AudioBuffer fakeBuffer = new()
{
BufferTag = buffer.BufferTag,
DataPointer = buffer.DataPointer,
DataSize = (ulong)samples.Length
DataSize = (ulong)samples.Length,
};
bool result = _realSession.RegisterBuffer(fakeBuffer, samples);
@ -159,4 +159,4 @@ namespace Ryujinx.Audio.Backends.CompatLayer
return _realSession.WasBufferFullyConsumed(buffer);
}
}
}
}

View File

@ -31,18 +31,18 @@ namespace Ryujinx.Audio.Backends.CompatLayer
private const int Minus6dBInQ15 = (int)(0.501f * 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,
Minus3dBInQ15,
Minus12dBInQ15,
Minus3dBInQ15
Minus3dBInQ15,
};
private static readonly int[] DefaultStereoToMonoCoefficients = new int[2]
private static readonly int[] _defaultStereoToMonoCoefficients = new int[2]
{
Minus6dBInQ15,
Minus6dBInQ15
Minus6dBInQ15,
};
private const int SurroundChannelCount = 6;
@ -114,12 +114,12 @@ namespace Ryujinx.Audio.Backends.CompatLayer
public static short[] DownMixStereoToMono(ReadOnlySpan<short> data)
{
return DownMixStereoToMono(DefaultStereoToMonoCoefficients, data);
return DownMixStereoToMono(_defaultStereoToMonoCoefficients, data);
}
public static short[] DownMixSurroundToStereo(ReadOnlySpan<short> data)
{
return DownMixSurroundToStereo(DefaultSurroundToStereoCoefficients, data);
return DownMixSurroundToStereo(_defaultSurroundToStereoCoefficients, data);
}
}
}
}

View File

@ -1,16 +1,16 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Integration;
using Ryujinx.Memory;
using System;
using System.Threading;
using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
namespace Ryujinx.Audio.Backends.Dummy
{
public class DummyHardwareDeviceDriver : IHardwareDeviceDriver
{
private ManualResetEvent _updateRequiredEvent;
private ManualResetEvent _pauseEvent;
private readonly ManualResetEvent _updateRequiredEvent;
private readonly ManualResetEvent _pauseEvent;
public static bool IsSupported => true;
@ -36,10 +36,8 @@ namespace Ryujinx.Audio.Backends.Dummy
{
return new DummyHardwareDeviceSessionOutput(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
}
else
{
return new DummyHardwareDeviceSessionInput(this, memoryManager, sampleFormat, sampleRate, channelCount);
}
return new DummyHardwareDeviceSessionInput(this, memoryManager);
}
public ManualResetEvent GetUpdateRequiredEvent()
@ -54,6 +52,7 @@ namespace Ryujinx.Audio.Backends.Dummy
public void Dispose()
{
GC.SuppressFinalize(this);
Dispose(true);
}
@ -86,4 +85,4 @@ namespace Ryujinx.Audio.Backends.Dummy
return channelCount == 1 || channelCount == 2 || channelCount == 6;
}
}
}
}

View File

@ -8,10 +8,10 @@ namespace Ryujinx.Audio.Backends.Dummy
class DummyHardwareDeviceSessionInput : IHardwareDeviceSession
{
private float _volume;
private IHardwareDeviceDriver _manager;
private IVirtualMemoryManager _memoryManager;
private readonly IHardwareDeviceDriver _manager;
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;
_manager = manager;
@ -64,4 +64,4 @@ namespace Ryujinx.Audio.Backends.Dummy
return true;
}
}
}
}

View File

@ -9,7 +9,7 @@ namespace Ryujinx.Audio.Backends.Dummy
internal class DummyHardwareDeviceSessionOutput : HardwareDeviceSessionOutputBase
{
private float _volume;
private IHardwareDeviceDriver _manager;
private readonly IHardwareDeviceDriver _manager;
private ulong _playedSampleCount;
@ -59,4 +59,4 @@ namespace Ryujinx.Audio.Backends.Dummy
return true;
}
}
}
}

View File

@ -34,4 +34,4 @@ namespace Ryujinx.Audio.Common
/// </summary>
public byte[] Data;
}
}
}

View File

@ -23,7 +23,7 @@ namespace Ryujinx.Audio.Common
/// <summary>
/// Array of all buffers currently used or released.
/// </summary>
private AudioBuffer[] _buffers;
private readonly AudioBuffer[] _buffers;
/// <summary>
/// The server index inside <see cref="_buffers"/> (appended but not queued to device driver).
@ -58,17 +58,17 @@ namespace Ryujinx.Audio.Common
/// <summary>
/// The released buffer event.
/// </summary>
private IWritableEvent _bufferEvent;
private readonly IWritableEvent _bufferEvent;
/// <summary>
/// The session on the device driver.
/// </summary>
private IHardwareDeviceSession _hardwareDeviceSession;
private readonly IHardwareDeviceSession _hardwareDeviceSession;
/// <summary>
/// Max number of buffers that can be registered to the device driver at a time.
/// </summary>
private uint _bufferRegisteredLimit;
private readonly uint _bufferRegisteredLimit;
/// <summary>
/// Create a new <see cref="AudioDeviceSession"/>.
@ -311,9 +311,9 @@ namespace Ryujinx.Audio.Common
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.
return false;
@ -425,10 +425,8 @@ namespace Ryujinx.Audio.Common
{
return 0;
}
else
{
return _hardwareDeviceSession.GetPlayedSampleCount();
}
return _hardwareDeviceSession.GetPlayedSampleCount();
}
/// <summary>
@ -515,4 +513,4 @@ namespace Ryujinx.Audio.Common
}
}
}
}
}

View File

@ -13,6 +13,6 @@ namespace Ryujinx.Audio.Common
/// <summary>
/// The audio device is stopped.
/// </summary>
Stopped
Stopped,
}
}
}

View File

@ -24,6 +24,6 @@ namespace Ryujinx.Audio.Common
/// <summary>
/// Reserved/unused.
/// </summary>
private ushort _reserved;
private readonly ushort _reserved;
}
}
}

View File

@ -34,4 +34,4 @@ namespace Ryujinx.Audio.Common
/// </summary>
public AudioDeviceState AudioOutState;
}
}
}

View File

@ -33,4 +33,4 @@ namespace Ryujinx.Audio.Common
/// </summary>
public ulong DataOffset;
}
}
}

View File

@ -38,6 +38,6 @@ namespace Ryujinx.Audio.Common
/// <summary>
/// ADPCM sample format. (Also known as GC-ADPCM)
/// </summary>
Adpcm = 6
Adpcm = 6,
}
}
}

View File

@ -172,4 +172,4 @@ namespace Ryujinx.Audio
0.707f,
};
}
}
}

View File

@ -24,7 +24,7 @@ namespace Ryujinx.Audio.Input
/// <summary>
/// The session ids allocation table.
/// </summary>
private int[] _sessionIds;
private readonly int[] _sessionIds;
/// <summary>
/// The device driver.
@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Input
/// <summary>
/// The <see cref="AudioInputSystem"/> session instances.
/// </summary>
private AudioInputSystem[] _sessions;
private readonly AudioInputSystem[] _sessions;
/// <summary>
/// The count of active sessions.
@ -166,6 +166,7 @@ namespace Ryujinx.Audio.Input
/// </summary>
/// <param name="filtered">If true, filter disconnected devices</param>
/// <returns>The list of all audio inputs name</returns>
#pragma warning disable CA1822 // Mark member as static
public string[] ListAudioIns(bool filtered)
{
if (filtered)
@ -173,8 +174,9 @@ namespace Ryujinx.Audio.Input
// TODO: Detect if the driver supports audio input
}
return new string[] { Constants.DefaultDeviceInputName };
return new[] { Constants.DefaultDeviceInputName };
}
#pragma warning restore CA1822
/// <summary>
/// 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);
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);
@ -238,6 +240,8 @@ namespace Ryujinx.Audio.Input
public void Dispose()
{
GC.SuppressFinalize(this);
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
{
Dispose(true);
@ -263,4 +267,4 @@ namespace Ryujinx.Audio.Input
}
}
}
}
}

View File

@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Input
/// <summary>
/// The session the <see cref="AudioInputSystem"/>.
/// </summary>
private AudioDeviceSession _session;
private readonly AudioDeviceSession _session;
/// <summary>
/// The target device name of the <see cref="AudioInputSystem"/>.
@ -43,7 +43,7 @@ namespace Ryujinx.Audio.Input
/// <summary>
/// The <see cref="AudioInputManager"/> owning this.
/// </summary>
private AudioInputManager _manager;
private readonly AudioInputManager _manager;
/// <summary>
/// The lock of the parent.
@ -90,11 +90,13 @@ namespace Ryujinx.Audio.Input
{
return ResultCode.DeviceNotFound;
}
else if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
{
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;
}
@ -185,11 +187,11 @@ namespace Ryujinx.Audio.Input
{
lock (_parentLock)
{
AudioBuffer buffer = new AudioBuffer
AudioBuffer buffer = new()
{
BufferTag = bufferTag,
DataPointer = userBuffer.Data,
DataSize = userBuffer.DataSize
DataSize = userBuffer.DataSize,
};
if (_session.AppendBuffer(buffer))
@ -213,14 +215,14 @@ namespace Ryujinx.Audio.Input
{
lock (_parentLock)
{
AudioBuffer buffer = new AudioBuffer
AudioBuffer buffer = new()
{
BufferTag = bufferTag,
DataPointer = userBuffer.Data,
DataSize = userBuffer.DataSize
DataSize = userBuffer.DataSize,
};
if (_session.AppendUacBuffer(buffer, handle))
if (AudioDeviceSession.AppendUacBuffer(buffer, handle))
{
return ResultCode.Success;
}
@ -373,6 +375,8 @@ namespace Ryujinx.Audio.Input
public void Dispose()
{
GC.SuppressFinalize(this);
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
{
Dispose(true);
@ -389,4 +393,4 @@ namespace Ryujinx.Audio.Input
}
}
}
}
}

View File

@ -6,12 +6,12 @@ namespace Ryujinx.Audio.Integration
{
public class HardwareDeviceImpl : IHardwareDevice
{
private IHardwareDeviceSession _session;
private uint _channelCount;
private uint _sampleRate;
private readonly IHardwareDeviceSession _session;
private readonly uint _channelCount;
private readonly uint _sampleRate;
private uint _currentBufferTag;
private byte[] _buffer;
private readonly byte[] _buffer;
public HardwareDeviceImpl(IHardwareDeviceDriver deviceDriver, uint channelCount, uint sampleRate, float volume)
{
@ -36,7 +36,7 @@ namespace Ryujinx.Audio.Integration
DataSize = (ulong)_buffer.Length,
});
_currentBufferTag = _currentBufferTag % 4;
_currentBufferTag %= 4;
}
public void SetVolume(float volume)
@ -61,6 +61,7 @@ namespace Ryujinx.Audio.Integration
public void Dispose()
{
GC.SuppressFinalize(this);
Dispose(true);
}
@ -72,4 +73,4 @@ namespace Ryujinx.Audio.Integration
}
}
}
}
}

View File

@ -52,4 +52,4 @@ namespace Ryujinx.Audio.Integration
return channelCount != Constants.ChannelCountMax;
}
}
}
}

View File

@ -13,7 +13,7 @@ namespace Ryujinx.Audio.Integration
public enum Direction
{
Input,
Output
Output,
}
IHardwareDeviceSession OpenDeviceSession(Direction direction, IVirtualMemoryManager memoryManager, SampleFormat sampleFormat, uint sampleRate, uint channelCount, float volume = 1f);
@ -33,4 +33,4 @@ namespace Ryujinx.Audio.Integration
return this;
}
}
}
}

View File

@ -25,4 +25,4 @@ namespace Ryujinx.Audio.Integration
void PrepareToClose();
}
}
}

View File

@ -15,4 +15,4 @@ namespace Ryujinx.Audio.Integration
/// </summary>
void Clear();
}
}
}

View File

@ -24,7 +24,7 @@ namespace Ryujinx.Audio.Output
/// <summary>
/// The session ids allocation table.
/// </summary>
private int[] _sessionIds;
private readonly int[] _sessionIds;
/// <summary>
/// The device driver.
@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Output
/// <summary>
/// The <see cref="AudioOutputSystem"/> session instances.
/// </summary>
private AudioOutputSystem[] _sessions;
private readonly AudioOutputSystem[] _sessions;
/// <summary>
/// The count of active sessions.
@ -165,10 +165,12 @@ namespace Ryujinx.Audio.Output
/// Get the list of all audio outputs name.
/// </summary>
/// <returns>The list of all audio outputs name</returns>
#pragma warning disable CA1822 // Mark member as static
public string[] ListAudioOuts()
{
return new string[] { Constants.DefaultDeviceOutputName };
return new[] { Constants.DefaultDeviceOutputName };
}
#pragma warning restore CA1822
/// <summary>
/// Open a new <see cref="AudioOutputSystem"/>.
@ -182,6 +184,7 @@ namespace Ryujinx.Audio.Output
/// <param name="parameter">The user configuration</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="volume">The volume level to request</param>
/// <returns>A <see cref="ResultCode"/> reporting an error or a success</returns>
public ResultCode OpenAudioOut(out string outputDeviceName,
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);
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);
@ -268,6 +271,8 @@ namespace Ryujinx.Audio.Output
public void Dispose()
{
GC.SuppressFinalize(this);
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
{
Dispose(true);
@ -293,4 +298,4 @@ namespace Ryujinx.Audio.Output
}
}
}
}
}

View File

@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Output
/// <summary>
/// The session the <see cref="AudioOutputSystem"/>.
/// </summary>
private AudioDeviceSession _session;
private readonly AudioDeviceSession _session;
/// <summary>
/// The target device name of the <see cref="AudioOutputSystem"/>.
@ -43,7 +43,7 @@ namespace Ryujinx.Audio.Output
/// <summary>
/// The <see cref="AudioOutputManager"/> owning this.
/// </summary>
private AudioOutputManager _manager;
private readonly AudioOutputManager _manager;
/// <summary>
/// THe lock of the parent.
@ -90,11 +90,13 @@ namespace Ryujinx.Audio.Output
{
return ResultCode.DeviceNotFound;
}
else if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
{
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;
}
@ -185,11 +187,11 @@ namespace Ryujinx.Audio.Output
{
lock (_parentLock)
{
AudioBuffer buffer = new AudioBuffer
AudioBuffer buffer = new()
{
BufferTag = bufferTag,
DataPointer = userBuffer.Data,
DataSize = userBuffer.DataSize
DataSize = userBuffer.DataSize,
};
if (_session.AppendBuffer(buffer))
@ -346,6 +348,8 @@ namespace Ryujinx.Audio.Output
public void Dispose()
{
GC.SuppressFinalize(this);
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
{
Dispose(true);
@ -362,4 +366,4 @@ namespace Ryujinx.Audio.Output
}
}
}
}
}

View File

@ -10,4 +10,4 @@ namespace Ryujinx.Audio.Renderer.Common
public ulong ReturnBufferInfo;
public ulong ReturnBufferInfoBase;
}
}
}

View File

@ -16,7 +16,7 @@ namespace Ryujinx.Audio.Renderer.Common
/// <summary>
/// Reserved/padding.
/// </summary>
private uint _padding;
private readonly uint _padding;
/// <summary>
/// The flags given controlling behaviour of the audio renderer
@ -38,7 +38,7 @@ namespace Ryujinx.Audio.Renderer.Common
/// <summary>
/// Reserved/padding.
/// </summary>
private uint _padding;
private readonly uint _padding;
/// <summary>
/// Extra information given with the <see cref="ResultCode"/>
@ -47,4 +47,4 @@ namespace Ryujinx.Audio.Renderer.Common
public ulong ExtraErrorInfo;
}
}
}
}

View File

@ -147,4 +147,4 @@ namespace Ryujinx.Audio.Renderer.Common
return _nodeCount;
}
}
}
}

View File

@ -55,4 +55,4 @@ namespace Ryujinx.Audio.Renderer.Common
/// </summary>
Compressor,
}
}
}

View File

@ -38,6 +38,6 @@ namespace Ryujinx.Audio.Renderer.Common
/// <summary>
/// The memory pool is released. (client side only)
/// </summary>
Released = 6
Released = 6,
}
}
}

View File

@ -25,4 +25,4 @@ namespace Ryujinx.Audio.Renderer.Common
return (nodeId >> 16) & 0xFFF;
}
}
}
}

View File

@ -28,6 +28,6 @@ namespace Ryujinx.Audio.Renderer.Common
/// <summary>
/// Performance monitoring related node id (performance commands)
/// </summary>
Performance = 15
Performance = 15,
}
}
}

View File

@ -53,17 +53,17 @@ namespace Ryujinx.Audio.Renderer.Common
}
private int _nodeCount;
private EdgeMatrix _discovered;
private EdgeMatrix _finished;
private readonly EdgeMatrix _discovered;
private readonly EdgeMatrix _finished;
private Memory<int> _resultArray;
private Stack _stack;
private readonly Stack _stack;
private int _tsortResultIndex;
private enum NodeState : byte
{
Unknown,
Discovered,
Finished
Finished,
}
public NodeStates()
@ -88,16 +88,16 @@ namespace Ryujinx.Audio.Renderer.Common
int edgeMatrixWorkBufferSize = EdgeMatrix.GetWorkBufferSize(nodeCount);
_discovered.Initialize(nodeStatesWorkBuffer.Slice(0, edgeMatrixWorkBufferSize), nodeCount);
_discovered.Initialize(nodeStatesWorkBuffer[..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);
}
@ -120,7 +120,8 @@ namespace Ryujinx.Audio.Renderer.Common
return NodeState.Discovered;
}
else if (_finished.Test(index))
if (_finished.Test(index))
{
Debug.Assert(!_discovered.Test(index));
@ -158,7 +159,7 @@ namespace Ryujinx.Audio.Renderer.Common
public ReadOnlySpan<int> GetTsortResult()
{
return _resultArray.Span.Slice(0, _tsortResultIndex);
return _resultArray.Span[.._tsortResultIndex];
}
public bool Sort(EdgeMatrix edgeMatrix)
@ -226,4 +227,4 @@ namespace Ryujinx.Audio.Renderer.Common
return true;
}
}
}
}

View File

@ -15,6 +15,6 @@ namespace Ryujinx.Audio.Renderer.Common
PcmFloat,
Limiter,
CaptureBuffer,
Compressor
Compressor,
}
}
}

View File

@ -6,6 +6,6 @@ namespace Ryujinx.Audio.Renderer.Common
Voice,
SubMix,
FinalMix,
Sink
Sink,
}
}
}

View File

@ -18,6 +18,6 @@ namespace Ryujinx.Audio.Renderer.Common
/// <summary>
/// The user request the voice to be paused.
/// </summary>
Pause
Pause,
}
}
}

View File

@ -28,6 +28,6 @@ namespace Ryujinx.Audio.Renderer.Common
/// <summary>
/// No early reflection.
/// </summary>
Disabled
Disabled,
}
}
}

View File

@ -33,6 +33,6 @@ namespace Ryujinx.Audio.Renderer.Common
/// <summary>
/// Max delay. (used for delay line limits)
/// </summary>
Limit = NoDelay
Limit = NoDelay,
}
}
}

View File

@ -18,6 +18,6 @@ namespace Ryujinx.Audio.Renderer.Common
/// <summary>
/// The sink is a circular buffer.
/// </summary>
CircularBuffer
CircularBuffer,
}
}
}

View File

@ -1,3 +1,4 @@
using Ryujinx.Common.Memory;
using System.Runtime.CompilerServices;
namespace Ryujinx.Audio.Renderer.Common
@ -19,7 +20,9 @@ namespace Ryujinx.Audio.Renderer.Common
public uint Unknown24;
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;
@ -30,4 +33,4 @@ namespace Ryujinx.Audio.Renderer.Common
TotalSize = (uint)Unsafe.SizeOf<UpdateDataHeader>();
}
}
}
}

View File

@ -101,4 +101,4 @@ namespace Ryujinx.Audio.Renderer.Common
}
}
}
}
}

View File

@ -1,5 +1,4 @@
using System.Runtime.InteropServices;
using DspAddr = System.UInt64;
namespace Ryujinx.Audio.Renderer.Common
@ -77,6 +76,6 @@ namespace Ryujinx.Audio.Renderer.Common
/// <summary>
/// Padding/Reserved.
/// </summary>
private ushort _padding;
private readonly ushort _padding;
}
}
}

View File

@ -23,7 +23,7 @@ namespace Ryujinx.Audio.Renderer.Common
if (size != 0)
{
ulong alignedOffset = BitUtils.AlignUp<ulong>(Offset, (ulong)align);
ulong alignedOffset = BitUtils.AlignUp(Offset, (ulong)align);
if (alignedOffset + size <= (ulong)BackingMemory.Length)
{
@ -32,7 +32,7 @@ namespace Ryujinx.Audio.Renderer.Common
Offset = alignedOffset + size;
// Clear the memory to be sure that is does not contain any garbage.
result.Span.Fill(0);
result.Span.Clear();
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
{
return BitUtils.AlignUp<ulong>(currentSize, (ulong)align) + (ulong)Unsafe.SizeOf<T>() * count;
return BitUtils.AlignUp(currentSize, (ulong)align) + (ulong)Unsafe.SizeOf<T>() * count;
}
}
}
}

View File

@ -12,11 +12,11 @@ namespace Ryujinx.Audio.Renderer.Device
/// </summary>
public static readonly VirtualDevice[] Devices = new VirtualDevice[5]
{
new VirtualDevice("AudioStereoJackOutput", 2, true),
new VirtualDevice("AudioBuiltInSpeakerOutput", 2, false),
new VirtualDevice("AudioTvOutput", 6, false),
new VirtualDevice("AudioUsbDeviceOutput", 2, true),
new VirtualDevice("AudioExternalOutput", 6, true),
new("AudioStereoJackOutput", 2, true),
new("AudioBuiltInSpeakerOutput", 2, false),
new("AudioTvOutput", 6, false),
new("AudioUsbDeviceOutput", 2, true),
new("AudioExternalOutput", 6, true),
};
/// <summary>
@ -86,4 +86,4 @@ namespace Ryujinx.Audio.Renderer.Device
return Name;
}
}
}
}

View File

@ -24,4 +24,4 @@ namespace Ryujinx.Audio.Renderer.Device
Device = virtualDevice;
}
}
}
}

View File

@ -11,13 +11,15 @@ namespace Ryujinx.Audio.Renderer.Device
/// <summary>
/// The session registry, used to store the sessions of a given AppletResourceId.
/// </summary>
private Dictionary<ulong, VirtualDeviceSession[]> _sessionsRegistry = new Dictionary<ulong, VirtualDeviceSession[]>();
private readonly Dictionary<ulong, VirtualDeviceSession[]> _sessionsRegistry = new();
/// <summary>
/// The default <see cref="VirtualDevice"/>.
/// </summary>
/// <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];
#pragma warning restore CA1822
/// <summary>
/// The current active <see cref="VirtualDevice"/>.
@ -76,4 +78,4 @@ namespace Ryujinx.Audio.Renderer.Device
return virtualDeviceSession;
}
}
}
}

View File

@ -12,7 +12,9 @@ namespace Ryujinx.Audio.Renderer.Dsp
private const int SamplesPerFrame = 14;
private const int NibblesPerFrame = SamplesPerFrame + 2;
private const int BytesPerFrame = 8;
#pragma warning disable IDE0051 // Remove unused private member
private const int BitsPerFrame = BytesPerFrame * 8;
#pragma warning restore IDE0051
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint GetAdpcmDataSize(int sampleCount)
@ -64,10 +66,14 @@ namespace Ryujinx.Audio.Renderer.Dsp
private static short Saturate(int value)
{
if (value > short.MaxValue)
{
value = short.MaxValue;
}
if (value < short.MinValue)
{
value = short.MinValue;
}
return (short)value;
}
@ -109,7 +115,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
ReadOnlySpan<byte> targetInput;
targetInput = input.Slice(nibbles / 2);
targetInput = input[(nibbles / 2)..];
while (remaining > 0)
{
@ -213,4 +219,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
return decodedCount;
}
}
}
}

View File

@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
Start,
Stop,
RenderStart,
RenderEnd
RenderEnd,
}
private class RendererSession
@ -36,7 +36,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
private long _lastTime;
private long _playbackEnds;
private ManualResetEvent _event;
private readonly ManualResetEvent _event;
private ManualResetEvent _pauseEvent;
@ -45,6 +45,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
_event = new ManualResetEvent(false);
}
#pragma warning disable IDE0051 // Remove unused private member
private static uint GetHardwareChannelCount(IHardwareDeviceDriver deviceDriver)
{
// 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;
}
else
{
// NOTE: We default to stereo as this will get downmixed to mono by the compat layer if it's not compatible.
return 2;
}
// NOTE: We default to stereo as this will get downmixed to mono by the compat layer if it's not compatible.
return 2;
}
#pragma warning restore IDE0051
public void Start(IHardwareDeviceDriver deviceDriver, float volume)
{
@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
CommandList = commands,
RenderingLimit = renderingLimit,
AppletResourceId = appletResourceId
AppletResourceId = appletResourceId,
};
}
@ -171,7 +171,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
_workerThread = new Thread(Work)
{
Name = "AudioProcessor.Worker"
Name = "AudioProcessor.Worker",
};
_workerThread.Start();
@ -260,6 +260,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
public void Dispose()
{
GC.SuppressFinalize(this);
Dispose(true);
}
@ -271,4 +272,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
}
}
}
}

View File

@ -80,4 +80,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
}
}
}
}

View File

@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@ -29,7 +31,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
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;
NodeId = nodeId;
@ -57,7 +59,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat.Adpcm,
@ -72,4 +74,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
}
}

View File

@ -155,7 +155,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (readResult != context.SampleCount)
{
outputBuffer.Slice((int)readResult, (int)context.SampleCount - (int)readResult).Fill(0);
outputBuffer[(int)readResult..(int)context.SampleCount].Clear();
}
}
else
@ -170,4 +170,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
}
}

View File

@ -48,4 +48,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
BiquadFilterHelper.ProcessBiquadFilter(ref _parameter, ref state, outputBuffer, inputBuffer, context.SampleCount);
}
}
}
}

View File

@ -133,4 +133,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
}
}

View File

@ -21,4 +21,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
context.ClearBuffers();
}
}
}
}

View File

@ -71,7 +71,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
return (IntPtr)((float*)_buffersMemoryHandle.Pointer + index * _sampleCount);
}
throw new ArgumentOutOfRangeException();
throw new ArgumentOutOfRangeException(nameof(index), index, null);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -149,7 +149,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public void Dispose()
{
GC.SuppressFinalize(this);
_buffersMemoryHandle.Dispose();
}
}
}
}

View File

@ -32,6 +32,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
LimiterVersion2,
GroupedBiquadFilter,
CaptureBuffer,
Compressor
Compressor,
}
}
}

View File

@ -1,6 +1,7 @@
using Ryujinx.Audio.Renderer.Dsp.Effect;
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
@ -51,11 +52,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
if (_parameter.Status == Server.Effect.UsageState.Invalid)
if (_parameter.Status == UsageState.Invalid)
{
state = new CompressorState(ref _parameter);
}
else if (_parameter.Status == Server.Effect.UsageState.New)
else if (_parameter.Status == UsageState.New)
{
state.UpdateParameter(ref _parameter);
}

View File

@ -27,4 +27,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
context.CopyBuffer(OutputBufferIndex, InputBufferIndex);
}
}
}
}

View File

@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@ -37,7 +39,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
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;
NodeId = nodeId;
@ -72,24 +74,20 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
private static CommandType GetCommandTypeBySampleFormat(SampleFormat sampleFormat)
{
switch (sampleFormat)
return sampleFormat switch
{
case SampleFormat.Adpcm:
return CommandType.AdpcmDataSourceVersion2;
case SampleFormat.PcmInt16:
return CommandType.PcmInt16DataSourceVersion2;
case SampleFormat.PcmFloat:
return CommandType.PcmFloatDataSourceVersion2;
default:
throw new NotImplementedException($"{sampleFormat}");
}
SampleFormat.Adpcm => CommandType.AdpcmDataSourceVersion2,
SampleFormat.PcmInt16 => CommandType.PcmInt16DataSourceVersion2,
SampleFormat.PcmFloat => CommandType.PcmFloatDataSourceVersion2,
_ => throw new NotImplementedException($"{sampleFormat}"),
};
}
public void Process(CommandList context)
{
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat,
@ -99,10 +97,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ExtraParameterSize = ExtraParameterSize,
ChannelIndex = (int)ChannelIndex,
ChannelCount = (int)ChannelCount,
SrcQuality = SrcQuality
SrcQuality = SrcQuality,
};
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
}
}

View File

@ -87,18 +87,18 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
Matrix2x2 delayFeedback = new Matrix2x2(delayFeedbackBaseGain, delayFeedbackCrossGain,
Matrix2x2 delayFeedback = new(delayFeedbackBaseGain, delayFeedbackCrossGain,
delayFeedbackCrossGain, delayFeedbackBaseGain);
for (int i = 0; i < sampleCount; i++)
{
Vector2 channelInput = new Vector2
Vector2 channelInput = new()
{
X = *((float*)inputBuffers[0] + i) * 64,
Y = *((float*)inputBuffers[1] + i) * 64,
};
Vector2 delayLineValues = new Vector2()
Vector2 delayLineValues = new()
{
X = state.DelayLines[0].Read(),
Y = state.DelayLines[1].Read(),
@ -124,7 +124,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, 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, 0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain,
0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain);
@ -132,20 +132,20 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
for (int i = 0; i < sampleCount; i++)
{
Vector4 channelInput = new Vector4
Vector4 channelInput = new()
{
X = *((float*)inputBuffers[0] + i) * 64,
Y = *((float*)inputBuffers[1] + 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(),
Y = state.DelayLines[1].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;
@ -171,7 +171,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, 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,
delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, 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++)
{
Vector6 channelInput = new Vector6
Vector6 channelInput = new()
{
X = *((float*)inputBuffers[0] + i) * 64,
Y = *((float*)inputBuffers[1] + i) * 64,
Z = *((float*)inputBuffers[2] + i) * 64,
W = *((float*)inputBuffers[3] + 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(),
Y = state.DelayLines[1].Read(),
Z = state.DelayLines[2].Read(),
W = state.DelayLines[3].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;

View File

@ -55,17 +55,15 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
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;
}
return depopValue;
buffer[i] += depopValue;
}
return depopValue;
}
public void Process(CommandList context)
@ -89,4 +87,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
}
}

View File

@ -54,4 +54,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
}
}

View File

@ -65,4 +65,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
context.ClearBuffer(OutputBufferIndices[5]);
}
}
}
}

View File

@ -14,11 +14,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public uint EstimatedProcessingTime { get; set; }
private BiquadFilterParameter[] _parameters;
private Memory<BiquadFilterState> _biquadFilterStates;
private int _inputBufferIndex;
private int _outputBufferIndex;
private bool[] _isInitialized;
private readonly BiquadFilterParameter[] _parameters;
private readonly Memory<BiquadFilterState> _biquadFilterStates;
private readonly int _inputBufferIndex;
private readonly int _outputBufferIndex;
private readonly bool[] _isInitialized;
public GroupedBiquadFilterCommand(int baseIndex, ReadOnlySpan<BiquadFilterParameter> filters, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
{
@ -59,4 +59,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
}
}

View File

@ -17,4 +17,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
return false;
}
}
}
}

View File

@ -1,5 +1,6 @@
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
@ -50,13 +51,13 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
if (Parameter.Status == Server.Effect.UsageState.Invalid)
if (Parameter.Status == UsageState.Invalid)
{
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);
}
}
@ -141,4 +142,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
}
}

View File

@ -1,6 +1,7 @@
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
@ -54,13 +55,13 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
if (Parameter.Status == Server.Effect.UsageState.Invalid)
if (Parameter.Status == UsageState.Invalid)
{
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);
}
}
@ -160,4 +161,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
}
}

View File

@ -134,4 +134,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessMix(outputBuffer, inputBuffer);
}
}
}
}

View File

@ -65,4 +65,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
State.Span[0].LastSamples[LastSampleIndex] = ProcessMixRamp(outputBuffer, inputBuffer, (int)context.SampleCount);
}
}
}
}

View File

@ -48,7 +48,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
[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 volume = volume0;
@ -88,4 +88,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
}
}

View File

@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@ -28,7 +30,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public Memory<VoiceUpdateState> State { 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;
NodeId = nodeId;
@ -56,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat.PcmFloat,
@ -71,4 +73,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
}
}

View File

@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@ -28,7 +30,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public Memory<VoiceUpdateState> State { 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;
NodeId = nodeId;
@ -56,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat.PcmInt16,
@ -71,4 +73,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
}
}

View File

@ -8,7 +8,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Invalid,
Start,
End
End,
}
public bool Enabled { get; set; }
@ -44,4 +44,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
}
}

View File

@ -9,21 +9,21 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
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[] 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[] _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[] _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[] 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[] _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[] _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[] 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[] _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[] _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[] 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[] _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[] _targetOutputFeedbackIndicesTableSurround = new int[6] { 0, 1, 2, 3, -1, 3 };
public bool Enabled { get; set; }
@ -73,25 +73,25 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
[MethodImpl(MethodImplOptions.AggressiveInlining)]
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)]
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)]
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)]
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)
@ -109,7 +109,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
{
outputValues.Fill(0);
outputValues.Clear();
float tapOut = state.PreDelayLine.TapUnsafe(state.ReflectionDelayTime, DelayLineSampleIndexOffset);

View File

@ -1,5 +1,6 @@
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
@ -8,25 +9,25 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
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[] 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[] TargetOutputFeedbackIndicesTableMono = new int[4] { 0, 1, 2, 3 };
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[] _outputIndicesTableMono = new int[4] { 0, 0, 0, 0 };
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[] 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[] TargetOutputFeedbackIndicesTableStereo = new int[4] { 2, 0, 3, 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[] _outputIndicesTableStereo = new int[4] { 0, 0, 1, 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[] 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[] TargetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 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[] _outputIndicesTableQuadraphonic = 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[] 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[] TargetOutputFeedbackIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, -1, 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[] _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[] _targetOutputFeedbackIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, -1, 3 };
public bool Enabled { get; set; }
@ -82,10 +83,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
OutputEarlyIndicesTableMono,
TargetEarlyDelayLineIndicesTableMono,
TargetOutputFeedbackIndicesTableMono,
OutputIndicesTableMono);
_outputEarlyIndicesTableMono,
_targetEarlyDelayLineIndicesTableMono,
_targetOutputFeedbackIndicesTableMono,
_outputIndicesTableMono);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -95,10 +96,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
OutputEarlyIndicesTableStereo,
TargetEarlyDelayLineIndicesTableStereo,
TargetOutputFeedbackIndicesTableStereo,
OutputIndicesTableStereo);
_outputEarlyIndicesTableStereo,
_targetEarlyDelayLineIndicesTableStereo,
_targetOutputFeedbackIndicesTableStereo,
_outputIndicesTableStereo);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -108,10 +109,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
OutputEarlyIndicesTableQuadraphonic,
TargetEarlyDelayLineIndicesTableQuadraphonic,
TargetOutputFeedbackIndicesTableQuadraphonic,
OutputIndicesTableQuadraphonic);
_outputEarlyIndicesTableQuadraphonic,
_targetEarlyDelayLineIndicesTableQuadraphonic,
_targetOutputFeedbackIndicesTableQuadraphonic,
_outputIndicesTableQuadraphonic);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -121,10 +122,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
OutputEarlyIndicesTableSurround,
TargetEarlyDelayLineIndicesTableSurround,
TargetOutputFeedbackIndicesTableSurround,
OutputIndicesTableSurround);
_outputEarlyIndicesTableSurround,
_targetEarlyDelayLineIndicesTableSurround,
_targetOutputFeedbackIndicesTableSurround,
_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)
@ -143,7 +144,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
{
outputValues.Fill(0);
outputValues.Clear();
for (int i = 0; i < targetEarlyDelayLineIndicesTable.Length; i++)
{
@ -263,11 +264,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
if (Parameter.Status == Server.Effect.UsageState.Invalid)
if (Parameter.Status == UsageState.Invalid)
{
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);
}
@ -276,4 +277,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessReverb(context, ref state);
}
}
}
}

View File

@ -67,4 +67,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
}
}

View File

@ -134,4 +134,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessVolume(outputBuffer, inputBuffer);
}
}
}
}

View File

@ -53,4 +53,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessVolumeRamp(outputBuffer, inputBuffer, (int)context.SampleCount);
}
}
}
}

View File

@ -76,7 +76,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
if (!info.DecodingBehaviour.HasFlag(DecodingBehaviour.SkipPitchAndSampleRateConversion))
{
voiceState.Pitch.AsSpan().Slice(0, pitchMaxLength).CopyTo(tempBuffer);
voiceState.Pitch.AsSpan()[..pitchMaxLength].CopyTo(tempBuffer);
tempBufferIndex += pitchMaxLength;
}
@ -107,7 +107,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
voiceState.LoopContext = memoryManager.Read<AdpcmLoopContext>(waveBuffer.Context);
}
Span<short> tempSpan = tempBuffer.Slice(tempBufferIndex + y);
Span<short> tempSpan = tempBuffer[(tempBufferIndex + y)..];
int decodedSampleCount = -1;
@ -168,7 +168,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
decodedSampleCount = PcmHelper.Decode(tempSpan, waveBufferPcmFloat, targetSampleStartOffset, targetSampleEndOffset, info.ChannelIndex, info.ChannelCount);
break;
default:
Logger.Error?.Print(LogClass.AudioRenderer, $"Unsupported sample format " + info.SampleFormat);
Logger.Error?.Print(LogClass.AudioRenderer, "Unsupported sample format " + info.SampleFormat);
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))
{
@ -231,9 +231,9 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
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);

View File

@ -49,4 +49,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return _delayLine.Tap(sampleIndex);
}
}
}
}

View File

@ -4,8 +4,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
{
public class DelayLine : IDelayLine
{
private float[] _workBuffer;
private uint _sampleRate;
private readonly float[] _workBuffer;
private readonly uint _sampleRate;
private uint _currentSampleIndex;
private uint _lastSampleIndex;
@ -75,4 +75,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return TapUnsafe(sampleIndex, -1);
}
}
}
}

View File

@ -4,8 +4,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
{
public class DelayLine3d : IDelayLine
{
private float[] _workBuffer;
private uint _sampleRate;
private readonly float[] _workBuffer;
private readonly uint _sampleRate;
private uint _currentSampleIndex;
private uint _lastSampleIndex;
@ -73,4 +73,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return TapUnsafe(sampleIndex, -1);
}
}
}
}

View File

@ -1,6 +1,4 @@
using System.Runtime.CompilerServices;
namespace Ryujinx.Audio.Renderer.Dsp.Effect
namespace Ryujinx.Audio.Renderer.Dsp.Effect
{
public struct ExponentialMovingAverage
{
@ -11,7 +9,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
_mean = mean;
}
public float Read()
public readonly float Read()
{
return _mean;
}

View File

@ -34,4 +34,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return (uint)MathF.Round(sampleRate * delayTime);
}
}
}
}

View File

@ -36,4 +36,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
return ToInt(value + half, qBits);
}
}
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
namespace Ryujinx.Audio.Renderer.Dsp
@ -39,7 +38,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
return 1.0f;
}
else if (x <= -5.3f)
if (x <= -5.3f)
{
return 0.0f;
}
@ -112,4 +112,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
return MathF.Sin(DegreesToRadians(value));
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More