1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-14 22:16:43 +00:00
Ryujinx/Ryujinx.Audio/Renderer/Dsp/FixedPointHelper.cs
Mary-nyan 1825bd87b4
misc: Reformat Ryujinx.Audio with dotnet-format (#3485)
This is the first commit of a series of reformat around the codebase as
discussed internally some weeks ago.

This project being one that isn't touched that much, it shouldn't cause
conflict with any opened PRs.
2022-07-25 15:46:33 -03:00

33 lines
No EOL
916 B
C#

using System.Runtime.CompilerServices;
namespace Ryujinx.Audio.Renderer.Dsp
{
public static class FixedPointHelper
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int ToInt(long value, int qBits)
{
return (int)(value >> qBits);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float ToFloat(long value, int qBits)
{
return (float)value / (1 << qBits);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int ToFixed(float value, int qBits)
{
return (int)(value * (1 << qBits));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int RoundUpAndToInt(long value, int qBits)
{
int half = 1 << (qBits - 1);
return ToInt(value + half, qBits);
}
}
}