使用DirectSound播放声音,改变Volume和Frequency没任何效果!

ZM 2011-04-15 04:15:23
CreateSoundBuffer的地方:
	DSBUFFERDESC dsbdesc;

// Set up DSBUFFERDESC structure.
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); // Zero it out.
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
// Need controls (pan, volume, frequency).
dsbdesc.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY; // assumes that the sound is played often
dsbdesc.dwBufferBytes = pcmwf->nSamplesPerSec * pcmwf->nBlockAlign;;
dsbdesc.lpwfxFormat = pcmwf; // Create buffer.
HRESULT hRes;
if( DS_OK != (hRes = m_lpDirectSound->CreateSoundBuffer(&dsbdesc, &m_pDsb, 0)) ) {
// Failed.
DSError(hRes);
m_pDsb = 0;
return FALSE;
}



改变Volume和Frequency的地方:
	m_pDsb->SetVolume(&dwVol);

m_pDsb->SetFrequency(dwFreq);


大家帮帮忙,先谢了!
...全文
127 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ZM 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 lostying 的回复:]

要设置成DSSCL_PRIORITY或者以上级别才行.
[/Quote]
恩,现在已经工作正常了,谢了!
无言猪 2011-04-15
  • 打赏
  • 举报
回复
要设置成DSSCL_PRIORITY或者以上级别才行.
ZM 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lostying 的回复:]

SetCooperativeLevel设置的是什么级别? DSSCL_PRIORITY?
[/Quote]
m_lpDirectSound->SetCooperativeLevel(pWnd->GetSafeHwnd(), DSSCL_NORMAL);
设置成normal的,这个要怎么设置?
无言猪 2011-04-15
  • 打赏
  • 举报
回复
SetCooperativeLevel设置的是什么级别? DSSCL_PRIORITY?

19,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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