我已经有一段时间了,但没有取得任何进展.所以这是我最后的手段!
我正在尝试将系统音频(我在耳机中听到的音频)发送到Skype(让我的通话中的人听到我基本听到的内容).而且我想我会使用Skype4comlib和naudio来做这件事.
我所做的是创建一个类,它使用WasapiLoopbackCapture和WaveFileWriter将临时数据写入.wav文件,并使用SkypeSystemAudio.set_InputDevice方法重定向音频.但当我与某人交谈并尝试开始录音时,该人不再听到我了.我只是完全安静,没有声音播放给这个人.
我认为最好是我发布全班,因为它更容易理解一切.
public class SkypeSystemAudio
{
public NAudio.Wave.WasapiLoopbackCapture capture;
NAudio.CoreAudioApi.MMDevice device;
NAudio.Wave.WaveFileWriter writer;
private Call CurrentCall = null;
private Skype SkypeApplet;
private const int SkypeProtocol = 9;
private bool IsRecording = false;
public string tempfilepath = System.IO.Directory.GetCurrentDirectory() + @"\temp.wav";
#region Public
public void Initialize()
{
device = NAudio.Wave.WasapiLoopbackCapture.GetDefaultLoopbackCaptureDevice();
Init();
}
public void Initialize(NAudio.CoreAudioApi.MMDevice device)
{
this.device = device;
Init();
}
public void StartRecording()
{
capture.StartRecording();
if (CurrentCall != null)
{
CurrentCall.set_OutputDevice(TCallIoDeviceType.callIoDeviceTypeFile, tempfilepath);
IsRecording = true;
}
}
public void StopRecording()
{
capture.StopRecording();
if (CurrentCall != null)
{
CurrentCall.set_OutputDevice(TCallIoDeviceType.callIoDeviceTypeFile, "");
}
}
#endregion
private void Init()
{
capture = new WasapiLoopbackCapture(device);
capture.ShareMode = NAudio.CoreAudioApi.AudioClientShareMode.Shared;
capture.DataAvailable += capture_DataAvailable;
capture.RecordingStopped += capture_RecordingStopped;
WaveFormat format = new WaveFormat(16000, 1); // skype wants 16 Bit samples, 16khz, mono WAV file
//tried using the standard waveformat in the device object too. Didn't work though.
writer = new WaveFileWriter(tempfilepath, format );
SkypeApplet = new Skype();
SkypeApplet.Attach(SkypeProtocol, true);
SkypeApplet.CallStatus += SkypeApplet_CallStatus;
}
void SkypeApplet_CallStatus(Call pCall, TCallStatus Status)
{
if (Status == TCallStatus.clsRinging)
{
CurrentCall = pCall;
pCall.Answer();
}
}
void capture_DataAvailable(object sender, WaveInEventArgs e)
{
if (writer != null)
writer.Write(e.Buffer, 0, e.BytesRecorded);
}
void capture_RecordingStopped(object sender, StoppedEventArgs e)
{
IsRecording = false;
}
}
有谁知道为什么这不起作用?我没有线索了下一步该做什么.
任何帮助将不胜感激!
最佳答案 我实际上做了类似的事情,但没有使用Skype4COM.
我所做的就是像Sebastian L建议的那样使用“虚拟电缆”,这样你可以控制进出skype的内容,缺点是你需要安装虚拟电缆并配置Skype才能使用它们.
电缆将作为标准输入/输出出现在音频设备中.
希望能帮助到你.