Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: MIC stop working of USB headphone when capture speaker audio.

$
0
0
Hi mark
Here is my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NAudio.CoreAudioApi;
using NAudio.Lame;
using NAudio.Wave;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            wavtomp3();

        }
        static LameMP3FileWriter wri;
        static bool stopped = false;
        private WaveFileWriter writer;
        public void wavtomp3()
        {


            // Start recording from loopback
            IWaveIn waveIn = new WasapiLoopbackCapture();
            //  int bitrate = System.Convert.ToInt32(textBox2.Text);
            
            MessageBox.Show("BitsPerSample=" + waveIn.WaveFormat.ToString());
            MessageBox.Show("Sample Rtae=" + waveIn.WaveFormat.SampleRate.ToString());
            MessageBox.Show("Channels=" + waveIn.WaveFormat.Channels.ToString());
            MessageBox.Show("BitsPerSample=" + waveIn.WaveFormat.BitsPerSample.ToString());
           
           wri = new LameMP3FileWriter(@"E:\128bits.mp3", waveIn.WaveFormat,LAMEPreset.ABR_128);
             


                      waveIn.DataAvailable += waveIn_DataAvailable;
            waveIn.RecordingStopped += waveIn_RecordingStopped;
            waveIn.StartRecording();
           // stopped = false;



            
                    }

        static void waveIn_RecordingStopped(object sender, StoppedEventArgs e)
        {
            stopped = true;
        }

        static void waveIn_DataAvailable(object sender, WaveInEventArgs e)
        {
            if (wri != null)
                          wri.Write(e.Buffer, 0, e.BytesRecorded);
         }



       
        }


            }
}

Viewing all articles
Browse latest Browse all 5831

Latest Images

Trending Articles



Latest Images