CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2004
    Posts
    232

    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!

  2. #2
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    2,147
    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

  3. #3
    Join Date
    Feb 2004
    Posts
    232
    Quote 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!

  4. #4
    Join Date
    Jul 2004
    Posts
    9
    pFormat.nBlockAlign = pFormat.nChannels * pFormat.wBitsPerSample / 8;
    pFormat.wBitsPerSample = 8;

    Shouldn't those two lines be the other way round?

  5. #5
    Join Date
    Feb 2004
    Posts
    232
    Quote 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!

  6. #6
    Join Date
    Feb 2004
    Posts
    232
    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!

  7. #7
    Join Date
    Feb 2004
    Posts
    232
    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!

  8. #8
    Join Date
    Feb 2004
    Posts
    232
    *bumpbumpbump*
    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
  •  





Click Here to Expand Forum to Full Width

Featured