forked from akanyan/mu3-mods
28 lines
1.2 KiB
C#
28 lines
1.2 KiB
C#
using System;
|
|
|
|
namespace MU3.Sound;
|
|
|
|
class patch_SoundManager: SoundManager {
|
|
public class SoundPatch { };
|
|
private void setWasapiExclusive() {
|
|
using IniFile iniFile = new IniFile("mu3.ini");
|
|
var sixCh = iniFile.getValue("Sound", "WasapiExclusive", 1) == 1;
|
|
var sampleRate = (uint)iniFile.getValue("Sound", "SampleRate", 48000);
|
|
|
|
CriAtomUserExtension.WaveFormatExtensible format = default;
|
|
format.Format = default;
|
|
format.Format.wFormatTag = 65534;
|
|
format.Format.nChannels = (ushort)(sixCh ? 6 : 2);
|
|
format.Format.nSamplesPerSec = sampleRate;
|
|
format.Format.wBitsPerSample = 32;
|
|
format.Format.nBlockAlign = (ushort)(format.Format.wBitsPerSample / 8 * format.Format.nChannels);
|
|
format.Format.nAvgBytesPerSec = format.Format.nSamplesPerSec * format.Format.nBlockAlign;
|
|
format.Format.cbSize = 22;
|
|
format.Samples.wValidBitsPerSample = 24;
|
|
format.dwChannelMask = sixCh ? 0b111111u : 0b11u;
|
|
format.SubFormat = new Guid("00000001-0000-0010-8000-00aa00389b71");
|
|
CriAtomUserExtension.SetAudioClientShareMode(CriAtomUserExtension.AudioClientShareMode.Exclusive);
|
|
CriAtomUserExtension.SetAudioClientFormat(ref format);
|
|
}
|
|
}
|