【问题标题】:Getting data from a microphone in C#在 C# 中从麦克风获取数据
【发布时间】:2011-02-20 15:46:54
【问题描述】:

我正在尝试从麦克风(或线路输入)录制音频数据,然后使用 C# 重新播放。

关于如何实现这一点的任何建议?

【问题讨论】:

标签: c# audio microphone


【解决方案1】:

看看使用NAudio 的开源.NET Voice Recorder 项目。有an article on Coding4Fun 解释它是如何工作的。

【讨论】:

    【解决方案2】:

    Console and multithreaded recording and playback

    class Program
    {
    
        static void Main(string[] args)
        {
            rex.Data += new RecorderEx.DataEventHandler(rex_Data);
            rex.Open += new EventHandler(rex_Open);
            rex.Close += new EventHandler(rex_Close);
            rex.Format = pcmFormat;
            rex.StartRecord();
            Console.WriteLine("Please press enter to exit!");
            Console.ReadLine();
            rex.StopRecord();
        }
    
        static RecorderEx rex = new RecorderEx(true);
        static PlayerEx play = new PlayerEx(true);
        static IntPtr pcmFormat = AudioCompressionManager.GetPcmFormat(1, 16, 44100);
    
        static void rex_Open(object sender, EventArgs e)
        {
            play.OpenPlayer(pcmFormat);
            play.StartPlay();
        }
    
        static void rex_Close(object sender, EventArgs e)
        {
            play.ClosePlayer();
        }
    
        static void rex_Data(object sender, DataEventArgs e)
        {
            byte[] data = e.Data;
            play.AddData(data);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多