两块声卡,如何实现指定其中一块播放一个声音文件,另一块同时放另一个?

chenchn 2005-01-04 11:33:40
两块声卡,如何实现指定其中一块播放一个声音文件,另一块同时放另一个?
或者让一块的左声道放一个,右声道放另外一个?
...全文
173 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ibp 2005-01-19
  • 打赏
  • 举报
回复
waveOutOpen
Use Winmm.lib.
MMRESULT waveOutOpen(
LPHWAVEOUT phwo,
UINT_PTR uDeviceID,
LPWAVEFORMATEX pwfx,
DWORD_PTR dwCallback,
DWORD_PTR dwCallbackInstance,
DWORD fdwOpen
);
Parameters
phwo
Pointer to a buffer that receives a handle identifying the open waveform-audio output device. Use the handle to identify the device when calling other waveform-audio output functions. This parameter might be NULL if the WAVE_FORMAT_QUERY flag is specified for fdwOpen.
uDeviceID
Identifier of the waveform-audio output device to open. It can be either a device identifier or a handle of an open waveform-audio input device. You can use the following flag instead of a device identifier.
Value Meaning
WAVE_MAPPER The function selects a waveform-audio output device capable of playing the given format.

pwfx
Pointer to a WAVEFORMATEX structure that identifies the format of the waveform-audio data to be sent to the device. You can free this structure immediately after passing it to waveOutOpen.
dwCallback
Pointer to a fixed callback function, an event handle, a handle to a window, or the identifier of a thread to be called during waveform-audio playback to process messages related to the progress of the playback. If no callback function is required, this value can be zero. For more information on the callback function, see waveOutProc.
dwCallbackInstance
User-instance data passed to the callback mechanism. This parameter is not used with the window callback mechanism.
fdwOpen
Flags for opening the device. The following values are defined.
Value Meaning
CALLBACK_EVENT The dwCallback parameter is an event handle.
CALLBACK_FUNCTION The dwCallback parameter is a callback procedure address.
CALLBACK_NULL No callback mechanism. This is the default setting.
CALLBACK_THREAD The dwCallback parameter is a thread identifier.
CALLBACK_WINDOW The dwCallback parameter is a window handle.
WAVE_ALLOWSYNC If this flag is specified, a synchronous waveform-audio device can be opened. If this flag is not specified while opening a synchronous driver, the device will fail to open.
WAVE_FORMAT_DIRECT If this flag is specified, the ACM driver does not perform conversions on the audio data.
WAVE_FORMAT_QUERY If this flag is specified, waveOutOpen queries the device to determine if it supports the given format, but the device is not actually opened.
WAVE_MAPPED If this flag is specified, the uDeviceID parameter specifies a waveform-audio device to be mapped to by the wave mapper.

Return Values
Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
Value Description
MMSYSERR_ALLOCATED Specified resource is already allocated.
MMSYSERR_BADDEVICEID Specified device identifier is out of range.
MMSYSERR_NODRIVER No device driver is present.
MMSYSERR_NOMEM Unable to allocate or lock memory.
WAVERR_BADFORMAT Attempted to open with an unsupported waveform-audio format.
WAVERR_SYNC The device is synchronous but waveOutOpen was called without using the WAVE_ALLOWSYNC flag.

Remarks
Use the waveOutGetNumDevs function to determine the number of waveform-audio output devices present in the system. If the value specified by the uDeviceID parameter is a device identifier, it can vary from zero to one less than the number of devices present. The WAVE_MAPPER constant can also be used as a device identifier.
The structure pointed to by pwfx can be extended to include type-specific information for certain data formats. For example, for PCM data, an extra UINT is added to specify the number of bits per sample. Use the PCMWAVEFORMAT structure in this case. For all other waveform-audio formats, use the WAVEFORMATEX structure to specify the length of the additional data.
If you choose to have a window or thread receive callback information, the following messages are sent to the window procedure function to indicate the progress of waveform-audio output: MM_WOM_OPEN, MM_WOM_CLOSE, and MM_WOM_DONE.
If you choose to have a function receive callback information, the following messages are sent to the function to indicate the progress of waveform-audio output: WOM_OPEN, WOM_CLOSE, and WOM_DONE.
Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Mmsystem.h; include Windows.h.

oyljerry 2005-01-18
  • 打赏
  • 举报
回复
先枚举一下设备
FJGoodGood 2005-01-18
  • 打赏
  • 举报
回复
可以做到的,

首先,用 waveOutGetNumDevs 来获取本机有几个波表输出设备,假设有N个;
然后,用 0 ~ N-1 作为 deviceID 参数,调用 waveOutOpen,然后就是播放,具体查 MSDN 吧。

MMRESULT waveOutOpen(
LPHWAVEOUT phwo,
UINT_PTR uDeviceID,
LPWAVEFORMATEX pwfx,
DWORD_PTR dwCallback,
DWORD_PTR dwCallbackInstance,
DWORD fdwOpen
);
mwp 2005-01-18
  • 打赏
  • 举报
回复
关注
真相重于对错 2005-01-05
  • 打赏
  • 举报
回复
一块声卡就可以,我现在一边听flash 老鼠爱大米 ,一边放mp3
somedummy 2005-01-05
  • 打赏
  • 举报
回复
好像不太可能吧?否则音频属性里面也不要设置首选播放设备了

这个就算可以事先也只能靠底层的调用了
张海霖 2005-01-04
  • 打赏
  • 举报
回复
帮顶

7,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧