1

I'm using NAudio to output audio files to both the speaker and a headset on a window 10 laptop. I created two WaveOut and assigned the corresponding device number. But I cannot here the audio from the speaker when the headset is plugged in. Can anyone let me know how to solve this? Here's my code (it works fine on the headset or the speaker separately, but I want to hear the sound from both of them at the same time):

        var input1 = new Mp3FileReader(PATH + "left.mp3");
        var input2 = new Mp3FileReader(PATH + "right.mp3");
        var waveProvider = new MultiplexingWaveProvider(new IWaveProvider[] { input1, input2 }, 2);

        var input3 = new Mp3FileReader(PATH + "left.mp3");

        int channel = ((Mp3FileReader)input1).Mp3WaveFormat.Channels;
        Debug.WriteLine(channel);

        waveProvider.ConnectInputToOutput(0, 0);
        waveProvider.ConnectInputToOutput(3, 1);

        WaveOut wave = new WaveOut();
        wave.DeviceNumber = 1;
        wave.Init(waveProvider);

        WaveOut wave1 = new WaveOut();
        wave1.DeviceNumber = 0;
        wave1.Init(input3);

        wave.Play();
        wave1.Play();
4

1 回答 1

1

我认为问题在于您没有两张声卡,您只有一张声​​卡在扬声器和耳机播放声音之间切换。如果您购买了 USB 耳机,那么您将拥有两个声卡,并且应该能够分别通过每个声卡播放不同的声音。

于 2017-06-20T11:05:15.717 回答