0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-24 00:45:46 +00:00
ryujinx-fork/Ryujinx.Audio/Backends/Common/BackendHelper.cs

26 lines
794 B
C#
Raw Normal View History

using Ryujinx.Audio.Common;
using System;
namespace Ryujinx.Audio.Backends.Common
{
public static class BackendHelper
{
public static int GetSampleSize(SampleFormat format)
{
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}"),
};
}
public static int GetSampleCount(SampleFormat format, int channelCount, int bufferSize)
{
return bufferSize / GetSampleSize(format) / channelCount;
}
}
}