public AudioOutput(int channels = 1, int sampleRate = 44100) { if (channels < 1 || channels > 2) { throw new ArgumentOutOfRangeException(nameof(channels)); } if (sampleRate < 2000 || sampleRate > 200000) { throw new ArgumentOutOfRangeException(nameof(sampleRate)); } try { al = AL.GetApi(true); alContext = ALContext.GetApi(true); } catch { al = AL.GetApi(false); alContext = ALContext.GetApi(false); } device = alContext.OpenDevice(""); Available = device != null; if (Available) { context = alContext.CreateContext(device, null); alContext.MakeContextCurrent(context); if (al.GetError() != AudioError.NoError) { Available = false; if (context != null) { alContext.DestroyContext(context); } alContext.CloseDevice(device); al.Dispose(); alContext.Dispose(); disposed = true; return; } source = al.GenSource(); al.SetSourceProperty(source, SourceBoolean.Looping, true); al.SetSourceProperty(source, SourceFloat.Gain, 1.0f); } }