CommandProcessingTimeEstimatorVersion5.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. using Ryujinx.Audio.Renderer.Dsp.Command;
  2. using System;
  3. using System.Diagnostics;
  4. namespace Ryujinx.Audio.Renderer.Server
  5. {
  6. /// <summary>
  7. /// <see cref="ICommandProcessingTimeEstimator"/> version 5. (added with REV11)
  8. /// </summary>
  9. public class CommandProcessingTimeEstimatorVersion5 : CommandProcessingTimeEstimatorVersion4
  10. {
  11. public CommandProcessingTimeEstimatorVersion5(uint sampleCount, uint bufferCount) : base(sampleCount, bufferCount) { }
  12. public override uint Estimate(DelayCommand command)
  13. {
  14. Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
  15. if (_sampleCount == 160)
  16. {
  17. if (command.Enabled)
  18. {
  19. switch (command.Parameter.ChannelCount)
  20. {
  21. case 1:
  22. return 8929;
  23. case 2:
  24. return 25501;
  25. case 4:
  26. return 47760;
  27. case 6:
  28. return 82203;
  29. default:
  30. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  31. }
  32. }
  33. else
  34. {
  35. switch (command.Parameter.ChannelCount)
  36. {
  37. case 1:
  38. return (uint)1295.20f;
  39. case 2:
  40. return (uint)1213.60f;
  41. case 4:
  42. return (uint)942.03f;
  43. case 6:
  44. return (uint)1001.6f;
  45. default:
  46. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  47. }
  48. }
  49. }
  50. if (command.Enabled)
  51. {
  52. switch (command.Parameter.ChannelCount)
  53. {
  54. case 1:
  55. return 11941;
  56. case 2:
  57. return 37197;
  58. case 4:
  59. return 69750;
  60. case 6:
  61. return 12004;
  62. default:
  63. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  64. }
  65. }
  66. else
  67. {
  68. switch (command.Parameter.ChannelCount)
  69. {
  70. case 1:
  71. return (uint)997.67f;
  72. case 2:
  73. return (uint)977.63f;
  74. case 4:
  75. return (uint)792.31f;
  76. case 6:
  77. return (uint)875.43f;
  78. default:
  79. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  80. }
  81. }
  82. }
  83. public override uint Estimate(ReverbCommand command)
  84. {
  85. Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
  86. if (_sampleCount == 160)
  87. {
  88. if (command.Enabled)
  89. {
  90. switch (command.Parameter.ChannelCount)
  91. {
  92. case 1:
  93. return 81475;
  94. case 2:
  95. return 84975;
  96. case 4:
  97. return 91625;
  98. case 6:
  99. return 95332;
  100. default:
  101. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  102. }
  103. }
  104. else
  105. {
  106. switch (command.Parameter.ChannelCount)
  107. {
  108. case 1:
  109. return (uint)536.30f;
  110. case 2:
  111. return (uint)588.80f;
  112. case 4:
  113. return (uint)643.70f;
  114. case 6:
  115. return (uint)706.0f;
  116. default:
  117. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  118. }
  119. }
  120. }
  121. if (command.Enabled)
  122. {
  123. switch (command.Parameter.ChannelCount)
  124. {
  125. case 1:
  126. return 120170;
  127. case 2:
  128. return 125260;
  129. case 4:
  130. return 135750;
  131. case 6:
  132. return 141130;
  133. default:
  134. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  135. }
  136. }
  137. else
  138. {
  139. switch (command.Parameter.ChannelCount)
  140. {
  141. case 1:
  142. return (uint)617.64f;
  143. case 2:
  144. return (uint)659.54f;
  145. case 4:
  146. return (uint)711.44f;
  147. case 6:
  148. return (uint)778.07f;
  149. default:
  150. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  151. }
  152. }
  153. }
  154. public override uint Estimate(Reverb3dCommand command)
  155. {
  156. Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
  157. if (_sampleCount == 160)
  158. {
  159. if (command.Enabled)
  160. {
  161. switch (command.Parameter.ChannelCount)
  162. {
  163. case 1:
  164. return 116750;
  165. case 2:
  166. return 125910;
  167. case 4:
  168. return 146340;
  169. case 6:
  170. return 165810;
  171. default:
  172. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  173. }
  174. }
  175. else
  176. {
  177. switch (command.Parameter.ChannelCount)
  178. {
  179. case 1:
  180. return 735;
  181. case 2:
  182. return (uint)766.62f;
  183. case 4:
  184. return (uint)834.07f;
  185. case 6:
  186. return (uint)875.44f;
  187. default:
  188. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  189. }
  190. }
  191. }
  192. if (command.Enabled)
  193. {
  194. switch (command.Parameter.ChannelCount)
  195. {
  196. case 1:
  197. return 170290;
  198. case 2:
  199. return 183880;
  200. case 4:
  201. return 214700;
  202. case 6:
  203. return 243850;
  204. default:
  205. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  206. }
  207. }
  208. else
  209. {
  210. switch (command.Parameter.ChannelCount)
  211. {
  212. case 1:
  213. return (uint)508.47f;
  214. case 2:
  215. return (uint)582.45f;
  216. case 4:
  217. return (uint)626.42f;
  218. case 6:
  219. return (uint)682.47f;
  220. default:
  221. throw new NotImplementedException($"{command.Parameter.ChannelCount}");
  222. }
  223. }
  224. }
  225. }
  226. }