-
July 20th, 2004, 07:36 PM
#1
Cannot Connect to Capture Window
I'm using a capture window to take input from the microphone, but there's a bit stagg here. I see absolutly no reason why this call would fail:
Code:
void initCap()
{
capWnd = capCreateCaptureWindow("Voiceieve-cap",0,0,0,0,0,hWnd,(int)0);
capSetCallbackOnWaveStream(capWnd,waveCallback);
// Phone quality.
WAVEFORMATEX pFormat;
memset(&pFormat,0,sizeof(pFormat));
pFormat.wFormatTag = WAVE_FORMAT_PCM;
pFormat.nChannels = 1;
pFormat.nSamplesPerSec = 22050;
pFormat.nAvgBytesPerSec = pFormat.nSamplesPerSec * pFormat.nChannels * pFormat.wBitsPerSample / 8;
pFormat.nBlockAlign = pFormat.nChannels * pFormat.wBitsPerSample / 8;
pFormat.wBitsPerSample = 8;
pFormat.cbSize = 0;
capSetAudioFormat(capWnd,&pFormat,sizeof(pFormat));
int result = SendMessage(capWnd,WM_CAP_DRIVER_CONNECT,(WPARAM)0,0L);
return;
}
I inserted a breakpoint, and result = 0. The MSDN states it returns 0 if it has failed, and apparently, it is, infact, returning 0. What's wrong here?
Need help with anything related to audio programming? I can help!
-
July 20th, 2004, 08:53 PM
#2
Is capWnd being created correctly?
You may need to specify some creation flags to keep it happy, such as:
WS_CHILD | WS_VISIBLE
As the second parameter for the constructor.
Hope this helps,
- Nigel
-
July 20th, 2004, 09:18 PM
#3
Originally Posted by NigelQ
Is capWnd being created correctly?
You may need to specify some creation flags to keep it happy, such as:
WS_CHILD | WS_VISIBLE
As the second parameter for the constructor.
Hope this helps,
- Nigel
No help, still returning 0, and yes, capWnd is being created like any normal HWND.
Need help with anything related to audio programming? I can help!
-
July 21st, 2004, 04:37 AM
#4
pFormat.nBlockAlign = pFormat.nChannels * pFormat.wBitsPerSample / 8;
pFormat.wBitsPerSample = 8;
Shouldn't those two lines be the other way round?
-
July 21st, 2004, 03:12 PM
#5
Originally Posted by dan.lambert
pFormat.nBlockAlign = pFormat.nChannels * pFormat.wBitsPerSample / 8;
pFormat.wBitsPerSample = 8;
Shouldn't those two lines be the other way round?
Oh geez, I didn't even notice that!
Thanks a bunch man!
Need help with anything related to audio programming? I can help!
-
July 21st, 2004, 03:15 PM
#6
Bleh, there's still a problem. Though I can connect to the capture window, my wave callback isn't being called. What's wrong now?
Need help with anything related to audio programming? I can help!
-
July 21st, 2004, 05:40 PM
#7
There's gotta be something wrong. Maybe something simple; anyone's help is GREATLY appreciated.
Need help with anything related to audio programming? I can help!
-
July 22nd, 2004, 12:05 AM
#8
Need help with anything related to audio programming? I can help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|