0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/Ryujinx.Audio/Renderer/Dsp/FixedPointHelper.cs
Mary 4c2ab880ef
misc: Relicense Ryujinx.Audio under the terms of the MIT license (#3449)
* Ryujinx.Audio: Remove BOM from files

* misc: Relicense Ryujinx.Audio under the terms of the MIT license

With the approvals of all the Ryujinx.Audio contributors, this commit
changes Ryujinx.Audio license from LGPLv3 to MIT.
2022-07-08 19:45:53 +02:00

33 lines
917 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);
}
}
}