/// <summary> /// Initialize the <see cref="SoundSystem"/> using specified device name. /// </summary> /// <param name="device">The audio device name.</param> public void Initialize(string device) { if (!AudioContext.AvailableDevices.Contains(device)) { throw new ArgumentException("Invalid device name"); } AudioDevice.Initialize(new AudioContext(device)); }
/// <summary> /// Initializes a new instance of the <see cref="SoundBuffer"/> class. /// </summary> public SoundBuffer() { // Ensure that AudioDevice is initialized AudioDevice.Initialize(); _samples = new short[0]; _sounds = new List <Sound>(); _duration = TimeSpan.Zero; // Create the buffer ALChecker.Check(() => _buffer = AL.GenBuffer()); }
/// <summary> /// Initializes a new instance of the <see cref="SoundSystem"/> class /// with default OpenAL Context. /// </summary> protected SoundSystem() { try { // Initialize OpenAL Audio AudioDevice.Initialize(); _sources = new List <SoundSource>(); _play = typeof(SoundSource).GetMethod("Play", BindingFlags.NonPublic | BindingFlags.Instance); _pause = typeof(SoundSource).GetMethod("Pause", BindingFlags.NonPublic | BindingFlags.Instance); _stop = typeof(SoundSource).GetMethod("Stop", BindingFlags.NonPublic | BindingFlags.Instance); } catch (Exception ex) { throw ex.InnerException != null ? ex.InnerException : ex; } }