Exemple #1
0
        /// <summary>
        /// Mixes two wav files to a single wav file. (Unused).
        /// </summary>
        public void mix()
        {
            window.lockForMixing();

            WaveFileReader reader1 = new WaveFileReader(file1);
            WaveFileReader reader2 = new WaveFileReader(file2);

            int        maxSampleRate = Math.Max(reader1.WaveFormat.SampleRate, reader2.WaveFormat.SampleRate);
            WaveFormat format        = new WaveFormat(maxSampleRate, 1);

            MediaFoundationResampler resampler1 = new MediaFoundationResampler(reader1, format);
            var input1 = resampler1.ToSampleProvider();
            MediaFoundationResampler resampler2 = new MediaFoundationResampler(reader2, format);
            var input2 = resampler2.ToSampleProvider();

            ISampleProvider[] provider = { input1, input2 };

            MixingSampleProvider mixer = new MixingSampleProvider(provider);

            WaveFileWriter.CreateWaveFile16(mixfile, mixer);

            resampler1.Dispose();
            resampler2.Dispose();
            reader1.Close();
            reader2.Close();
            reader1.Dispose();
            reader2.Dispose();

            window.unlock();
        }
Exemple #2
0
 public void stopRecording()
 {
     micCapture.StopRecording();
     speakCapture.StopRecording();
     micWriter.Close();
     micWriter.Dispose();
     speakWriter.Close();
     speakWriter.Dispose();
     soundOut.Stop();
     soundOut.Dispose();
     window.unlock();
 }
        /// <summary>
        /// Stops recording.
        /// </summary>
        public void stopRecording()
        {
            micCapture.Stop();
            speakCapture.Stop();
            micWriter.Dispose();
            speakWriter.Dispose();
            micCapture.Dispose();
            speakCapture.Dispose();
            window.unlock();
            string size1 = "-1";
            string size2 = "-1";

            if (File.Exists(micFileName))
            {
                FileInfo f      = new FileInfo(micFileName);
                int      mbytes = (int)(f.Length / 1024 / 1024);
                size1 = mbytes.ToString();
            }
            else
            {
                MessageBox.Show("No file with name\n   " + micFileName + "\nexists.\n\nMicrophone may not have been recorded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (File.Exists(speakFileName))
            {
                FileInfo f      = new FileInfo(speakFileName);
                int      mbytes = (int)(f.Length / 1024 / 1024);
                size2 = mbytes.ToString();
            }
            else
            {
                MessageBox.Show("No file with name\n   " + speakFileName + "\nexists.\n\nSpeakers may not have been recorded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            window.setLabelMicText(micFileName + "   -   " + size1 + "MB");
            window.setLabelSpeakText(speakFileName + "   -   " + size2 + "MB");
        }