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