MixParameter.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // Copyright (c) 2019-2020 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.Common.Utilities;
  18. using System;
  19. using System.Runtime.InteropServices;
  20. namespace Ryujinx.Audio.Renderer.Parameter
  21. {
  22. /// <summary>
  23. /// Input information for a mix.
  24. /// </summary>
  25. /// <remarks>Also used on the client side for mix tracking.</remarks>
  26. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  27. public struct MixParameter
  28. {
  29. /// <summary>
  30. /// Base volume of the mix.
  31. /// </summary>
  32. public float Volume;
  33. /// <summary>
  34. /// Target sample rate of the mix.
  35. /// </summary>
  36. public uint SampleRate;
  37. /// <summary>
  38. /// Target buffer count.
  39. /// </summary>
  40. public uint BufferCount;
  41. /// <summary>
  42. /// Set to true if in use.
  43. /// </summary>
  44. [MarshalAs(UnmanagedType.I1)]
  45. public bool IsUsed;
  46. /// <summary>
  47. /// Set to true if it was changed.
  48. /// </summary>
  49. [MarshalAs(UnmanagedType.I1)]
  50. public bool IsDirty;
  51. /// <summary>
  52. /// Reserved/padding.
  53. /// </summary>
  54. private ushort _reserved1;
  55. /// <summary>
  56. /// The id of the mix.
  57. /// </summary>
  58. public int MixId;
  59. /// <summary>
  60. /// The effect count. (client side)
  61. /// </summary>
  62. public uint EffectCount;
  63. /// <summary>
  64. /// The mix node id.
  65. /// </summary>
  66. public int NodeId;
  67. /// <summary>
  68. /// Reserved/padding.
  69. /// </summary>
  70. private ulong _reserved2;
  71. /// <summary>
  72. /// Mix buffer volumes storage.
  73. /// </summary>
  74. private MixVolumeArray _mixBufferVolumeArray;
  75. /// <summary>
  76. /// The mix to output the result of this mix.
  77. /// </summary>
  78. public int DestinationMixId;
  79. /// <summary>
  80. /// The splitter to output the result of this mix.
  81. /// </summary>
  82. public uint DestinationSplitterId;
  83. /// <summary>
  84. /// Reserved/padding.
  85. /// </summary>
  86. private uint _reserved3;
  87. [StructLayout(LayoutKind.Sequential, Size = 4 * RendererConstants.MixBufferCountMax * RendererConstants.MixBufferCountMax, Pack = 1)]
  88. private struct MixVolumeArray { }
  89. /// <summary>
  90. /// Mix buffer volumes.
  91. /// </summary>
  92. /// <remarks>Used when no splitter id is specified.</remarks>
  93. public Span<float> MixBufferVolume => SpanHelpers.AsSpan<MixVolumeArray, float>(ref _mixBufferVolumeArray);
  94. }
  95. }