Thx for ur reply. I have a button that would let user click to stop recording. That would make isclose = 1; Originally, I use waveInStop but I waveInStop only stop recording. waveInReset would stop recording and set the position to 0. I see some information in the Internet that says use waveInUnPrepareHeader before using waveInReset. Originally, I don't use Sleep() function,but it has same problem. I write it in a new small program as follow. It halts at waveInReset. If I delete waveInReset, waveInUnPrepareHeader and waveInClose falses and returns 33. #include "stdafx.h" #include #include #include #include #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "Winmm.lib") using namespace System; using namespace std; static void CALLBACK WaveInProc(HWAVEIN, UINT, DWORD , DWORD , DWORD ); static const int SNDNBUF = 2; static const int SNDSIZEBUF = 320; HWAVEOUT hWavout; MMRESULT mmrr; WAVEHDR headersend[SNDNBUF]; char hdrDatasend[SNDSIZEBUF*SNDNBUF]; HWAVEIN hWavin; int _tmain(int argc, _TCHAR* argv[]) { WAVEFORMATEX wfx; wfx.nSamplesPerSec = 8000; wfx.nChannels = 1; wfx.wFormatTag = WAVE_FORMAT_PCM; wfx.wBitsPerSample = 16; wfx.nBlockAlign = wfx.nChannels * (wfx.wBitsPerSample / 8); wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; memset(headersend, 0,sizeof(WAVEHDR)*SNDNBUF); for(int i=0;i<sndnbuf;i++){ headersend[i].lpData = hdrDatasend + i*SNDSIZEBUF; headersend[i].dwBufferLength = SNDSIZEBUF;} memset(hdrDatasend,0,SNDSIZEBUF*SNDNBUF); if(waveInOpen(&hWavin,WAVE_MAPPER, &wfx,(DWORD_PTR)WaveInProc ,0, CALLBACK_FUNCTION) == MMSYSERR_NOERROR){ for(int i=0;i{ mmrr = waveInPrepareHeader(hWavin, headersend + i, sizeof(WAVEHDR)); mmrr = waveInAddBuffer(hWavin, headersend + i, sizeof(WAVEHDR));} mmrr = waveInStart(hWavin); } int i; cin >> i; mmrr=waveInStop(hWavin); mmrr=waveInReset(hWavin); Sleep(500); for(int i=0;i<sndnbuf;i++){ if ((headersend+i)->dwFlags & WHDR_PREPARED){ mmrr=waveInUnprepareHeader(hWavin,headersend+i, sizeof(WAVEHDR));} Sleep(500); mmrr=waveInClose(hWavin); cin >> i; return 0; } static void CALLBACK WaveInProc(HWAVEIN hw, UINT uMsg,DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD dwParam2) { WAVEHDR* curhdrin = (WAVEHDR*)dwParam1; if(uMsg != WIM_DATA)return; waveInAddBuffer(hw, curhdrin, sizeof
minihotto
Posts
-
About wavein API -
About wavein APIHello I have a program using waveIn API. This is part of my code. Originally, my program has a deadlock while running waveInReset. I google it and it is said putting the wavein function in the callback function is forbidden. So I delete the code which I put waveinstop in the callback function. It can run waveInReset and waveInunprepareheader successfully. But it halt at waveInClose. I can't find information about waveInClose halt. Can anybody solve this problem?Thx, Jane.
while(1){ if(isopen==1){ if(waveInOpen(&hWavin,WAVE_MAPPER, &wfx,(DWORD_PTR)WaveInProc ,0, CALLBACK_FUNCTION) == MMSYSERR_NOERROR) { isopen=1; for(int i=0;i<4;i++) { mmrr = waveInPrepareHeader(hWavin, headersend + i, sizeof(WAVEHDR)); mmrr = waveInAddBuffer(hWavin, headersend + i, sizeof(WAVEHDR)); } mmrr = waveInStart(hWavin); } } if(isclose==1) { if(hWavin) { mmrr=waveInReset(hWavin); for(int i=0;i<4;i++) { mmrr=waveInUnprepareHeader(hWavin,headersend+i, sizeof(WAVEHDR)); } for(int i=0;i<4;i++) { mmrr=waveInReset(hWavin); } mmrr=waveInClose(hWavin); sclose=0; } } } static void CALLBACK WaveInProc(HWAVEIN hw, UINT uMsg,DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD dwParam2) { WAVEHDR* curhdrin = (WAVEHDR*)dwParam1; if(uMsg != WIM_DATA) return; if(isclose==1){ Sleep(1000); return; } ///other code//// waveInAddBuffer(hw, curhdrin, sizeof(WAVEHDR)); }
-
About exe fileHello, I'm not sure which topic to post this kind of problem. If I ask on the wrong board, please let me know. I write a windows form project with CLR supporting, and I want to package it into an exe file. I run the exe file in the Debug folder. It works on my computer, but not on other's computer which doesn't install .NET. But I want the exe file to be portable and without install. It seems that it needs a .NET environment. I try to install .net framework 2.0 to the computer which doesn't install Microsoft Visual Studio 2005. But I still can't open the exe file, too. Is it possible to create a exe file without install in Microsoft Visual Studio 2005? Thx for ur reply. Jane
-
Using MFC with windows formyes, I only need the message map in MFC. I want to use MFC in windows form application, not use windows form controls in MFC. Appreciate ur reply. Thx. jane -- modified at 0:46 Monday 12th November, 2007
-
Using MFC with windows formI create a windows form application named p2pport. and I want to use the Message Map of MFC. so I use MFC with shared DLL and include afxwin.h. But When I compile it, it says that Debug Assertion Failed File : dbgheap.c line 144 Expression : _CrtIsValidHeapPointer(pUserData) I find it is because of the afxwin.h. I google it and found that it is a bug that was reported to MSDN. http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99715[^][^]I use that method to replace the main function and put #include in stdfax.h file. My original code is
#include "stdafx.h" #include "Dlg.h" using namespace p2pport; [STAThreadAttribute] int main(void)//array ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it Application::Run(gcnew Dlg()); //Application::Run(gcnew Form2()); CMFCApp k; return 0; }
And I modify it.#include "stdafx.h" #include "Dlg.h" using namespace p2pport; [STAThreadAttribute] class CMFCApp : public CWinApp { public: virtual BOOL InitInstance() { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it //Application::Run(gcnew Dlg()); return FALSE; } }theApp;
But it comes the error. error C3115: 'System::STAThreadAttribute': this attribute is not allowed on 'theApp' I delete the[STAThreadAttribute].
It comes another two errors. error LNK2001: unresolved external symbol _main fatal error LNK1120: 1 unresolved externals I dont know how to solve it. I stuck it all day. Can anybody help me to solve the problem. Appreciate for ur reply Thx. Jane -
Using MFC with windows formI create a windows form application named p2pport. and I want to use the Message Map of MFC. so I use MFC with shared DLL and include afxwin.h. But When I compile it, it says that Debug Assertion Failed File : dbgheap.c line 144 Expression : _CrtIsValidHeapPointer(pUserData) I find it is because of the afxwin.h. I google it and found that it is a bug that was reported to MSDN. http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99715[^] I use that method to replace the main function and put #include in stdfax.h file. My original code is
#include "stdafx.h" #include "Dlg.h" using namespace p2pport; [STAThreadAttribute] int main(void)//array ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it Application::Run(gcnew Dlg()); //Application::Run(gcnew Form2()); CMFCApp k; return 0; }
And I modify it.#include "stdafx.h" #include "Dlg.h" using namespace p2pport; [STAThreadAttribute] class CMFCApp : public CWinApp { public: virtual BOOL InitInstance() { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it //Application::Run(gcnew Dlg()); return FALSE; } }theApp;
But it comes the error. error C3115: 'System::STAThreadAttribute': this attribute is not allowed on 'theApp' I delete the[STAThreadAttribute]
. It comes another two errors. error LNK2001: unresolved external symbol _main fatal error LNK1120: 1 unresolved externals I dont know how to solve it. I stuck it all day. Can anybody help me to solve the problem. Appreciate for ur reply Thx. Jane -
Mixed types problemOK. THx.
-
A problemI create a windows form apllication, p2pport. My form file name is Dlg.I get some errors. error C2027: use of undefined type 'p2pport::CParams' error C2227: left of '->setValue' must point to class/struct/union/generic type in Dlg.cpp params->setValue("Y", "123"); in my Dlg.h file #include "params.h"; namespace p2pport { using namespace System; ............................... public ref class Dlg : public System::Windows::Forms::Form { CParams* params; } } in my param.h file class CParams{ void setvalue(char* k, char* v); } in my params.cpp void CParams::setValue(char* k, char* v){ ..... return; } Can anybody tell me what's wrong with it? Appreciate your reply. Jane
-
A problemTHx for reply. Is that means I can't declare it in Dlg.h? I have to put "MyClass* pMC;" to Dlg.cpp? Jane
-
A problemI create a windows form apllication, p2pport. My form file name is Dlg.I get some errors. error C2027: use of undefined type 'p2pport::CParams' error C2227: left of '->setValue' must point to class/struct/union/generic type in Dlg.cpp
params->setValue("Y", "123");
in my Dlg.h file#include "params.h"; namespace p2pport { using namespace System; ............................... public ref class Dlg : public System::Windows::Forms::Form { CParams* params; } }
in my param.h fileclass CParams{ void setvalue(char* k, char* v); }
in my params.cppvoid CParams::setValue(char* k, char* v){ ..... return; }
Can anybody tell me what's wrong with it? Appreciate your reply. Jane -
Message Map Problem [modified]I got it. I lose DECLARE_MESSAGE_MAP()in the header file. The correct code is as below.
#ifndef CMYVIEW_H #define CMYVIEW_H #include <afxwin.h> #include <afxext.h> public class CMyView : public CFormView { public: afx_msg LRESULT OnUI1(WPARAM wParam, LPARAM lParam); LRESULT OnUI2(WPARAM wParam, LPARAM lParam); LRESULT onMixerCallBack(WPARAM wParam, LPARAM lParam); protected: DECLARE_MESSAGE_MAP(); }; #endif
-
Message Map Problem [modified]Thx for your reply. It helps me a lot. But I still get some errors. I create a header file that named CMyView and the content is following.
#ifndef CMYVIEW_H #define CMYVIEW_H #include <afxwin.h> #include <afxext.h> public class CMyView : public CFormView { LRESULT OnUI1(WPARAM wParam, LPARAM lParam); LRESULT OnUI2(WPARAM wParam, LPARAM lParam); LRESULT onMixerCallBack(WPARAM wParam, LPARAM lParam); }; #endif
And my code is modified as below.BEGIN_MESSAGE_MAP(CMyView,CFormView) ON_MESSAGE(WM_UI1, OnUI1) ON_MESSAGE(WM_UI2, OnUI2) ON_MESSAGE(MM_MIXM_LINE_CHANGE,onMixerCallBack) ON_MESSAGE(MM_MIXM_CONTROL_CHANGE,onMixerCallBack) END_MESSAGE_MAP()
And there's the error. error C2509: 'GetMessageMap' : member function not declared in 'CMyView' error C2509: 'GetThisMessageMap' : member function not declared in 'CMyView' How could I solve this problem? Appreciate for ur reply. Thx. -
About global namespace in cwchar.hI see. Thx for ur reply.
-
Mixed types problemI create a "Windows Form Application" projects that names p2pport. Dlg is my form file name. The following two lines are in Dlg.h. struct sockaddr_in addrLoop; CClient *cnList[5]; But it comes some errors. error C4368: cannot define 'addrLoop' as a member of managed 'p2pport::Dlg': mixed types are not supported error C4368: cannot define 'cnList' as a member of managed 'p2pport::Dlg': mixed types are not supported Do anybody know what's wrong? Appreciate your reply. Thx.
-
Message Map Problem [modified]Hello, I create a "Windows Form Application" project that names p2pport, in Microsoft visual .NET 2005. I want to use the Message Map. I see it on MSDN. MFC uses it. So I include the #include , and use MFC in a shared DLL. This is my code. BEGIN_MESSAGE_MAP(p2pport::Dlg,public System::Windows::Forms::Form) ON_MESSAGE(WM_UI1, p2pport::Dlg::OnUI1, WPARAM wParam, LPARAM lParam) ON_MESSAGE(WM_UI2, p2pport::Dlg::OnUI2, WPARAM wParam, LPARAM lParam) ON_MESSAGE(MM_MIXM_LINE_CHANGE,p2pport::Dlg::onMixerCallBack) ON_MESSAGE(MM_MIXM_CONTROL_CHANGE,p2pport::Dlg::onMixerCallBack) END_MESSAGE_MAP() p2pport is my project name, and Dlg is the name of my form file. But I get a lots of errors. error C2039: 'GetMessageMap' : is not a member of 'p2pport::Dlg' error C2039: 'GetThisMessageMap' : is not a member of 'p2pport::Dlg' error C2039: 'GetThisMessageMap' : is not a member of 'System::Int32' error C2270: 'GetMessageMap' : modifiers not allowed on nonmember functions error C2365: 'GetThisMessageMap' : redefinition; previous definition was 'formerly unknown identifier' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C3861: 'GetThisMessageMap': identifier not found error C4430: missing type specifier - int assumed. Note: C++ does not support default-int I google it, but nothing finds. Can anybody help me to solve it? Appreciate for ur reply. Thx. -- modified at 5:03 Tuesday 6th November, 2007
-
About global namespace in cwchar.hThere are some errors. error C2039: 'btowc' : is not a member of '`global namespace'' in cwchar.h I see some information about gloabal namespace, but i dont understand why it comes some errors. Is it because cwchar.h file is obsolete? If it is, what can I do if I need to use the file? Can somebody help me to solve the problem? Thx for ur reply. Jane.
-
about CLRI want to compile a program.I compile the files with /TP. I originally use /CLR option, but it says that a .c file cant work with /clr. I see the page. http://msdn2.microsoft.com/en-us/library/ms173265(VS.80).aspx so, I change it to no /CLR. Then it comes out other problems. 1. syntax error '__value' 2. error C4980: '__value' : use of this keyword requires /clr:oldSyntax command line option But I change it to /clr:oldSyntax, I comes the error that error D8045 : cannot compile C file '.\gsm\RPE.C' with the /clr option again. How can I debug this error? Appreciate for ur reply. Jane -- modified at 3:01 Monday 29th October, 2007
-
About waveinopenpublic ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: Add the constructor code here // } int call_id; void CALLBACK WaveInCallback(HWAVEIN hw, UINT uMsg,DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD dwParam2) { WAVEHDR* curhdr = (WAVEHDR*)dwParam1; waveInAddBuffer(hw, curhdr, sizeof(WAVEHDR)); } ............ I put in the class form1
-
About waveinopenIt comes other errors.@@ 1.error C3374: can't take address of 'p2p::Form1::WaveInCallback' unless creating delegate instance 2.error C2440: 'type cast' : cannot convert from 'void (__clrcall p2p::Form1::* )(HWAVEIN,UINT,DWORD_PTR,DWORD_PTR,DWORD)' to 'DWORD_PTR'
-
About waveinopenAppreciate for ur reply. But it's still same.