public void SelectRecoderProvider(int index) { this._store.SelectedRecoderProviderIndex = index; this.DisposeAudioResources(); this._waveIn = this._store.RecoderProviders[index] .CreateWaveIn(); this._waveIn.DataAvailable += this.WaveInDataAvailable; this._waveIn.RecordingStopped += this.WaveInRecordingStopped; this._waveIn.StartRecording(); var waveFormat = this._waveIn.WaveFormat; this._upperHarmonyPlayer = new PitchShiftPlayer(waveFormat, 0.5f); this._lowerHarmonyPlayer = new PitchShiftPlayer(waveFormat, -0.5f); if (this._store.IsUpperHarmonyEnabled) { this._upperHarmonyPlayer.Start(); } if (this._store.IsLowerHarmonyEnabled) { this._lowerHarmonyPlayer.Start(); } }
private void DisposeAudioResources() { if (this._waveIn != null) { this._waveIn.Dispose(); this._waveIn = null; } if (this._upperHarmonyPlayer != null) { this._upperHarmonyPlayer.Dispose(); this._upperHarmonyPlayer = null; } if (this._lowerHarmonyPlayer != null) { this._lowerHarmonyPlayer.Dispose(); this._lowerHarmonyPlayer = null; } }