aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Audio/Backends/Common/BackendHelper.cs
blob: 124d8364f6f7c985f4b594e3549e2b2389f2d19b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
        }
    }
}