Пример #1
0
        public static void Initialize()
        {
            IntPtr        device  = Alc.OpenDevice("");
            ContextHandle context = Alc.CreateContext(device, new int[0]);

            Alc.MakeContextCurrent(context);

#if DEBUG
            GlobalEvent.EndStep += () =>
            {
                _Audio.ErrorCheck();
            };
#endif
        }
Пример #2
0
        /*
         *      AL.GetError ();
         *      string deviceName = Alc.GetString (IntPtr.Zero, AlcGetString.CaptureDefaultDeviceSpecifier);
         *      Console.WriteLine ("device: " + deviceName);
         *      IntPtr device = Alc.CaptureOpenDevice (deviceName, SRATE, ALFormat.Mono16, SSIZE);
         *      if (Error (device))
         *              return;
         *      Console.WriteLine ("c");
         *      Alc.CaptureStart (device);
         *      if (Error (device))
         *              return;
         *
         *      while (true) {
         *      byte[] buffer = new byte[SRATE];
         *              int sample = 0;
         *              Alc.GetInteger (device, AlcGetInteger.CaptureSamples, sizeof (int), out sample);
         *              if (Error (device))
         *                      return;
         *              Console.WriteLine ("sample: " + sample.ToString ());
         *              Alc.CaptureSamples (device, buffer, sample);
         *              if (Error (device))
         *                      return;
         *              SDL2.SDL.SDL_Delay (100);
         *      }
         *      Alc.CaptureStop (device);
         *      Alc.CaptureCloseDevice (device);
         */
        /*
         * ALCdevice *device = alcCaptureOpenDevice (NULL, SRATE, AL_FORMAT_STEREO16, SSIZE);
         * if (alGetError () != AL_NO_ERROR) {
         * return 0;
         * }
         * alcCaptureStart (device);
         *
         * while (true) {
         * alcGetIntegerv (device, ALC_CAPTURE_SAMPLES, (ALCsizei)sizeof (ALint), &sample);
         * alcCaptureSamples (device, (ALCvoid *)buffer, sample);
         *
         * // ... do something with the buffer
         * }
         *
         * alcCaptureStop (device);
         * alcCaptureCloseDevice (device);
         *
         * return 0;
         */

        private static bool Error(IntPtr device)
        {
            AlcError err = Alc.GetError(device);

            if (err != AlcError.NoError)
            {
                Console.WriteLine("Error: " + err.ToString());
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        internal static void CheckError(string message = "", params object[] args)
        {
            AlcError error;

            if ((error = Alc.GetError()) != AlcError.NoError)
            {
                if (args != null && args.Length > 0)
                {
                    message = String.Format(message, args);
                }

                throw new InvalidOperationException(message + " (Reason: " + error.ToString() + ")");
            }
        }
Пример #4
0
        public static void Init()
        {
            ac = new AudioContext();
            ac.CheckErrors();
            ac.MakeCurrent();
            eax_sup = ac.SupportsExtension("EAX3.0");
            if (eax_sup)
            {
                xram = new XRamExtension();
            }

            mp3_sup = ac.SupportsExtension("AL_EXT_mp3");
            devices = Alc.GetString(IntPtr.Zero, AlcGetStringList.AllDevicesSpecifier);
        }
Пример #5
0
        private VoipCapture(string deviceName) : base(GameMain.Client?.ID ?? 0, true, false)
        {
            VoipConfig.SetupEncoding();

            //set up capture device
            captureDevice = Alc.CaptureOpenDevice(deviceName, VoipConfig.FREQUENCY, ALFormat.Mono16, VoipConfig.BUFFER_SIZE * 5);

            if (captureDevice == IntPtr.Zero)
            {
                if (!GUIMessageBox.MessageBoxes.Any(mb => mb.UserData as string == "capturedevicenotfound"))
                {
                    GUI.SettingsMenuOpen = false;
                    new GUIMessageBox(TextManager.Get("Error"), TextManager.Get("VoipCaptureDeviceNotFound"))
                    {
                        UserData = "capturedevicenotfound"
                    };
                }
                GameMain.Config.VoiceSetting = GameSettings.VoiceMode.Disabled;
                Instance?.Dispose();
                Instance = null;
                return;
            }

            ALError  alError  = AL.GetError();
            AlcError alcError = Alc.GetError(captureDevice);

            if (alcError != AlcError.NoError)
            {
                throw new Exception("Failed to open capture device: " + alcError.ToString() + " (ALC)");
            }
            if (alError != ALError.NoError)
            {
                throw new Exception("Failed to open capture device: " + alError.ToString() + " (AL)");
            }

            Alc.CaptureStart(captureDevice);
            alcError = Alc.GetError(captureDevice);
            if (alcError != AlcError.NoError)
            {
                throw new Exception("Failed to start capturing: " + alcError.ToString());
            }

            capturing     = true;
            captureThread = new Thread(UpdateCapture)
            {
                IsBackground = true,
                Name         = "VoipCapture"
            };
            captureThread.Start();
        }
Пример #6
0
        protected override void OnDispose()
        {
            OpenALSoundWorld.criticalSection.Enter();

            if (alCaptureDevice != IntPtr.Zero)
            {
                Alc.alcCaptureCloseDevice(alCaptureDevice);
                alCaptureDevice = IntPtr.Zero;
            }

            OpenALSoundWorld.criticalSection.Leave();

            base.OnDispose();
        }
Пример #7
0
        private void FillBuffer()
        {
            if (overrideSound != null)
            {
                int totalSampleCount = 0;
                while (totalSampleCount < VoipConfig.BUFFER_SIZE)
                {
                    int sampleCount = overrideSound.FillStreamBuffer(overridePos, overrideBuf);
                    overridePos += sampleCount * 2;
                    Array.Copy(overrideBuf, 0, uncompressedBuffer, totalSampleCount, sampleCount);
                    totalSampleCount += sampleCount;

                    if (sampleCount == 0)
                    {
                        overridePos = 0;
                    }
                }
                int sleepMs = VoipConfig.BUFFER_SIZE * 800 / VoipConfig.FREQUENCY;
                Thread.Sleep(sleepMs - 1);
            }
            else
            {
                int sampleCount = 0;

                while (sampleCount < VoipConfig.BUFFER_SIZE)
                {
                    Alc.GetInteger(captureDevice, Alc.EnumCaptureSamples, out sampleCount);

                    int alcError = Alc.GetError(captureDevice);
                    if (alcError != Alc.NoError)
                    {
                        throw new Exception("Failed to determine sample count: " + alcError.ToString());
                    }

                    if (sampleCount < VoipConfig.BUFFER_SIZE)
                    {
                        int sleepMs = (VoipConfig.BUFFER_SIZE - sampleCount) * 800 / VoipConfig.FREQUENCY;
                        if (sleepMs >= 1)
                        {
                            Thread.Sleep(sleepMs);
                        }
                    }

                    if (!capturing) { return; }
                }

                Alc.CaptureSamples(captureDevice, nativeBuffer, VoipConfig.BUFFER_SIZE);
                Marshal.Copy(nativeBuffer, uncompressedBuffer, 0, uncompressedBuffer.Length);
            }
        }
Пример #8
0
 private void CleanUpOpenAL()
 {
     Alc.MakeContextCurrent(ContextHandle.Zero);
     if (_context != ContextHandle.Zero)
     {
         Alc.DestroyContext(_context);
         _context = ContextHandle.Zero;
     }
     if (_device != IntPtr.Zero)
     {
         Alc.CloseDevice(_device);
         _device = IntPtr.Zero;
     }
 }
Пример #9
0
        internal int GetQueuedSampleCount()
        {
            if (_state == MicrophoneState.Stopped || BufferReady == null)
            {
                return(0);
            }

            int[] values = new int[1];
            Alc.GetInteger(_captureDevice, AlcGetInteger.CaptureSamples, 1, values);

            CheckALCError("Failed to query capture samples.");

            return(values[0]);
        }
Пример #10
0
        // --- initialization and deinitialization ---

        /// <summary>Initializes audio. A call to Deinitialize must be made when terminating the program.</summary>
        /// <returns>Whether initializing audio was successful.</returns>
        internal static bool Initialize()
        {
            Deinitialize();
            switch (Interface.CurrentOptions.SoundRange)
            {
            case Interface.SoundRange.Low:
                OuterRadiusFactorMinimum      = 2.0;
                OuterRadiusFactorMaximum      = 8.0;
                OuterRadiusFactorMaximumSpeed = 1.0;
                break;

            case Interface.SoundRange.Medium:
                OuterRadiusFactorMinimum      = 4.0;
                OuterRadiusFactorMaximum      = 16.0;
                OuterRadiusFactorMaximumSpeed = 2.0;
                break;

            case Interface.SoundRange.High:
                OuterRadiusFactorMinimum      = 6.0;
                OuterRadiusFactorMaximum      = 24.0;
                OuterRadiusFactorMaximumSpeed = 3.0;
                break;
            }
            OuterRadiusFactor      = Math.Sqrt(OuterRadiusFactorMinimum * OuterRadiusFactorMaximum);
            OuterRadiusFactorSpeed = 0.0;
            OpenAlDevice           = Alc.OpenDevice(null);
            if (OpenAlDevice != IntPtr.Zero)
            {
                OpenAlContext = Alc.CreateContext(OpenAlDevice, (int[])null);
                if (OpenAlContext != ContextHandle.Zero)
                {
                    Alc.MakeContextCurrent(OpenAlContext);
                    try {
                        AL.SpeedOfSound(343.0f);
                    } catch {
                        MessageBox.Show(Interface.GetInterfaceString("errors_sound_openal_version"), Interface.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                    AL.DistanceModel(ALDistanceModel.None);
                    return(true);
                }
                Alc.CloseDevice(OpenAlDevice);
                OpenAlDevice = IntPtr.Zero;
                MessageBox.Show(Interface.GetInterfaceString("errors_sound_openal_context"), Interface.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(false);
            }
            OpenAlContext = ContextHandle.Zero;
            MessageBox.Show(Interface.GetInterfaceString("errors_sound_openal_device"), Interface.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
            return(false);
        }
Пример #11
0
        public OpenAlSoundEngine()
        {
            Console.WriteLine("Using OpenAL sound engine");

            if (Game.Settings.Sound.Device != null)
            {
                Console.WriteLine("Using device `{0}`", Game.Settings.Sound.Device);
            }
            else
            {
                Console.WriteLine("Using default device");
            }

            var dev = Alc.OpenDevice(Game.Settings.Sound.Device);

            if (dev == IntPtr.Zero)
            {
                Console.WriteLine("Failed to open device. Falling back to default");
                dev = Alc.OpenDevice(null);
                if (dev == IntPtr.Zero)
                {
                    throw new InvalidOperationException("Can't create OpenAL device");
                }
            }

            var ctx = Alc.CreateContext(dev, (int[])null);

            if (ctx == ContextHandle.Zero)
            {
                throw new InvalidOperationException("Can't create OpenAL context");
            }
            Alc.MakeContextCurrent(ctx);

            for (var i = 0; i < PoolSize; i++)
            {
                var source = 0;
                AL.GenSources(1, out source);
                if (0 != AL.GetError())
                {
                    Log.Write("sound", "Failed generating OpenAL source {0}", i);
                    return;
                }

                sourcePool.Add(source, new PoolSlot()
                {
                    IsActive = false
                });
            }
        }
Пример #12
0
        static string[] QueryDevices(string label, AlcGetStringList type)
        {
            // Clear error bit
            AL.GetError();

            var devices = Alc.GetString(IntPtr.Zero, type).ToArray();

            if (AL.GetError() != ALError.NoError)
            {
                Log.Write("sound", "Failed to query OpenAL device list using {0}", label);
                return(new string[] { });
            }

            return(devices);
        }
Пример #13
0
 public void Dispose()
 {
     Alc.MakeContextCurrent(ContextHandle.Zero);
     if (alContext != ContextHandle.Zero)
     {
         Alc.DestroyContext(alContext);
         alContext = ContextHandle.Zero;
     }
     if (alDevice != IntPtr.Zero)
     {
         Alc.CloseDevice(alDevice);
         alDevice = IntPtr.Zero;
     }
     Instance = null;
 }
Пример #14
0
        public static string[] AvailableDevices()
        {
            // Returns all devices under windows vista and newer
            if (Alc.alcIsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATE_ALL_EXT") == Alc.ALC_TRUE)
            {
                return(QueryDevices("ALC_ENUMERATE_ALL_EXT", Alc.ALC_ALL_DEVICES_SPECIFIER));
            }

            if (Alc.alcIsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATION_EXT") == Alc.ALC_TRUE)
            {
                return(QueryDevices("ALC_ENUMERATION_EXT", Alc.ALC_DEVICE_SPECIFIER));
            }

            return(new string[] {});
        }
Пример #15
0
        public AudioDevice(string device = null)
        {
            if (device == null)
            {
                device = Alc.GetString(IntPtr.Zero, AlcGetString.DefaultDeviceSpecifier);
            }

            deviceId = Alc.OpenDevice(device);
            if (deviceId == IntPtr.Zero)
            {
                throw new Exception("unable to open the specified audio device");
            }
            contextHandle = Alc.CreateContext(deviceId, new int[] { });
            this.Use();
        }
Пример #16
0
        static string[] QueryDevices(string label, int type)
        {
            // Clear error bit
            Al.alGetError();

            var devices = Alc.alcGetStringv(IntPtr.Zero, type);

            if (Al.alGetError() != Al.AL_NO_ERROR)
            {
                Log.Write("sound", "Failed to query OpenAL device list using {0}", label);
                return(new string[] {});
            }

            return(devices);
        }
Пример #17
0
        public static string[] AvailableDevices()
        {
            // Returns all devices under Windows Vista and newer
            if (Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATE_ALL_EXT"))
            {
                return(QueryDevices("ALC_ENUMERATE_ALL_EXT", AlcGetStringList.AllDevicesSpecifier));
            }

            if (Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATION_EXT"))
            {
                return(QueryDevices("ALC_ENUMERATION_EXT", AlcGetStringList.DeviceSpecifier));
            }

            return(new string[] { });
        }
        internal void CheckALCError(string operation)
        {
            AlcError error = Alc.GetError(_captureDevice);

            if (error == AlcError.NoError)
            {
                return;
            }

            string errorFmt = "OpenAL Error: {0}";

            throw new NoMicrophoneConnectedException(String.Format("{0} - {1}",
                                                                   operation,
                                                                   string.Format(errorFmt, error)));
        }
Пример #19
0
        /// <summary>Opens a device for audio recording.</summary>
        /// <param name="deviceName">The device name.</param>
        /// <param name="frequency">The frequency that the data should be captured at.</param>
        /// <param name="sampleFormat">The requested capture buffer format.</param>
        /// <param name="bufferSize">The size of OpenAL's capture internal ring-buffer. This value expects number of samples, not bytes.</param>
        public AudioCapture(string deviceName, int frequency, ALFormat sampleFormat, int bufferSize)
        {
            if (!AudioDeviceEnumerator.IsOpenALSupported)
            {
                throw new DllNotFoundException("openal32.dll");
            }
            if (frequency <= 0)
            {
                throw new ArgumentOutOfRangeException("frequency");
            }
            if (bufferSize <= 0)
            {
                throw new ArgumentOutOfRangeException("bufferSize");
            }

            // Try to open specified device. If it fails, try to open default device.
            device_name = deviceName;
            Handle      = Alc.CaptureOpenDevice(deviceName, frequency, sampleFormat, bufferSize);

            if (Handle == IntPtr.Zero)
            {
                Debug.WriteLine(ErrorMessage(deviceName, frequency, sampleFormat, bufferSize));
                device_name = "IntPtr.Zero";
                Handle      = Alc.CaptureOpenDevice(null, frequency, sampleFormat, bufferSize);
            }

            if (Handle == IntPtr.Zero)
            {
                Debug.WriteLine(ErrorMessage("IntPtr.Zero", frequency, sampleFormat, bufferSize));
                device_name = AudioDeviceEnumerator.DefaultRecordingDevice;
                Handle      = Alc.CaptureOpenDevice(AudioDeviceEnumerator.DefaultRecordingDevice, frequency, sampleFormat, bufferSize);
            }

            if (Handle == IntPtr.Zero)
            {
                // Everything we tried failed. Capture may not be supported, bail out.
                Debug.WriteLine(ErrorMessage(AudioDeviceEnumerator.DefaultRecordingDevice, frequency, sampleFormat, bufferSize));
                device_name = "None";

                throw new AudioDeviceException("All attempts to open capture devices returned IntPtr.Zero. See debug log for verbose list.");
            }

            // handle is not null, check for some Alc Error
            CheckErrors();

            SampleFormat    = sampleFormat;
            SampleFrequency = frequency;
        }
Пример #20
0
        private void Dispose(bool manual)
        {
            if (!this.IsDisposed)
            {
                if (this.Handle != IntPtr.Zero)
                {
                    if (this._isrecording)
                    {
                        this.Stop();
                    }

                    Alc.CaptureCloseDevice(this.Handle);
                }
                this.IsDisposed = true;
            }
        }
Пример #21
0
 // deinitialize
 internal static void Deinitialize()
 {
     if (OpenAlContext != ContextHandle.Zero)
     {
         SoundManager.StopAllSounds(true);
         SoundManager.UnuseAllSoundsBuffers();
         Alc.MakeContextCurrent(ContextHandle.Zero);
         Alc.DestroyContext(OpenAlContext);
         OpenAlContext = ContextHandle.Zero;
     }
     if (OpenAlDevice != IntPtr.Zero)
     {
         Alc.CloseDevice(OpenAlDevice);
         OpenAlDevice = IntPtr.Zero;
     }
 }
Пример #22
0
        public void CheckALError(string operation)
        {
            _lastOpenALError = Alc.GetError(_device);

            if (_lastOpenALError == AlcError.NoError)
            {
                return;
            }

            string errorFmt = "OpenAL Error: {0}";

            Console.WriteLine(String.Format("{0} - {1}",
                                            operation,
                                            //string.Format (errorFmt, Alc.GetString (_device, _lastOpenALError))));
                                            string.Format(errorFmt, _lastOpenALError)));
        }
Пример #23
0
 /// <summary>Deinitializes audio.</summary>
 internal static void Deinitialize()
 {
     StopAllSounds();
     UnloadAllBuffers();
     if (OpenAlContext != ContextHandle.Zero)
     {
         Alc.MakeContextCurrent(ContextHandle.Zero);
         Alc.DestroyContext(OpenAlContext);
         OpenAlContext = ContextHandle.Zero;
     }
     if (OpenAlDevice != IntPtr.Zero)
     {
         Alc.CloseDevice(OpenAlDevice);
         OpenAlDevice = IntPtr.Zero;
     }
 }
Пример #24
0
        public void Dispose()
        {
            if (_context != ContextHandle.Zero)
            {
                Alc.MakeContextCurrent(ContextHandle.Zero);

                Alc.DestroyContext(_context);
            }
            _context = ContextHandle.Zero;

            if (_device != IntPtr.Zero)
            {
                Alc.CloseDevice(_device);
            }
            _device = IntPtr.Zero;
        }
Пример #25
0
        public AudioDevice(string deviceName)
        {
            if (deviceName != null && !AvailableDevices.Contains(deviceName))
            {
                throw new InvalidOperationException(string.Format("AudioDevice \"{0}\" does not exist.", deviceName));
            }

            Context = new OpenTK.Audio.AudioContext(deviceName, 0, 15, true, true, AudioContext.MaxAuxiliarySends.UseDriverDefault);
            CheckAlcError();
            deviceHandle = Alc.GetContextsDevice(Alc.GetCurrentContext());
            CheckAlcError();
            Efx = new EffectsExtension();
            CheckAlcError();

            int[] val = new int[4];
            DeviceName    = Context.CurrentDevice;
            VendorName    = AL.Get(ALGetString.Vendor);
            Renderer      = AL.Get(ALGetString.Renderer);
            DriverVersion = AL.Get(ALGetString.Version);
            int major, minor;

            Alc.GetInteger(deviceHandle, AlcGetInteger.MajorVersion, 1, val);
            major = val[0];
            Alc.GetInteger(deviceHandle, AlcGetInteger.MinorVersion, 1, val);
            minor   = val[0];
            Version = new Version(major, minor);
            Alc.GetInteger(deviceHandle, AlcGetInteger.EfxMajorVersion, 1, val);
            major = val[0];
            Alc.GetInteger(deviceHandle, AlcGetInteger.EfxMinorVersion, 1, val);
            minor      = val[0];
            EfxVersion = new Version(major, minor);
            Alc.GetInteger(deviceHandle, AlcGetInteger.EfxMaxAuxiliarySends, 1, val);
            MaxRoutes  = val[0];
            Extensions = new List <string>(AL.Get(ALGetString.Extensions).Split(' ')).AsReadOnly();

            AL.DistanceModel(ALDistanceModel.ExponentDistance);

            CheckAudioCapabilities(LogLevel.Verbose);
            LogDiagnostics(LogLevel.Verbose);

            Factory  = new AudioFactory(this);
            Listener = new AudioListener(this);
            Listener.Orientation(Vector3.UnitY, Vector3.UnitZ);

            updateTaskCancelation = new CancellationTokenSource();
            updateTask            = Task.Factory.StartNew(Update);
        }
Пример #26
0
        public OpenALDevice()
        {
            if (Instance != null)
            {
                throw new Exception("OpenALDevice already created!");
            }

            alDevice = Alc.OpenDevice(string.Empty);
            if (CheckALCError("Could not open AL device") || alDevice == IntPtr.Zero)
            {
                throw new Exception("Could not open AL device!");
            }

            int[] attribute = new int[0];
            alContext = Alc.CreateContext(alDevice, attribute);
            if (CheckALCError("Could not create OpenAL context") || alContext == ContextHandle.Zero)
            {
                Dispose();
                throw new Exception("Could not create OpenAL context");
            }

            Alc.MakeContextCurrent(alContext);
            if (CheckALCError("Could not make OpenAL context current"))
            {
                Dispose();
                throw new Exception("Could not make OpenAL context current");
            }

            EFX = new EffectsExtension();

            float[] ori = new float[]
            {
                0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f
            };
            AL.Listener(ALListenerfv.Orientation, ref ori);
            AL.Listener(ALListener3f.Position, 0.0f, 0.0f, 0.0f);
            AL.Listener(ALListener3f.Velocity, 0.0f, 0.0f, 0.0f);
            AL.Listener(ALListenerf.Gain, 1.0f);

            // We do NOT use automatic attenuation! XNA does not do this!
            AL.DistanceModel(ALDistanceModel.None);

            instancePool        = new List <SoundEffectInstance>();
            dynamicInstancePool = new List <DynamicSoundEffectInstance>();

            Instance = this;
        }
Пример #27
0
        /// <summary>
        ///
        /// </summary>
        private void CleanUpOpenAl()
        {
            Alc.MakeContextCurrent(NullContext);

            if (_context != NullContext)
            {
                Alc.DestroyContext(_context);
                _context = NullContext;
            }
            if (_device != IntPtr.Zero)
            {
                Alc.CloseDevice(_device);
                _device = IntPtr.Zero;
            }

            _bSoundAvailable = false;
        }
        public AlcDiagnostic(IntPtr dev)
        {
            Trace.WriteLine("--- Alc related errors ---");

            Alc.GetInteger(dev, AlcGetInteger.MajorVersion, 1, out MajorVersion);
            Alc.GetInteger(dev, AlcGetInteger.MinorVersion, 1, out MinorVersion);
            Alc.GetInteger(dev, AlcGetInteger.EfxMajorVersion, 1, out EfxMajorVersion);
            Alc.GetInteger(dev, AlcGetInteger.EfxMinorVersion, 1, out EfxMinorVersion);
            Alc.GetInteger(dev, AlcGetInteger.EfxMaxAuxiliarySends, 1, out EfxMaxAuxiliarySends);

            ExtensionString = Alc.GetString(dev, AlcGetString.Extensions);

            foreach (string s in Alc_Extension_C_Names)
            {
                Extensions.Add(s, Alc.IsExtensionPresent(dev, s));
            }
        }
Пример #29
0
        //

        public OpenALCaptureSound(SoundModes mode, int channels, int frequency, int bufferSize)
        {
            mode |= SoundModes.Loop | SoundModes.Software;

            int alFormat = channels == 2 ? Al.AL_FORMAT_STEREO16 : Al.AL_FORMAT_MONO16;

            alCaptureDevice = Alc.alcCaptureOpenDevice(OpenALSoundWorld.captureDeviceName, frequency, alFormat, bufferSize);
            if (alCaptureDevice == IntPtr.Zero)
            {
                return;
            }

            this.channels  = channels;
            this.frequency = frequency;

            Init(null, mode, 100000.0f, channels, frequency);
        }
Пример #30
0
 public static void Teardown()
 {
     foreach (object o in Sounds.Keys)
     {
         Sound sound = (Sound)Sounds[o];
         AL.SourceStop(sound.SourceId);
         AL.DeleteSource(sound.SourceId);
         AL.DeleteBuffer(sound.BufferId);
     }
     if (Alc.MakeContextCurrent(ContextHandle.Zero))
     {
         Alc.DestroyContext(AudioCtx);
         if (Alc.CloseDevice(AudioDevice))
         {
         }
     }
 }