如何使用c#录制通信器呼叫 [英] How to record a communicator call using c#
问题描述
我想写一个程序来记录通讯器的来电。
我试过很多地方找到这个NAudio大会。但即使这样也无济于事,因为我无法在Naudio中使用环回来初始化音频。
如果有人知道任何替代方案,请帮助,
感谢
Hi,
I want to write a program to record the calls made by the communicator.
I tried many places and find this NAudio Assembly. But even that is not helping since I can''t initialize audioclient using loopback in Naudio.
If any one knows any alternative please help,
Thanks
推荐答案
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NAudio.Mixer;
using NAudio.Wave;
using NAudio.CoreAudioApi;
using NAudio.Midi;
using System.Threading;
using System.Management;
using System.Diagnostics;
namespace ConsoleApplication1
{
class RecordSound
{
public void TestSoundCapture()
{
MMDeviceEnumerator mEn = new MMDeviceEnumerator();
MMDeviceCollection deviceCol = mEn.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active);
Console.WriteLine("All listed Devices are");
Console.WriteLine("*----------------------*");
foreach (MMDevice m in mEn.EnumerateAudioEndPoints(DataFlow.All, DeviceState.All))
{
Console.WriteLine(m.FriendlyName);
}
Console.WriteLine("\nAll active Devices are");
Console.WriteLine("*----------------------*");
foreach (MMDevice m in deviceCol)
{
Console.WriteLine(m.FriendlyName);
}
MMDevice mmDevice = mEn.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Communications);
Console.WriteLine("\nDefault device is " + mmDevice.FriendlyName.ToString());
//mmDevice.AudioClient.Start();
//Console.WriteLine(mmDevice.AudioClient.BufferSize.ToString());
AudioClient ac = mmDevice.AudioClient;
if (mmDevice.State == DeviceState.Active)
{
int x = mmDevice.AudioEndpointVolume.Channels.Count;
Console.WriteLine(x.ToString());
}
WaveFormat wf = ac.MixFormat;
ac.Initialize(AudioClientShareMode.Shared, AudioClientStreamFlags.Loopback, 10000000, 0, wf, Guid.Empty)
DirectSoundOut dso = new DirectSoundOut();
WaveIn wavIn = new WaveIn();
WaveOut wout = new WaveOut();
WaveMixerStream32 wm = new WaveMixerStream32();
WaveFileWriter WFR = new WaveFileWriter("C://NVIDIA//TEST.WAV", wm.WaveFormat);
Console.ReadLine();
}
}
}
以上是我尝试使用Nvideo程序集的代码。我把它标记为粗体(对不起,不知道如何改变颜色,尝试但颜色来自其他位置而不是意图:))
我想要记录作为Loopback,它会将麦克风和扬声器声音保存在一起。在ac.Initialize方法中,AudioClientStreamFlags.Loopback抛出异常。没有其他值导致任何问题...
谢谢。
Above is the code I tried using Nvideo assembly. I marked it as bold(sorry ,don''t know how to change color ,tried but color comes in other location than intented :))
I want to record as Loopback then it will save both mic and speaker sound together. There in ac.Initialize method AudioClientStreamFlags.Loopback throws exception. No other values cause any issues...
Thanks.
这篇关于如何使用c#录制通信器呼叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!