|
A good technique to learn early in one's career in programming is this: when you have a problem where you don't have any idea where the problem lies, comment out sections, placing hard coded (good) values where necessary and see if the unexplained problem goes away. This is a good place to start when you don't know where else to start.
|
|
|
|
|
Hello,
i would encode a wavebuffer to the ogg speex.
My actually code is like this:
HWAVEIN hWaveIn;
WAVEHDR WaveHdrIn[AUDIOBUFS];
BYTE BufferIn[AUDIOBUFS][BUFSIZE];
DWORD WINAPI WaveInThread (void *Arg)
{
MSG Msg;
int rv;
rv = SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL);
winexit_if(0 == rv, hWindow, "SetThreadPriority failed");
while (GetMessage (&Msg, NULL, 0, 0) == TRUE) {
if (MM_WIM_DATA == Msg.message) {
int rv = 0;
WAVEHDR *Hdr = (WAVEHDR *) Msg.lParam;
EnterCriticalSection(&remotefd_sem);
if (remotefd != INVALID_SOCKET) {
rv = sendto(remotefd, Hdr->lpData, sizeof(BufferIn[0]), 0,
(struct sockaddr *) &remote, sizeof(remote));
if (rv < 0) {
closesocket(remotefd);
remotefd = INVALID_SOCKET;
}
}
LeaveCriticalSection(&remotefd_sem);
waveInAddBuffer(hWaveIn, Hdr, sizeof(*Hdr));
if (rv < 0) MessageBox(hWindow, "sendto failed", "WARNING", MB_OK);
}
}
return 0;
}
BOOL CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG: {
WSADATA wsaData;
int rv;
int i;
WAVEFORMATEX waveform;
HANDLE WaveInThreadHandle;
DWORD WaveInThreadId;
hWindow = hWnd;
rv = WSAStartup(MAKEWORD(2, 2), &wsaData);
winexit_if(rv != 0, hWnd, "WSAStartup failed");
waveform.nChannels = AUDIOCHANNELS;
waveform.wBitsPerSample = 8;
waveform.nAvgBytesPerSec = AUDIOSPEED * waveform.nChannels * waveform.wBitsPerSample / 8;
waveform.wFormatTag = AUDIOFORMAT;
waveform.nSamplesPerSec = AUDIOSPEED;
waveform.nBlockAlign = 1;
waveform.cbSize = 0;
WaveInThreadHandle = CreateThread(NULL, 0, WaveInThread, NULL, 0, &WaveInThreadId);
winexit_if(NULL == WaveInThreadHandle, hWnd, "CreateThread failed");
rv = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveform, (DWORD)WaveInThreadId,0,CALLBACK_THREAD);
winexit_if(rv != MMSYSERR_NOERROR, hWnd, "waveInOpen failed f");
for (i = 0; i < AUDIOBUFS; ++i) {
WaveHdrIn[i].lpData = BufferIn[i];
WaveHdrIn[i].dwBufferLength = sizeof(BufferIn[0]);
WaveHdrIn[i].dwBytesRecorded = 0;
WaveHdrIn[i].dwUser = 0;
WaveHdrIn[i].dwFlags = 0;
WaveHdrIn[i].dwLoops = 0;
WaveHdrIn[i].lpNext = NULL;
WaveHdrIn[i].reserved = 0;
waveInPrepareHeader(hWaveIn, WaveHdrIn + i, sizeof(WaveHdrIn[0]));
waveInAddBuffer(hWaveIn, WaveHdrIn + i, sizeof(WaveHdrIn[0]));
}
waveInStart(hWaveIn);
break;
}
How can i encode the firstly wave?
I would handle with the microphon stream as wave. Only one step befor i send it with a socket i would encode it to ogg.
I finde the Page of the Ogg speex Project, but i cant understand the message behind the libary and the project has not a board for questions.
http://www.speex.org/docs/api/speex-api-reference.pdf
PS. Sorry for my bad english.
modified on Monday, February 2, 2009 12:04 PM
|
|
|
|
|
Hello,
I was searching some articles about serial port communication in c++ and ran into this:
http://msdn.microsoft.com/en-us/library/ms810467.aspx[^].
This also includes a sample application, named MTTY.
From the abstract.txt of the application:
MTTTY was built and tested under Microsoft Windows(TM)
95 and Microsoft Windows NT 3.51 using Microsoft
Visual C/C++ version 2.0 and the combined Win32 SDK
for Windows 95 and Windows NT.
Finally, my question to you is how to create/convert the MTTY project into a vs 2005/2008 project(I reckon that simply adding the headers,resources and sources won't do the job). And I also wanted to know if this application will run properly on Windows Xp(although it belongs to windows nt family, the code dates back to '95). Sorry for the dumb questions, just beginning to read about this. Thank you!
|
|
|
|
|
I don't see any problems with the code at a quick glance - it all looks like classic Win32 stuff. If it worked on NT3.51, it should be fine and dandy under XP.
I'd create a Hello World windows (no MFC) project, and just start chucking the code in there.
Alternatively, read the excellent serial primer by Flounder, and make your own code using that as a serial core.
http://www.flounder.com/serial.htm[^]
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi All,
When I clickoon system tray icon first time menu works fine , but second time I am getting error like this ;
"Debug assertion failed!
Program: ...
File: F:\rtm\vctools\vc7libs\ship\atlmfc\winmenu.cpp
line 84
retry abort "
code is goes like:
LRESULT CDialogOnTopDlg::onTrayNotify(WPARAM wParam,LPARAM lParam)
{
UINT uMsg = (UINT) lParam;
switch (uMsg )
{
case WM_RBUTTONDOWN:
m_TrayMenu.LoadMenu(IDR_MENU1); // second time crashing here
CPoint pt;
GetCursorPos(&pt);
m_TrayMenu.GetSubMenu(0)->TrackPopupMenu(0,pt.x,pt.y,this);
break;
}
return TRUE;
}
Plz tell me wot could be possible causes.
|
|
|
|
|
My guess would be that you already have that menu loaded and you try to load it again using the same CMenu, either load it once or delete/destroy it before you try to load it again.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
yes you r correct, actully i am using same menu for right click on tray icon and right click on dialog box (anywhere on dialog box),
so plz tell me hadnle same menu for these two things? how to destroy/delete after work os done?
|
|
|
|
|
Well, i think you can do generally 2 things:
1. Load your menu only once and keep it around until your program exits (for example you can load it in the OnInitDialog of your dialog)
2. Load, use and destroy it "on sight", for example, you can use TrackPopupMenuEx[^] with TPM_RETURNCMD, if you do this, when the TrackPopupMenuEx call finishes you will get the command back from the call telling you what the user clicked on (or 0 if he dismissed the menu) and then you can use DestroyMenu[^] to destroy it. Of course doing so you will no longer need your CMenu to hang around so you can make it a local variable and then it will destroy the menu in its destructor when your method exits.
Judging by what i have seen of your code i guess for you the first aproach could be better.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I'm certain code-o-mat is correct in his answer to you.
But you really should have used the debugger to see the actual ASSERT line - that will give you lots of information you need to fix your own problem. I/we don;t mind helping - but you are much better learning debugging skills to find the issue out your self.
I bet the ASSERT line was something like:
BOOL CMenu::LoadMenu (UINT nBlah)
{
ASSERT (m_hMenu == NULL);
which would have told you what your problem was.
And that's more than half the battle of solving the problem.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
crazy_sam wrote: m_TrayMenu.LoadMenu(IDR_MENU1); // second time crashing here
Make m_TrayMenu local to the OnTrayNotify() method.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I am using MFC picture control for displaying bmps on property dialog boxes. So I added picture contrl from the tools and changed the type to bitmap. Then selected a bmp resource to be loaded into the control. At design time the bmp is visible but at run time its not. I have done this before but the project used a MBCS. Now its Unicode.
Does that matter? If not what might be the problem?
TIA
|
|
|
|
|
Can you show your code ?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
There is no code actually. Its all done in design time.
|
|
|
|
|
Did you change from MBCS to Unicode in the same project? If yes, try cleaning and rebuilding the whole project if you did not try it yet.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thats the thing Im doing now.. I'll let you know..
|
|
|
|
|
But I added a new dialog, placed a picture control on it and loaded a bmp. It works fine in unicode also. I think it should not be specific to property sheets.
what do you say ?
|
|
|
|
|
Hi,
Cant you help me?
what is the command for c++ if i want to read the line but with the condition.
if LINE contains "my" copy the whole LINE.
example:
myData.txt
1. Hello my dear!
2. Good day!
when i access the myData.txt the first line is "Hello my dear!"
i want to copy the line if contains "my" .
thanks
|
|
|
|
|
Common sense says:
- Read a line (exit on 'no-more-lines' condition).
- Search for
"my" inside the read string. - Copy the line if the search of point (2) was succesful.
- Goto point (1).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thanks but my question is "What is the command?"
|
|
|
|
|
If you're using MFC , the CString::Find method [^] is the proper 'command'.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i will try this..
thanks...
|
|
|
|
|
Hey, nice algo. I doubt he could convert it into proper code. But he should !
|
|
|
|
|
can you help me?
its like in visual basic, but im beginner in c++.
InStr(1, line, "string", vbTextCompare)
thanks
|
|
|
|
|
Along with the link given by CPallini, you can have a look at this[^] for reference if you aren't using MFC.
|
|
|
|
|
mac_g wrote: what is the command...
There is no single command to do this. It will all depend on what type of variable you are reading the line of text into (e.g, CString , string , char ).
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|