/// <summary> /// Creates input provider needed for reading an audio file into the SoundTouch library /// </summary> /// <param name="filename"></param> private void CreateSoundTouchInputProvider(string filename) { CreateInputWaveChannel(filename); WaveFormat format = m_waveChannel.WaveFormat; m_inputProvider = new AdvancedBufferedWaveProvider(format); m_inputProvider.PlayPositionChanged += new EventHandler(inputProvider_PlayPositionChanged); m_inputProvider.MaxQueuedBuffers = 100; m_soundTouchSharp.SetSampleRate(format.SampleRate); m_soundTouchSharp.SetChannels(format.Channels); m_soundTouchSharp.SetTempoChange(0); m_soundTouchSharp.SetPitchSemiTones(0); m_soundTouchSharp.SetRateChange(0); m_soundTouchSharp.SetTempo(m_tempo); // Apply default SoundTouch settings m_soundTouchSharp.SetSetting(SoundTouchSharp.SoundTouchSettings.SETTING_USE_QUICKSEEK, 0); ApplySoundTouchTimeStretchProfile(); }
/// <summary> /// Terminates the NAudio library resources and connection /// </summary> private void TerminateNAudio() { if (m_inputProvider != null) { if (m_inputProvider is IDisposable) { (m_inputProvider as IDisposable).Dispose(); } m_inputProvider = null; } if (m_waveChannel != null) { m_waveChannel.Dispose(); m_waveChannel = null; } if (m_blockAlignedStream != null) { m_blockAlignedStream.Dispose(); m_blockAlignedStream = null; } if (m_waveReader != null) { m_waveReader.Dispose(); m_waveReader = null; } if (m_waveOutDevice != null) { m_waveOutDevice.Dispose(); m_waveOutDevice = null; } m_logger.Debug("NAudio terminated"); }