CommandProcessingTimeEstimatorVersion5.cs 8.6 KB

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