2021-02-26 00:11:56 +00:00
|
|
|
using Ryujinx.Audio.Common;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Ryujinx.Audio.Backends.Common
|
2020-08-18 02:49:37 +01:00
|
|
|
{
|
2021-02-26 00:11:56 +00:00
|
|
|
public static class BackendHelper
|
2020-08-18 02:49:37 +01:00
|
|
|
{
|
2021-02-26 00:11:56 +00:00
|
|
|
public static int GetSampleSize(SampleFormat format)
|
2020-08-18 02:49:37 +01:00
|
|
|
{
|
2021-02-26 00:11:56 +00: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-18 02:49:37 +01:00
|
|
|
}
|
|
|
|
|
2021-02-26 00:11:56 +00:00
|
|
|
public static int GetSampleCount(SampleFormat format, int channelCount, int bufferSize)
|
2020-08-18 02:49:37 +01:00
|
|
|
{
|
2021-02-26 00:11:56 +00:00
|
|
|
return bufferSize / GetSampleSize(format) / channelCount;
|
2020-08-18 02:49:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|