我目前正在努力寻找以编程方式设置 USB 声卡的采样率和比特率的解决方案。我正在努力将我们的测试程序从 Windows XP 切换到 Windows 7,并且我们有一个像 USB 声卡一样的产品。我们的一些测试是通过声卡发送 48k 信号,并在将信号路由通过 DAC 后测量信号。我认为测量硬件固件/软件没有将其信号发生器置于独占模式,Windows 感到困惑并将设备置于共享模式,默认采样率为 44.1k/16bit,我想更改此值当我们将设备启动到 48k/24bit 时。
我希望有人能把我推向正确的方向,因为我所看到的一切都告诉我这是不可能的......(另外,我更喜欢 .NET 解决方案,或者我可以调用/执行的任何东西.NET 就可以了)。
这是我尝试过的一件事,但这最终只设置了一个用于播放音频的对象,它并没有设置好样本/位深度。
Imports NAudio.Wave
Module ConfigureDevice
Private Const SAMPLE_RATE As Integer = 48000
Private Const CHANNELS As Integer = 2
Sub Main(ByVal args() As String)
ConfigureDirectSound(args(0))
End Sub
Private Sub ConfigureDirectSound(ByVal name As String)
Dim out As New DirectSoundOut(GetWaveOutDeviceNumber(name))
Dim waveFormat = New WaveFormat(SAMPLE_RATE, CHANNELS)
Dim waveProvider = New BufferedWaveProvider(waveFormat)
out.Init(waveProvider)
End Sub
Private Function GetWaveOutDeviceNumber(ByVal name As String) As System.Guid
Dim devices = DirectSoundOut.Devices
For Each d In devices
If d.Description = name Then
Return d.Guid
End If
Next
Return Nothing
End Function
End Module