如何通过特定的声卡播放音频?

编程入门 行业动态 更新时间:2024-10-26 15:17:49
本文介绍了如何通过特定的声卡播放音频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要从Visual Basic 6应用程序播放声音(.WAV文件).但是,该PC配备了多个声卡,用户应该可以使用它.

I need to play a sound (.WAV file) from a Visual Basic 6 application. However, the PC is equipped with multiple sound cards and the user should be able to use it.

到目前为止,支持默认的声卡,我将播放这样的声音:

Up till now a default sound card was supported and I would play a sound like this:

CommandString = "Open " & Chr$(34) & mstrFilename & Chr$(34) & " type waveaudio alias MediaFile" mciSendString CommandString, vbNullString, 0, 0& If PlayFromPercent <= 0 Then CommandString = "play MediaFile" lngRetcode = mciSendString(CommandString, vbNullString, 0, 0&) Else CommandString = "play MediaFile from " & CLng(lngLength * (PlayFromPercent / 100)) lngRetcode = mciSendString(CommandString, vbNullString, 0, 0&) End If

有没有办法针对特定的声卡修改此代码,或者我可以采用其他方法(例如DirectX或商业的3rd Party Library)?

Is there a way to adapt this code for a specific sound card or is there a different approach I could take (e.g. DirectX or a commercial 3rd Party Library)?

奖金,如果该方法支持从特定位置播放文件(如您所见,上面的代码支持该文件)

Bonus, if the approach supports playing the file from a specific position (as you can see, the code above supports it)

推荐答案

这可能有效;调用 mciSendCommand()和 MCI_SET & MCI_WAVE_SET_PARMS 将 wOutput 设置为所需的播放设备的ID.

This may work; call mciSendCommand() with MCI_SET & MCI_WAVE_SET_PARMS setting wOutput to the desired playback device's ID.

  • 您可以通过 mciGetDeviceID("waveaudio")
  • 获取 mciSendCommand()的 IDDevice
  • 尚不能100%清楚地知道 wOutput 想要什么,它的ID可能与 waveOutGetDevCaps()
  • 返回的ID相同
  • You can get IDDevice for mciSendCommand() via mciGetDeviceID("waveaudio")
  • Its not 100% clear what wOutput wants, its probably the same ID as returned by waveOutGetDevCaps()

更多推荐

如何通过特定的声卡播放音频?

本文发布于:2023-07-11 12:02:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093986.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:声卡   音频

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!