CommandProcessingTimeEstimatorVersion1.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using Ryujinx.Audio.Renderer.Dsp.Command;
  2. using System.Diagnostics;
  3. namespace Ryujinx.Audio.Renderer.Server
  4. {
  5. /// <summary>
  6. /// <see cref="ICommandProcessingTimeEstimator"/> version 1.
  7. /// </summary>
  8. public class CommandProcessingTimeEstimatorVersion1 : ICommandProcessingTimeEstimator
  9. {
  10. private uint _sampleCount;
  11. private uint _bufferCount;
  12. public CommandProcessingTimeEstimatorVersion1(uint sampleCount, uint bufferCount)
  13. {
  14. _sampleCount = sampleCount;
  15. _bufferCount = bufferCount;
  16. }
  17. public uint Estimate(PerformanceCommand command)
  18. {
  19. return 1454;
  20. }
  21. public uint Estimate(ClearMixBufferCommand command)
  22. {
  23. return (uint)(_sampleCount * 0.83f * _bufferCount * 1.2f);
  24. }
  25. public uint Estimate(BiquadFilterCommand command)
  26. {
  27. return (uint)(_sampleCount * 58.0f * 1.2f);
  28. }
  29. public uint Estimate(MixRampGroupedCommand command)
  30. {
  31. int volumeCount = 0;
  32. for (int i = 0; i < command.MixBufferCount; i++)
  33. {
  34. if (command.Volume0[i] != 0.0f || command.Volume1[i] != 0.0f)
  35. {
  36. volumeCount++;
  37. }
  38. }
  39. return (uint)(_sampleCount * 14.4f * 1.2f * volumeCount);
  40. }
  41. public uint Estimate(MixRampCommand command)
  42. {
  43. return (uint)(_sampleCount * 14.4f * 1.2f);
  44. }
  45. public uint Estimate(DepopPrepareCommand command)
  46. {
  47. return 1080;
  48. }
  49. public uint Estimate(VolumeRampCommand command)
  50. {
  51. return (uint)(_sampleCount * 9.8f * 1.2f);
  52. }
  53. public uint Estimate(PcmInt16DataSourceCommandVersion1 command)
  54. {
  55. return (uint)(command.Pitch * 0.25f * 1.2f);
  56. }
  57. public uint Estimate(AdpcmDataSourceCommandVersion1 command)
  58. {
  59. return (uint)(command.Pitch * 0.46f * 1.2f);
  60. }
  61. public uint Estimate(DepopForMixBuffersCommand command)
  62. {
  63. return (uint)(_sampleCount * 8.9f * command.MixBufferCount);
  64. }
  65. public uint Estimate(CopyMixBufferCommand command)
  66. {
  67. // NOTE: Nintendo returns 0 here for some reasons even if it will generate a command like that on version 1.. maybe a mistake?
  68. return 0;
  69. }
  70. public uint Estimate(MixCommand command)
  71. {
  72. return (uint)(_sampleCount * 10.0f * 1.2f);
  73. }
  74. public uint Estimate(DelayCommand command)
  75. {
  76. return (uint)(_sampleCount * command.Parameter.ChannelCount * 202.5f);
  77. }
  78. public uint Estimate(ReverbCommand command)
  79. {
  80. Debug.Assert(command.Parameter.IsChannelCountValid());
  81. if (command.Enabled)
  82. {
  83. return (uint)(750 * _sampleCount * command.Parameter.ChannelCount * 1.2f);
  84. }
  85. return 0;
  86. }
  87. public uint Estimate(Reverb3dCommand command)
  88. {
  89. if (command.Enabled)
  90. {
  91. return (uint)(530 * _sampleCount * command.Parameter.ChannelCount * 1.2f);
  92. }
  93. return 0;
  94. }
  95. public uint Estimate(AuxiliaryBufferCommand command)
  96. {
  97. if (command.Enabled)
  98. {
  99. return 15956;
  100. }
  101. return 3765;
  102. }
  103. public uint Estimate(VolumeCommand command)
  104. {
  105. return (uint)(_sampleCount * 8.8f * 1.2f);
  106. }
  107. public uint Estimate(CircularBufferSinkCommand command)
  108. {
  109. return 55;
  110. }
  111. public uint Estimate(DownMixSurroundToStereoCommand command)
  112. {
  113. return 16108;
  114. }
  115. public uint Estimate(UpsampleCommand command)
  116. {
  117. return 357915;
  118. }
  119. public uint Estimate(DeviceSinkCommand command)
  120. {
  121. return 10042;
  122. }
  123. public uint Estimate(PcmFloatDataSourceCommandVersion1 command)
  124. {
  125. return 0;
  126. }
  127. public uint Estimate(DataSourceVersion2Command command)
  128. {
  129. return 0;
  130. }
  131. public uint Estimate(LimiterCommandVersion1 command)
  132. {
  133. return 0;
  134. }
  135. public uint Estimate(LimiterCommandVersion2 command)
  136. {
  137. return 0;
  138. }
  139. public uint Estimate(GroupedBiquadFilterCommand command)
  140. {
  141. return 0;
  142. }
  143. public uint Estimate(CaptureBufferCommand command)
  144. {
  145. return 0;
  146. }
  147. }
  148. }