【问题标题】:How to play the microphone audio using DirectSound or API?如何使用 DirectSound 或 API 播放麦克风音频?
【发布时间】:2014-02-22 22:26:30
【问题描述】:

我想实时播放音频麦克风输入。

如果使用DirectSound。我可以从 Buffer 中获取音频数据,但我不知道如何播放我得到的数据。

如果使用 API:我今天早上收到了一个 C++ 示例。

它使用了一些API函数,例如“waveInOpen”。但是我对C++知之甚少。我不知道如何在其他编程语言中使用这些API函数......

那我该怎么办?

【问题讨论】:

    标签: c# microphone directsound cscore


    【解决方案1】:

    您可以使用CSCore 来做到这一点:

    private static void Main(string[] args)
    {
        using(var capture = new WasapiCapture())
        {
            capture.Initialize();
    
            using(var source = new SoundInSource(capture))
            {
                using(var soundOut = new WasapiOut())
                {
                    capture.Start();
    
                    soundOut.Initialize(source);
                    soundOut.Play();
    
                    Console.ReadKey();
                }
            }
        }
    }
    

    【讨论】:

    • 好!简单实用...非常感谢!
    猜你喜欢
    • 2018-06-18
    • 2018-02-14
    • 1970-01-01
    • 2013-06-28
    • 1970-01-01
    • 2014-01-01
    • 2016-10-13
    • 1970-01-01
    • 2023-01-10
    相关资源
    最近更新 更多