aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs
diff options
context:
space:
mode:
authorAlex Barney <thealexbarney@gmail.com>2018-12-06 05:16:24 -0600
committergdkchan <gab.dark.100@gmail.com>2018-12-06 09:16:24 -0200
commitfb1d9493a3d43f2b86c551682586905a1f0e9ea7 (patch)
treed842685ff5bdd45d11d94bd1a45a002b9d532fe7 /Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs
parent3615a70cae3f89197fe185dfc5d0a47fa42151d9 (diff)
Adjust naming conventions and general refactoring in HLE Project (#527)
* Rename enum fields * Naming conventions * Remove unneeded ".this" * Remove unneeded semicolons * Remove unused Usings * Don't use var * Remove unneeded enum underlying types * Explicitly label class visibility * Remove unneeded @ prefixes * Remove unneeded commas * Remove unneeded if expressions * Method doesn't use unsafe code * Remove unneeded casts * Initialized objects don't need an empty constructor * Remove settings from DotSettings * Revert "Explicitly label class visibility" This reverts commit ad5eb5787cc5b27a4631cd46ef5f551c4ae95e51. * Small changes * Revert external enum renaming * Changes from feedback * Apply previous refactorings to the merged code
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs')
-rw-r--r--Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs82
1 files changed, 41 insertions, 41 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs
index baa0bc62..9714f6d8 100644
--- a/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs
+++ b/Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/Resampler.cs
@@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
static class Resampler
{
#region "LookUp Tables"
- private static short[] CurveLut0 = new short[]
+ private static short[] _curveLut0 = new short[]
{
6600, 19426, 6722, 3, 6479, 19424, 6845, 9, 6359, 19419, 6968, 15, 6239, 19412, 7093, 22,
6121, 19403, 7219, 28, 6004, 19391, 7345, 34, 5888, 19377, 7472, 41, 5773, 19361, 7600, 48,
@@ -41,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
22, 7093, 19412, 6239, 15, 6968, 19419, 6359, 9, 6845, 19424, 6479, 3, 6722, 19426, 6600
};
- private static short[] CurveLut1 = new short[]
+ private static short[] _curveLut1 = new short[]
{
-68, 32639, 69, -5, -200, 32630, 212, -15, -328, 32613, 359, -26, -450, 32586, 512, -36,
-568, 32551, 669, -47, -680, 32507, 832, -58, -788, 32454, 1000, -69, -891, 32393, 1174, -80,
@@ -77,7 +77,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
-36, 512, 32586, -450, -26, 359, 32613, -328, -15, 212, 32630, -200, -5, 69, 32639, -68
};
- private static short[] CurveLut2 = new short[]
+ private static short[] _curveLut2 = new short[]
{
3195, 26287, 3329, -32, 3064, 26281, 3467, -34, 2936, 26270, 3608, -38, 2811, 26253, 3751, -42,
2688, 26230, 3897, -46, 2568, 26202, 4046, -50, 2451, 26169, 4199, -54, 2338, 26130, 4354, -58,
@@ -115,77 +115,77 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
#endregion
public static int[] Resample2Ch(
- int[] Buffer,
- int SrcSampleRate,
- int DstSampleRate,
- int SamplesCount,
- ref int FracPart)
+ int[] buffer,
+ int srcSampleRate,
+ int dstSampleRate,
+ int samplesCount,
+ ref int fracPart)
{
- if (Buffer == null)
+ if (buffer == null)
{
- throw new ArgumentNullException(nameof(Buffer));
+ throw new ArgumentNullException(nameof(buffer));
}
- if (SrcSampleRate <= 0)
+ if (srcSampleRate <= 0)
{
- throw new ArgumentOutOfRangeException(nameof(SrcSampleRate));
+ throw new ArgumentOutOfRangeException(nameof(srcSampleRate));
}
- if (DstSampleRate <= 0)
+ if (dstSampleRate <= 0)
{
- throw new ArgumentOutOfRangeException(nameof(DstSampleRate));
+ throw new ArgumentOutOfRangeException(nameof(dstSampleRate));
}
- double Ratio = (double)SrcSampleRate / DstSampleRate;
+ double ratio = (double)srcSampleRate / dstSampleRate;
- int NewSamplesCount = (int)(SamplesCount / Ratio);
+ int newSamplesCount = (int)(samplesCount / ratio);
- int Step = (int)(Ratio * 0x8000);
+ int step = (int)(ratio * 0x8000);
- int[] Output = new int[NewSamplesCount * 2];
+ int[] output = new int[newSamplesCount * 2];
- short[] Lut;
+ short[] lut;
- if (Step > 0xaaaa)
+ if (step > 0xaaaa)
{
- Lut = CurveLut0;
+ lut = _curveLut0;
}
- else if (Step <= 0x8000)
+ else if (step <= 0x8000)
{
- Lut = CurveLut1;
+ lut = _curveLut1;
}
else
{
- Lut = CurveLut2;
+ lut = _curveLut2;
}
- int InOffs = 0;
+ int inOffs = 0;
- for (int OutOffs = 0; OutOffs < Output.Length; OutOffs += 2)
+ for (int outOffs = 0; outOffs < output.Length; outOffs += 2)
{
- int LutIndex = (FracPart >> 8) * 4;
+ int lutIndex = (fracPart >> 8) * 4;
- int Sample0 = Buffer[(InOffs + 0) * 2 + 0] * Lut[LutIndex + 0] +
- Buffer[(InOffs + 1) * 2 + 0] * Lut[LutIndex + 1] +
- Buffer[(InOffs + 2) * 2 + 0] * Lut[LutIndex + 2] +
- Buffer[(InOffs + 3) * 2 + 0] * Lut[LutIndex + 3];
+ int sample0 = buffer[(inOffs + 0) * 2 + 0] * lut[lutIndex + 0] +
+ buffer[(inOffs + 1) * 2 + 0] * lut[lutIndex + 1] +
+ buffer[(inOffs + 2) * 2 + 0] * lut[lutIndex + 2] +
+ buffer[(inOffs + 3) * 2 + 0] * lut[lutIndex + 3];
- int Sample1 = Buffer[(InOffs + 0) * 2 + 1] * Lut[LutIndex + 0] +
- Buffer[(InOffs + 1) * 2 + 1] * Lut[LutIndex + 1] +
- Buffer[(InOffs + 2) * 2 + 1] * Lut[LutIndex + 2] +
- Buffer[(InOffs + 3) * 2 + 1] * Lut[LutIndex + 3];
+ int sample1 = buffer[(inOffs + 0) * 2 + 1] * lut[lutIndex + 0] +
+ buffer[(inOffs + 1) * 2 + 1] * lut[lutIndex + 1] +
+ buffer[(inOffs + 2) * 2 + 1] * lut[lutIndex + 2] +
+ buffer[(inOffs + 3) * 2 + 1] * lut[lutIndex + 3];
- int NewOffset = FracPart + Step;
+ int newOffset = fracPart + step;
- InOffs += NewOffset >> 15;
+ inOffs += newOffset >> 15;
- FracPart = NewOffset & 0x7fff;
+ fracPart = newOffset & 0x7fff;
- Output[OutOffs + 0] = Sample0 >> 15;
- Output[OutOffs + 1] = Sample1 >> 15;
+ output[outOffs + 0] = sample0 >> 15;
+ output[outOffs + 1] = sample1 >> 15;
}
- return Output;
+ return output;
}
}
} \ No newline at end of file