private void button1_Click(object sender, EventArgs e) { var ofn = new OpenFileDialog(); ofn.Filter = CodecFactory.SupportedFilesFilterEN; if (ofn.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Stop(); if (WasapiOut.IsSupportedOnCurrentPlatform) { _soundOut = new WasapiOut(); } else { _soundOut = new DirectSoundOut(); } var source = CodecFactory.Instance.GetCodec(ofn.FileName); source = new LoopStream(source) { EnableLoop = false }; (source as LoopStream).StreamFinished += (s, args) => Stop(); _eq = Equalizer.Create10BandEqualizer(source); _soundOut.Initialize(_eq.ToWaveSource(16)); _soundOut.Play(); } }
public void Open(string filename) { CleanupPlayback(); var source = CodecFactory.Instance.GetCodec(filename); volumeSource = new VolumeSource(source); equalizer = Equalizer.Create10BandEqualizer(volumeSource); finalSource = equalizer .ToStereo() .ChangeSampleRate(44100) .AppendSource(Equalizer.Create10BandEqualizer, out equalizer) .ToWaveSource(16); if (WasapiOut.IsSupportedOnCurrentPlatform) soundOut = new WasapiOut() { Latency = 100, Device = device }; else soundOut = new DirectSoundOut(); soundOut.Initialize(finalSource); soundOut.Volume = deviceVolume; if (this.OpenCompleted != null) this.OpenCompleted(this, new EventArgs()); }
public void SetEqualizer(Equalizer eq) { if (eq != null) for (int i = 0; i < this.Length; i++) eq.SampleFilters[i].SetGain(this[i]); }