FineAudio/Sound.cs

27 lines
731 B
C#
Raw Normal View History

2021-01-20 02:06:10 +00:00
namespace MoonWorks.Audio
{
2021-01-20 03:26:30 +00:00
public abstract class Sound
2021-01-20 02:06:10 +00:00
{
2021-01-20 03:26:30 +00:00
internal FAudio.FAudioWaveFormatEx Format { get; }
2021-01-20 02:06:10 +00:00
2021-01-20 03:26:30 +00:00
/* NOTE: we only support float decoding! WAV sucks! */
2021-01-20 02:06:10 +00:00
public Sound(
ushort channels,
2021-01-20 03:26:30 +00:00
uint samplesPerSecond
2021-01-20 02:06:10 +00:00
) {
2021-01-20 03:26:30 +00:00
var blockAlign = (ushort) (4 * channels);
2021-01-20 02:06:10 +00:00
2021-01-20 03:26:30 +00:00
Format = new FAudio.FAudioWaveFormatEx
{
wFormatTag = 3,
wBitsPerSample = 32,
nChannels = channels,
nBlockAlign = blockAlign,
nSamplesPerSec = samplesPerSecond,
nAvgBytesPerSec = blockAlign * samplesPerSecond,
cbSize = 0
};
2021-01-20 02:06:10 +00:00
}
}
}