扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:智慧的鱼 来源:天极网 2007年10月19日
关键字:
if( FAILED( hr = CoInitialize(NULL) ) ) return hr; if(pDeviceGuid) { if(FAILED( hr = DirectSoundCaptureCreate(pDeviceGuid,&g_pDSCapture,NULL))) return hr; } else { if(FAILED(hr= DirectSoundCaptureCreate(&DSDEVID_DefaultCapture ,&g_pDSCapture,NULL))) return hr } |
HRESULT CreateCaptureBuffer(LPDIRECTSOUNDCAPTURE8 pDSC, LPDIRECTSOUNDCAPTUREBUFFER8* ppDSCB8) { HRESULT hr; DSCBUFFERDESC dscbd; LPDIRECTSOUNDCAPTUREBUFFER pDSCB; WAVEFORMATEX wfx ={WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0}; // wFormatTag, nChannels, nSamplesPerSec, mAvgBytesPerSec, // nBlockAlign, wBitsPerSample, cbSize if ((NULL == pDSC) || (NULL == ppDSCB8)) return E_INVALIDARG; dscbd.dwSize = sizeof(DSCBUFFERDESC); dscbd.dwFlags = 0; dscbd.dwBufferBytes = wfx.nAvgBytesPerSec; dscbd.dwReserved = 0; dscbd.lpwfxFormat = &wfx; //设置录音用的wave格式 dscbd.dwFXCount = 0; dscbd.lpDSCFXDesc = NULL; if (SUCCEEDED(hr = pDSC->CreateCaptureBuffer(&dscbd, &pDSCB, NULL))) { hr = pDSCB->QueryInterface(IID_IDirectSoundCaptureBuffer8, (LPVOID*)ppDSCB8); pDSCB->Release(); } return hr; } |
HRESULT InitNotifications() { HRESULT hr ; g_hNotificationEvent = CreateEvent(NULL,FALSE,FALSE,NULL); //创建事件 if(g_pDSBCapture == NULL) return E_FAIL; if(FAILED(hr = g_pDSBCapture ->QueryInterface(IID_IDirectSoundNotify,(VOID**)&g_pDSNotify))) return hr; for( INT i = 0; i < NUM_REC_NOTIFICATIONS; i++ ) { g_aPosNotify[i].dwOffset = (g_dwNotifySize * i) + g_dwNotifySize - 1; g_aPosNotify[i].hEventNotify = g_hNotificationEvent; } if(FAILED( hr =g_pDSNotify->SetNotificationPositions( NUM_REC_NOTIFICATIONS, g_aPosNotify ) ) ) return hr; return S_OK; } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者