程序实现方法: 线城函数()
{
unsigned char* pa = new unsigned char[length]; pa = GetData(); dsound->filldata(); while (1)
{
if (dsound->isplay())
continus; dsound->play();
pa = GetData(); dsound->filldata();
}
}问题: 我每次得到1秒钟的数据,为什么声音会出现“扑哧”的噪音或停顿。
{
unsigned char* pa = new unsigned char[length]; pa = GetData(); dsound->filldata(); while (1)
{
if (dsound->isplay())
continus; dsound->play();
pa = GetData(); dsound->filldata();
}
}问题: 我每次得到1秒钟的数据,为什么声音会出现“扑哧”的噪音或停顿。
解决方案 »
- 右键动态创建菜单,消息响应函数中如何对菜单进行设置?
- xp下的资源管理器界面上的前进后退等图标保持在系统哪里?shell32.dll里没有。
- 如何讲unsinged char* 转 unsigned char[],在线等!
- 如何设置CListCtrl中的某一行的字体颜色为红色?
- 华为面试题
- 服务里面读注册表失败,不明??求救,以下是安装服务代码,望高手指点
- 大家来看看呀!!!!!!高分小问题
- CComVariant 如何转换到 BYTE * 呀?(已经没分了,大家心心好吧!)
- 有关进程调度的压力测试
- 类中的static const类型变量,在cout中 值被改变,求指教?
- 日期的格式?
- 一个有关dll的问题
Ex:
m_pIDirectSoundBuffer->QueryInterface(IID_IDirectSoundNotify,(LPVOID*)&m_pIDirectSoundNotify);
m_pIDirectSoundNotify->SetNotificationPositions(2,m_DSBPOSITIONNOTIFY);
播放时把buffer一段一段的填充到播放的buffer
在SDK查SetNotificationPositions在关联的function可以找到更多的smaple
{
if (dsound->isplay())//你在PLAY完了一段数据之后才写新数据
continus; dsound->play();
pa = GetData(); dsound->filldata();
}
你在PLAY完了一段数据之后才写新数据,当然会有停顿. 你PLAY的时候指定为循环播放(此时PLAY只需要执行一次).播放时DIRECT SOUND BUFFER有2个指针,一个指向当前播放的地方, 一个指向当前填写新数据的地方.你往第二个指针指向的地方写数据就可以了.void CEIENDSBuffer::Play()
{
DWORD dwStatus;
if( m_lpDSBuffer )
if (DS_OK == m_lpDSBuffer->GetStatus(&dwStatus))
if((dwStatus & DSBSTATUS_PLAYING) != DSBSTATUS_PLAYING)
m_lpDSBuffer->Play(0, 0, DSBPLAY_LOOPING); //循环播放
}
void CEIENDSBuffer::WriteData( UINT length, unsigned char* pData )
{
DWORD CurrentWriteCursor;
DWORD dwAudioBytes1;
DWORD dwAudioBytes2;
LPVOID pvAudioPtr1;
LPVOID pvAudioPtr2;
HRESULT mmr;
mmr = m_lpDSBuffer->GetCurrentPosition( NULL,
&CurrentWriteCursor );
if( mmr == DS_OK )
{//锁定内存,具体见DIRCT X SDK HELP
mmr = m_lpDSBuffer->Lock( CurrentWriteCursor, length,
&pvAudioPtr1, &dwAudioBytes1, &pvAudioPtr2,
&dwAudioBytes2, 0 );
if(mmr == DS_OK)
{
if( pvAudioPtr1 )
memcpy( pvAudioPtr1, pData, dwAudioBytes1 );
if( pvAudioPtr2 )
memcpy( pvAudioPtr2, pData + dwAudioBytes1, dwAudioBytes2 );
m_lpDSBuffer->Unlock( pvAudioPtr1, dwAudioBytes1,
pvAudioPtr2,dwAudioBytes2 );
}
}
}