BackendHelper.cs 794 B

1234567891011121314151617181920212223242526
  1. using Ryujinx.Audio.Common;
  2. using System;
  3. namespace Ryujinx.Audio.Backends.Common
  4. {
  5. public static class BackendHelper
  6. {
  7. public static int GetSampleSize(SampleFormat format)
  8. {
  9. return format switch
  10. {
  11. SampleFormat.PcmInt8 => sizeof(byte),
  12. SampleFormat.PcmInt16 => sizeof(ushort),
  13. SampleFormat.PcmInt24 => 3,
  14. SampleFormat.PcmInt32 => sizeof(int),
  15. SampleFormat.PcmFloat => sizeof(float),
  16. _ => throw new ArgumentException($"{format}"),
  17. };
  18. }
  19. public static int GetSampleCount(SampleFormat format, int channelCount, int bufferSize)
  20. {
  21. return bufferSize / GetSampleSize(format) / channelCount;
  22. }
  23. }
  24. }