From: ScottMcP [MVP] on 19 Dec 2009 19:46 On Dec 19, 6:40 pm, "Larry" <dontmewit...(a)got.it> wrote: > Ok! So, if I wanted to go for the CALBACK_WINDOW, should I just set up a > regular callback like the following? > > LRESULT CALLBACK MyWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM > lParam); > > thanks No, you would have to creaate a window, and a message pump. This would change the basic structure of your program, from a console program (procedural code) to a windowed program (event-driven code). So only use CALLBACK_WINDOW if and when you are creating a program that has windows.
From: Larry on 19 Dec 2009 20:04 "ScottMcP [MVP]" <scottmcp(a)mvps.org> ha scritto nel messaggio news:76ea11dd-f08b-4fd6-ab3d-5d991c06d4c8(a)x18g2000vbd.googlegroups.com... > No, you would have to creaate a window, and a message pump. This > would change the basic structure of your program, from a console > program (procedural code) to a windowed program (event-driven code). > So only use CALLBACK_WINDOW if and when you are creating a program > that has windows. Ok. I coded the callback function like the following: void CALLBACK waveInProc(HWAVEIN hwi,UINT uMsg,DWORD dwInstance,DWORD dwParam1,DWORD dwParam2) { WAVEHDR* pWaveHdr; switch(uMsg) { case MM_WIM_DATA: pWaveHdr = ((WAVEHDR*)dwParam1 ); std::cout << "MM_WIN_DATA" << std::endl; std::cout << "dwFlags: " << pWaveHdr->dwFlags << std::endl; std::cout << "dwBytesRecorded: " << pWaveHdr->dwBytesRecorded << std::endl; std::cout << "lpData: " << &pWaveHdr->lpData << std::endl; break; case MM_WIM_OPEN: std::cout << "MM_WIN_OPEN" << std::endl; break; case MM_WIM_CLOSE: std::cout << "MM_WIN_CLOSE" << std::endl; break; } } I am getting it working great. yet, I wonder how I can access the actual buffer data! I'd like to save it on a binary file (yep, just 4096 bytes)
From: ScottMcP [MVP] on 19 Dec 2009 22:52 On Dec 19, 8:04 pm, "Larry" <dontmewit...(a)got.it> wrote: > > I am getting it working great. yet, I wonder how I can access the actual > buffer data! I'd like to save it on a binary file (yep, just 4096 bytes) The actual buffer data is in the buffer that you allocated! Not sure what you don't understand about that. You put its address in: pWaveHdr->lpData and wavein writes it to that address. But now you have a problem I warned you about. You're not allowed to write a file from the callback function. That's why CALLBACK_EVENT is a better choice in a console app.
From: Larry on 20 Dec 2009 05:00 "ScottMcP [MVP]" <scottmcp(a)mvps.org> ha scritto nel messaggio news:9897526f-2ea6-474d-b618-2226a9baf71d(a)t12g2000vbk.googlegroups.com... > But now you have a problem I warned you about. You're not allowed to > write a file from the callback function. That's why CALLBACK_EVENT is > a better choice in a console app. So, from the callback function I cannot call one more function dedicated to saving files by passing the lpdata as a pointer? Ok, I moving to CALLBACK_EVENT
From: ScottMcP [MVP] on 23 Dec 2009 10:23 On Dec 23, 6:58 am, "Larry" <dontmewit...(a)got.it> wrote: > It sound as the only solutionj to go for! great! Yet, I do not seem to get > it working correctly...I tried adding the waveInAddBuffer in different > position inside the WIN_DATA scope: What incorrect result do you get? If you are going to reuse the buffer do not call waveInUnprepareHeader and do not delete the buffer! As I pointed out earlier, the documentation says you are not allowed to call the wave functions from inside the waveInProc. That may be part of your problem. (Or it may not. I have heard that it works on some versions of Windows and fails on other versions.)
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: using lame encoder Next: InternetOpenUrl and retrieving protocol FTP data-size |