public int Read(byte[] buffer, int offset, int count) { if (count % this.bytesPerSample != 0) { throw new ArgumentException("Must read an whole number of samples", "count"); } Array.Clear(buffer, offset, count); int num = 0; byte[] array = new byte[count]; lock (this.inputs) { foreach (IWaveProvider waveProvider in this.inputs) { int num2 = waveProvider.Read(array, 0, count); num = Math.Max(num, num2); if (num2 > 0) { MixingWaveProvider32.Sum32BitAudio(buffer, offset, array, num2); } } } return(num); }
// // Export button // private void exportToolStripMenuItem1_Click(object sender, EventArgs e) { //Debugs On the table deleteTempFilesToolStripMenuItem.Enabled = false; //mic stop if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); } else if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } //loopback stop else if (gravae != null) { gravae.StopRecording(); gravae.Dispose(); } else if (wri != null) { wri.Dispose(); wri = null; } if (File.Exists(@"C:\Windows\Temp\outputTemp.wav")) { File.Delete(@"C:\Windows\Temp\outputTemp.wav"); } if (File.Exists(@"C:\Windows\Temp\output4Chanels.wav")) { // //Muda o channel do output // int outRate = 44100; var inFile = @"C:\Windows\Temp\output4Chanels.wav"; var outFile = @"C:\Windows\Temp\outputTemp.wav"; using (var reader = new WaveFileReader(inFile)) { var outFormat = new WaveFormat(outRate, 2); using (var resampler = new MediaFoundationResampler(reader, outFormat)) { resampler.ResamplerQuality = 60; WaveFileWriter.CreateWaveFile(outFile, resampler); } } // //Mixa as Stream microphone e loopBack // foreach (WavePlayer clip in Clips) { clip.Dispose(); } Clips.Clear(); foreach (string file in files) { Clips.Add(new WavePlayer(file)); } var mixer = new MixingWaveProvider32(Clips.Select(c => c.Channel)); SaveFileDialog save = new SaveFileDialog(); save.Filter = "Mp3 Files (*.mp3)|*.mp3"; if (save.ShowDialog() != DialogResult.OK) return; this.UseWaitCursor = true; MediaFoundationEncoder.EncodeToMp3(mixer, save.FileName, 128); MessageBox.Show("Export High Light Done!"); this.UseWaitCursor = false; } }