Ejemplo n.º 1
0
        /// <summary>
        /// Initialize the NAudio framework
        /// </summary>
        private void InitializeNAudioLibrary()
        {
            try
            {
                m_latency = Properties.Settings.Default.Latency;

                m_logger.Info("OS Info: " + Environment.OSVersion.ToString());

                // string soundOutput = "WasapiOut";
                string soundOutput = "WaveOut";

                // Set the wave output device based on the configuration setting
                switch (soundOutput)
                {
                    case "WasapiOut":
                        m_waveOutDevice = new WasapiOut(global::NAudio.CoreAudioApi.AudioClientShareMode.Shared, m_latency);
                        break;

                    case "DirectSound":
                        m_waveOutDevice = new DirectSoundOut(m_latency);
                        break;

                    default:
                    case "WaveOut":
                        m_waveOutDevice = new WaveOut();
                        break;
                }

                m_waveOutDevice.PlaybackStopped += waveOutDevice_PlaybackStopped;
                m_logger.Info("Wave Output Device that is actually being used: {0}", m_waveOutDevice.GetType().ToString());
            }
            catch (Exception driverCreateException)
            {
                m_logger.ErrorException("NAudio Driver Creation Failed", driverCreateException);
                throw driverCreateException;
            }
        }