2021-02-25 19:11:56 -05:00
|
|
|
using Ryujinx.Audio.Common;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Ryujinx.Audio.Backends.Common
|
2020-08-17 21:49:37 -04:00
|
|
|
{
|
2021-02-25 19:11:56 -05:00
|
|
|
public static class BackendHelper
|
2020-08-17 21:49:37 -04:00
|
|
|
{
|
2021-02-25 19:11:56 -05:00
|
|
|
public static int GetSampleSize(SampleFormat format)
|
2020-08-17 21:49:37 -04:00
|
|
|
{
|
2021-02-25 19:11:56 -05:00
|
|
|
return format switch
|
|
|
|
{
|
|
|
|
SampleFormat.PcmInt8 => sizeof(byte),
|
|
|
|
SampleFormat.PcmInt16 => sizeof(ushort),
|
|
|
|
SampleFormat.PcmInt24 => 3,
|
|
|
|
SampleFormat.PcmInt32 => sizeof(int),
|
|
|
|
SampleFormat.PcmFloat => sizeof(float),
|
|
|
|
_ => throw new ArgumentException($"{format}"),
|
|
|
|
};
|
2020-08-17 21:49:37 -04:00
|
|
|
}
|
|
|
|
|
2021-02-25 19:11:56 -05:00
|
|
|
public static int GetSampleCount(SampleFormat format, int channelCount, int bufferSize)
|
2020-08-17 21:49:37 -04:00
|
|
|
{
|
2021-02-25 19:11:56 -05:00
|
|
|
return bufferSize / GetSampleSize(format) / channelCount;
|
2020-08-17 21:49:37 -04:00
|
|
|
}
|
|
|
|
}
|
2022-07-25 14:46:33 -04:00
|
|
|
}
|