gpt4 book ai didi

c# - 在Windows 7中设置采样率

转载 作者:行者123 更新时间:2023-12-02 23:16:26 25 4
gpt4 key购买 nike

我目前正在努力寻找一种以编程方式设置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

最佳答案

看来您需要探索WASAPI。从我正在阅读的内容来看,除了更改音频文件本身之外,这是唯一以编程方式强制输出采样率的方法。

http://msdn.microsoft.com/en-us/library/windows/desktop/dd371455(v=vs.85).aspx

您可能需要在其中搜索C++ / CLI包装器(或自己编写),以在.NET中充分利用它。

关于c# - 在Windows 7中设置采样率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18113675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com