|
You'll need to capture data from the microphone device and examine the audio samples and decide
if it's receiving input (maybe based on a threshold or some other way).
To get the audio samples, there's a variety of methods. Two common ways are
1) Windows Multimedia: Recording Waveform Audio[^]
2) DirectSound[^]
If those are confusing then you'll probably need to choose a method and study!
If you have more specific questions about parts you don't understand, there's lots of people here
that can help.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks Mark. I somehow completely missed the DirectSound section of MSDN. I will check that out.
|
|
|
|
|
I'm develop some ActiveX that act like tree but also have header.
My ActiveX base class is SysListView32.
I don't understand how can i get access to the listView control ?
In this function i load the SysListView32
BOOL CTreeListViewCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
cs.lpszClass = _T("SysListView32");
return COleControl::PreCreateWindow(cs);
}
I must draw the control that i writing by myself ? can i use the control draw that i already have in the SysListView32 ?
I try to use some MFC class that the base class of it is CListCtrl - i check this MFC class and all work fine. Can i marge between those 2 project ( the MFC and my new ActiveX control ) ?
Thanks for any help.
|
|
|
|
|
Hi all:
Here is my question.
struct _wordTable {
char *word;
int count;
};
/*I need to dynamically allocate memory for every _wordTable structure.*/
/*What I have done is:*/
struct _wordTable *word_ptr = NULL;
word_ptr = malloc(sizeof(struct _wordTable));
if (word_ptr != NULL) {
word_ptr->word = malloc(wordSize * sizeof(char) + 1); /* wordSize if the length of the char string pointed by *word.*/
}
/*Is my coding OK? Since it worries me that I allocated memory for the struct first, followed by allocation of its string.*/
Thanks
|
|
|
|
|
It will not create any problem, since U R allocating 2 bytes of memory for the pointer "word" in the structure.
sizeof(struct _wordTable) -> This will always evaluates to 4 bytes
irrespective of the size of the string that "word" is pointing to.
Regards,
Arun Kumar.A
|
|
|
|
|
Hi:
Thank you. I was confused here for a second.
Thank you a lot, Arun.
|
|
|
|
|
Arun.Immanuel wrote: This will always evaluates to 4 bytes
Actually it will be 8 bytes when 32 bit addressing is used:
a pointer is usually stored as 4 bytes and the int is also 4 bytes.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
That will work.
Here is a better design that MS used for years.
typedef struct _wordTable {
int count;
char word[1];
} WORDTABLE;
WORDTABLE *word_ptr = malloc(sizeof(WORDTABLE) + wordSize);
if( word_ptr )
word_ptr->count = wordSize;
With this method you allocate both at the same time and do not have to add 1, because the extra byte it is part of the structure.
Note: You do not need to multiply by sizeof(char) on most compilers, because it is equal to 1.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
while (!bEnd)<br />
{<br />
Sleep(0);<br />
}
and
HANDLE hEventEnd = CreateEvent(...);<br />
WaitForSingleObject(hEventEnd...);
----------------------------------------------
which better?
|
|
|
|
|
HOW WHAT wrote: hile (!bEnd)
{
Sleep(0);
}
is obviously a disaster.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Sleep(0) plainly does nothing, and so you're going to start another thread, but at the same time, have your main thread check a bool over and over again, as fast as it can ?
The mechanisms like WaitForSingleEvent exist precisely to stop people doing stuff like a hard loop to check a bool.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
e...But i see WaitForSingleObject sources also use do {}while(...), Sleep and WaitForSingleObject sources as much as same....
|
|
|
|
|
CPU resources... a while the is always looping takes al the computer resources in order to be done as fast as possible, in the other way is like a callback, the OS handles it...
|
|
|
|
|
|
I've given my five to Mr. Graus...
|
|
|
|
|
I have two functions:
getBuffer();
setBuffer();
Assuming the client calls setBuffer() and passes a pointer to a memory block where data is stored, would it be bad practice to have my object modify that block directly, possibly resizing the block itself?
Doing this seems bad practice, as it would indirectly make getBuffer() pointless, but resizing the memory block would screw everything up wouldn't it? Or does the fact the buffer is completed by a NULL byte allow for such scenarios?
Hopefully my question has made sense?
Cheers
I'm finding the only constant in software development is change it self.
|
|
|
|
|
Hockey wrote: would it be bad practice to have my object modify that block directly, possibly resizing the block itself ... but resizing the memory block would screw everything up wouldn't it
Modify how ?
Resizing would be bad as you probably haven't specified what heap the block is from.
Even if you are using alloc/free new/delete everywhere there may be issues (if multiple modules have statically linked to CRT).
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Interesting! Yes it would be bad practice to have the object modify the size of a buffer it knows nothing about, but it would also be bad practice not to have the object do its own buffer allocations and releases.
Example: char buffer[128]; setBuffer(buffer, cbSize);
As you can see, I just misused your function.
Unless you have a very good reason not to, then you should use the C++ vector class for your buffers. If your object needs a buffer it should allocate it internally and have control over its life time.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Has anyone out there ever successfully done automatic proxy detection?
To be specific -- there's 2 types. There's configuration from IE's static settings.
But IE also supports a automatic proxy detection javascript -- FindProxyForUrl?
I am having a heck of a time finding a method that works.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
How can I set the uniform axis property of mschart in VC++2005?
in VB we can use .plot.UniformAxis=FALSE
But how can we do that in VC?
thanks!
|
|
|
|
|
is there anybody who knows that?
|
|
|
|
|
chart.GetPlot().SetUniformAxis()?
|
|
|
|
|
|
What do you mean?
|
|
|
|