我正在尝试使用 DirectSound 从麦克风捕获声音。这是我的代码:
using Microsoft.DirectX.DirectSound;
public MicrophoneSensor()
{
CaptureBufferDescription micBufferDesc = new CaptureBufferDescription();
WaveFormat format = new WaveFormat();
format.SamplesPerSecond = 22000;
format.Channels = 1;
format.BitsPerSample = 8;
format.AverageBytesPerSecond = 22000;
format.BlockAlign = 1;
micBufferDesc.Format = format;
micBufferDesc.BufferBytes = 100000;
micBufferDesc.ControlEffects = false;
micBufferDesc.WaveMapped = true;
micBuffer = new CaptureBuffer(micBufferDesc, microphone);
}
micBufferDesc 和格式变量的实例化导致 Visual Studio 2008 抛出以下错误:
以下方法或属性之间的调用不明确:“Microsoft.DirectX.DirectSound.CaptureBufferDescription.CaptureBufferDescription()”和“Microsoft.DirectX.DirectSound.CaptureBufferDescription.CaptureBufferDescription()”
和
以下方法或属性之间的调用不明确:“Microsoft.DirectX.DirectSound.WaveFormat.WaveFormat()”和“Microsoft.DirectX.DirectSound.WaveFormet.WaveFormat()”
我已经尝试了很多不同的说明命名空间和 using 语句的组合,但没有运气。
我还检查了解决方案资源管理器中的引用,据我所知没有重复。
一个只有 Microsoft.DirectX.DirectSound 引用的全新测试项目仍然会引发相同的错误。
我还卸载并重新安装了 DirectX SDK(2009 年 3 月)以及 DirectX SDK(2008 年 11 月)。仍然没有运气。
最后,我在实验室的另一台计算机上尝试了一个新项目,但仍然无法正常工作。
以下是我的参考资料:
- 图形
- Microsoft.DirectX.DirectSound
- Microsoft.DirectX.DirectInput
- 演示核心
- 演示框架
- 服务
- 系统
- 系统核心
- 系统数据
- System.Data.DataSetExtensions
- 系统部署
- 系统绘图
- System.Runtime.Serialization
- 系统.服务模型
- System.Windows.Forms
- 系统文件
- System.Xml.Linq
- UIAutomationProvider
- 视窗基地
- Windows窗体集成