如何将系统麦克风音频流传输到连接的设备麦克风音频流 [英] How transfer system mic audio stream to attached device mic audio stream

查看:116
本文介绍了如何将系统麦克风音频流传输到连接的设备麦克风音频流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接用于电话呼叫的 USB 设备,该设备具有用于麦克风和扬声器的 pnp 声音控制器.现在我有两个扬声器和两个麦克风用于输入输出,如下图所示..现在我的目的是将音频流从系统麦克风传输到 USB 麦克风,从 USB 扬声器传输到系统扬声器.

I am trying to attach USB device used for tele calling which have pnp sound controller for mic and speaker. Now i have two speaker and two mic for input output as shown in image below.. Now my motive is to transfer audio stream from system mic to usb mic and from usb speaker to system speaker.

我试图用虚拟电缆软件解决这个问题,但我需要依赖第三方.使用 c# 可以实现的可能解决方案是什么.

I tried to solve this issue with virtual cable software but with this i need to depend on third party. What can be the possible solution that can attained using c#.

我对此一无所知,所以不知道如何开始.谷歌搜索后我发现

I don't have knowledge about this, so don't know how to start. After googling i found

  1. CS 核心
  2. N 音频

可以帮助我,我不知道如何.

Can help me i don't know how.

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

    private void button1_Click(object sender, EventArgs e)
    {
        List<NAudio.Wave.WaveInCapabilities> sources = new List<NAudio.Wave.WaveInCapabilities>();

        for (int i = 0; i < NAudio.Wave.WaveIn.DeviceCount; i++)
        {
            sources.Add(NAudio.Wave.WaveIn.GetCapabilities(i));
        }

        sourceList.Items.Clear();

        foreach (var source in sources)
        {
            ListViewItem item = new ListViewItem(source.ProductName);
            item.SubItems.Add(new ListViewItem.ListViewSubItem(item, source.Channels.ToString()));
            sourceList.Items.Add(item);
        }
    }

    NAudio.Wave.WaveIn sourceStream,sourceStream1 = null;
    NAudio.Wave.DirectSoundOut waveOut = null;

    private void button2_Click(object sender, EventArgs e)
    {
        if (sourceList.SelectedItems.Count == 0) return;

        int deviceNumber = sourceList.SelectedItems[0].Index;

        sourceStream = new NAudio.Wave.WaveIn();
        sourceStream.DeviceNumber = 0;
        sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(deviceNumber).Channels);



        NAudio.Wave.WaveInProvider waveIn = new NAudio.Wave.WaveInProvider(sourceStream1);
        sourceStream.
        waveOut = new NAudio.Wave.DirectSoundOut();
        waveOut.Init(waveIn);

        sourceStream1.StartRecording();
        waveOut.Play();
    }

    private void button3_Click(object sender, EventArgs e)
    {
        if (waveOut != null)
        {
            waveOut.Stop();
            waveOut.Dispose();
            waveOut = null;
        }
        if (sourceStream != null)
        {
            sourceStream.StopRecording();
            sourceStream.Dispose();
            sourceStream = null;
        }
    }

    private void button4_Click(object sender, EventArgs e)
    {
        button3_Click(sender, e);
        this.Close();
    }
}

使用此代码,我可以将麦克风音频发送到扬声器,但如何使用此代码实现我的任务.

Using this code i can send mic audio to speaker but how can i implement my task using this.

推荐答案

实际上,如果不编写任何自定义驱动程序,就无法做到这一点.您无法将音频数据渲染到输入设备.输入设备旨在从中读取数据.输出设备(扬声器)用于写入数据.

Actually there is no way to do this without writing any custom driver. You can not render audio data to a input device. Input devices are meant to read data from. Output devices (speakers) are meant to write data to.

有像虚拟音频线这样的程序,它们使用自定义驱动程序来绕过这些限制.

There are programs like virtual audio cable, which are using custom drivers to bypass these limitations.

这篇关于如何将系统麦克风音频流传输到连接的设备麦克风音频流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆