Constants.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. namespace Ryujinx.Audio
  2. {
  3. /// <summary>
  4. /// Define constants used by the audio system.
  5. /// </summary>
  6. public static class Constants
  7. {
  8. /// <summary>
  9. /// The default device output name.
  10. /// </summary>
  11. public const string DefaultDeviceOutputName = "DeviceOut";
  12. /// <summary>
  13. /// The default device input name.
  14. /// </summary>
  15. public const string DefaultDeviceInputName = "BuiltInHeadset";
  16. /// <summary>
  17. /// The maximum number of channels supported. (6 channels for 5.1 surround)
  18. /// </summary>
  19. public const int ChannelCountMax = 6;
  20. /// <summary>
  21. /// The maximum number of channels supported per voice.
  22. /// </summary>
  23. public const int VoiceChannelCountMax = ChannelCountMax;
  24. /// <summary>
  25. /// The maximum count of mix buffer supported per operations (volumes, mix effect, ...)
  26. /// </summary>
  27. public const int MixBufferCountMax = 24;
  28. /// <summary>
  29. /// The maximum count of wavebuffer per voice.
  30. /// </summary>
  31. public const int VoiceWaveBufferCount = 4;
  32. /// <summary>
  33. /// The maximum count of biquad filter per voice.
  34. /// </summary>
  35. public const int VoiceBiquadFilterCount = 2;
  36. /// <summary>
  37. /// The lowest priority that a voice can have.
  38. /// </summary>
  39. public const int VoiceLowestPriority = 0xFF;
  40. /// <summary>
  41. /// The highest priority that a voice can have.
  42. /// </summary>
  43. /// <remarks>Voices with the highest priority will not be dropped if a voice drop needs to occur.</remarks>
  44. public const int VoiceHighestPriority = 0;
  45. /// <summary>
  46. /// Maximum <see cref="Common.BehaviourParameter.ErrorInfo"/> that can be returned by <see cref="Parameter.BehaviourErrorInfoOutStatus"/>.
  47. /// </summary>
  48. public const int MaxErrorInfos = 10;
  49. /// <summary>
  50. /// Default alignment for buffers.
  51. /// </summary>
  52. public const int BufferAlignment = 0x40;
  53. /// <summary>
  54. /// Alignment required for the work buffer.
  55. /// </summary>
  56. public const int WorkBufferAlignment = 0x1000;
  57. /// <summary>
  58. /// Alignment required for every performance metrics frame.
  59. /// </summary>
  60. public const int PerformanceMetricsPerFramesSizeAlignment = 0x100;
  61. /// <summary>
  62. /// The id of the final mix.
  63. /// </summary>
  64. public const int FinalMixId = 0;
  65. /// <summary>
  66. /// The id defining an unused mix id.
  67. /// </summary>
  68. public const int UnusedMixId = int.MaxValue;
  69. /// <summary>
  70. /// The id defining an unused splitter id as a signed integer.
  71. /// </summary>
  72. public const int UnusedSplitterIdInt = -1;
  73. /// <summary>
  74. /// The id defining an unused splitter id.
  75. /// </summary>
  76. public const uint UnusedSplitterId = uint.MaxValue;
  77. /// <summary>
  78. /// The id of invalid/unused node id.
  79. /// </summary>
  80. public const int InvalidNodeId = -268435456;
  81. /// <summary>
  82. /// The indice considered invalid for processing order.
  83. /// </summary>
  84. public const int InvalidProcessingOrder = -1;
  85. /// <summary>
  86. /// The maximum number of audio renderer sessions allowed to be created system wide.
  87. /// </summary>
  88. public const int AudioRendererSessionCountMax = 2;
  89. /// <summary>
  90. /// The maximum number of audio output sessions allowed to be created system wide.
  91. /// </summary>
  92. public const int AudioOutSessionCountMax = 12;
  93. /// <summary>
  94. /// The maximum number of audio input sessions allowed to be created system wide.
  95. /// </summary>
  96. public const int AudioInSessionCountMax = 4;
  97. /// <summary>
  98. /// Maximum buffers supported by one audio device session.
  99. /// </summary>
  100. public const int AudioDeviceBufferCountMax = 32;
  101. /// <summary>
  102. /// The target sample rate of the audio renderer. (48kHz)
  103. /// </summary>
  104. public const uint TargetSampleRate = 48000;
  105. /// <summary>
  106. /// The target sample size of the audio renderer. (PCM16)
  107. /// </summary>
  108. public const int TargetSampleSize = sizeof(ushort);
  109. /// <summary>
  110. /// The target sample count per audio renderer update.
  111. /// </summary>
  112. public const int TargetSampleCount = 240;
  113. /// <summary>
  114. /// The size of an upsampler entry to process upsampling to <see cref="TargetSampleRate"/>.
  115. /// </summary>
  116. public const int UpSampleEntrySize = TargetSampleCount * VoiceChannelCountMax;
  117. /// <summary>
  118. /// The target audio latency computed from <see cref="TargetSampleRate"/> and <see cref="TargetSampleCount"/>.
  119. /// </summary>
  120. public const int AudioProcessorMaxUpdateTimeTarget = 1000000000 / ((int)TargetSampleRate / TargetSampleCount); // 5.00 ms
  121. /// <summary>
  122. /// The maximum update time of the DSP on original hardware.
  123. /// </summary>
  124. public const int AudioProcessorMaxUpdateTime = 5760000; // 5.76 ms
  125. /// <summary>
  126. /// The maximum update time per audio renderer session.
  127. /// </summary>
  128. public const int AudioProcessorMaxUpdateTimePerSessions = AudioProcessorMaxUpdateTime / AudioRendererSessionCountMax;
  129. /// <summary>
  130. /// Guest timer frequency used for system ticks.
  131. /// </summary>
  132. public const int TargetTimerFrequency = 19200000;
  133. /// <summary>
  134. /// The default coefficients used for standard 5.1 surround to stereo downmixing.
  135. /// </summary>
  136. public static float[] DefaultSurroundToStereoCoefficients = new float[4]
  137. {
  138. 1.0f,
  139. 0.707f,
  140. 0.251f,
  141. 0.707f,
  142. };
  143. }
  144. }