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