Get Audio from PC microphone with a C# program

こ雲淡風輕ζ 提交于 2019-12-22 01:16:27

问题


I need to capture audio from a PC with Windows 7 with a C# program. I need to get all the frequencies until 20 khz. Do you know if there are a way to do it?


回答1:


You could take a look at the NAudio Library at codeplex http://naudio.codeplex.com.

A nice project for recording mic input with NAudio can be found here http://voicerecorder.codeplex.com/.




回答2:


I found some links that could help you

Visit http://www.codeproject.com/Articles/2615/DirectShow-NET? Or http://www.codeproject.com/Articles/4889/A-full-duplex-audio-player-in-C-using-the-waveIn-w?

Or You could use Matalab and Link it with .Net using Liydos dlls




回答3:


Just try to use winmm.dll api function. Here is simple example.

    using System;
    using System.Runtime.InteropServices;
    using System.Threading;

    namespace MicrophoneTest
    {
        class Program
        {

            [DllImport("winmm.dll")]
            private static extern int mciSendString(string MciComando, string MciRetorno, int MciRetornoLeng, int CallBack);

            static void Main(string[] args)
            {
                //create Test alias
                mciSendString("open new type waveaudio alias Test", null, 0, 0);

                //start
                mciSendString("record Test", null, 0, 0);

                Thread.Sleep(3000);

                //pause
                mciSendString("pause Test", null, 0, 0);

                //save
                mciSendString("save Test " + "test.wav", null, 0, 0);
                mciSendString("close Test", null, 0, 0);

                //press any key
                Console.ReadKey();
            }
        }
    }

Function signature MSDN: mciSendString function.

List of commands MSDN: Command Strings.



来源:https://stackoverflow.com/questions/10893674/get-audio-from-pc-microphone-with-a-c-sharp-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!