LimiterParameter.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //
  2. // Copyright (c) 2019-2021 Ryujinx
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. //
  17. using Ryujinx.Audio.Renderer.Server.Effect;
  18. using Ryujinx.Common.Memory;
  19. using System.Runtime.InteropServices;
  20. namespace Ryujinx.Audio.Renderer.Parameter.Effect
  21. {
  22. /// <summary>
  23. /// <see cref="IEffectInParameter.SpecificData"/> for <see cref="Common.EffectType.Limiter"/>.
  24. /// </summary>
  25. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  26. public struct LimiterParameter
  27. {
  28. /// <summary>
  29. /// The input channel indices that will be used by the <see cref="Dsp.AudioProcessor"/>.
  30. /// </summary>
  31. public Array6<byte> Input;
  32. /// <summary>
  33. /// The output channel indices that will be used by the <see cref="Dsp.AudioProcessor"/>.
  34. /// </summary>
  35. public Array6<byte> Output;
  36. /// <summary>
  37. /// The maximum number of channels supported.
  38. /// </summary>
  39. public ushort ChannelCountMax;
  40. /// <summary>
  41. /// The total channel count used.
  42. /// </summary>
  43. public ushort ChannelCount;
  44. /// <summary>
  45. /// The target sample rate.
  46. /// </summary>
  47. /// <remarks>This is in kHz.</remarks>
  48. public int SampleRate;
  49. /// <summary>
  50. /// The look ahead max time.
  51. /// <remarks>This is in microseconds.</remarks>
  52. /// </summary>
  53. public int LookAheadTimeMax;
  54. /// <summary>
  55. /// The attack time.
  56. /// <remarks>This is in microseconds.</remarks>
  57. /// </summary>
  58. public int AttackTime;
  59. /// <summary>
  60. /// The release time.
  61. /// <remarks>This is in microseconds.</remarks>
  62. /// </summary>
  63. public int ReleaseTime;
  64. /// <summary>
  65. /// The look ahead time.
  66. /// <remarks>This is in microseconds.</remarks>
  67. /// </summary>
  68. public int LookAheadTime;
  69. /// <summary>
  70. /// The attack coefficient.
  71. /// </summary>
  72. public float AttackCoefficient;
  73. /// <summary>
  74. /// The release coefficient.
  75. /// </summary>
  76. public float ReleaseCoefficient;
  77. /// <summary>
  78. /// The threshold.
  79. /// </summary>
  80. public float Threshold;
  81. /// <summary>
  82. /// The input gain.
  83. /// </summary>
  84. public float InputGain;
  85. /// <summary>
  86. /// The output gain.
  87. /// </summary>
  88. public float OutputGain;
  89. /// <summary>
  90. /// The minimum samples stored in the delay buffer.
  91. /// </summary>
  92. public int DelayBufferSampleCountMin;
  93. /// <summary>
  94. /// The maximum samples stored in the delay buffer.
  95. /// </summary>
  96. public int DelayBufferSampleCountMax;
  97. /// <summary>
  98. /// The current usage status of the effect on the client side.
  99. /// </summary>
  100. public UsageState Status;
  101. /// <summary>
  102. /// Indicate if the limiter effect should output statistics.
  103. /// </summary>
  104. [MarshalAs(UnmanagedType.I1)]
  105. public bool StatisticsEnabled;
  106. /// <summary>
  107. /// Indicate to the DSP that the user did a statistics reset.
  108. /// </summary>
  109. [MarshalAs(UnmanagedType.I1)]
  110. public bool StatisticsReset;
  111. /// <summary>
  112. /// Reserved/padding.
  113. /// </summary>
  114. private byte _reserved;
  115. /// <summary>
  116. /// Check if the <see cref="ChannelCount"/> is valid.
  117. /// </summary>
  118. /// <returns>Returns true if the <see cref="ChannelCount"/> is valid.</returns>
  119. public bool IsChannelCountValid()
  120. {
  121. return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
  122. }
  123. /// <summary>
  124. /// Check if the <see cref="ChannelCountMax"/> is valid.
  125. /// </summary>
  126. /// <returns>Returns true if the <see cref="ChannelCountMax"/> is valid.</returns>
  127. public bool IsChannelCountMaxValid()
  128. {
  129. return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
  130. }
  131. }
  132. }