|
Mark, I need to rephrase my comments.
I am questioning the process after the callback function is being executed as a result of the buffer / header being full.
In one of the codes I have been learning from I found the following snippet
case WIM_DATA:
{
TRACE("%d",pHdr->dwUser);
if(WHDR_DONE==(WHDR_DONE &pHdr->dwFlags))
{
mmioWrite(m_hOPFile,pHdr->lpData,pHdr->dwBytesRecorded);
mRes=waveInAddBuffer(m_hWaveIn,pHdr,sizeof(WAVEHDR));
if(mRes!=0)
StoreError(mRes,TRUE,"File: %s ,Line Number:%d",__FILE__,__LINE__);
}
…
I feel since the callback receives WIM_DATA message cheking for header WHDR_DONE is redundant.
However, I do question how dwByteRecored can be 0 if the buffer was being full.
Obviously it is not full.
So how did the callback got to be executed with no data recorded?
Vaclav
.
|
|
|
|
|
Vaclav_Sal wrote: if(WHDR_DONE==(WHDR_DONE &pHdr->dwFlags))
That looks wrong to me unless there's only one buffer and the entire recording is done in that one buffer. But then it doesn't make sense because it calls waveInAddBuffer()...
I think it should be
if(WHDR_DONE != (WHDR_DONE &pHdr->dwFlags))
Vaclav_Sal wrote: I feel since the callback receives WIM_DATA message cheking for header WHDR_DONE is redundant.
If you look at the WIM_DATA documentation it states "The message can be sent when the buffer is full or after the waveInReset function is called. ". So when waveInReset is called the buffer will probably be empty and the WHDR_DONE flag will be set. That's what your check above is failing on....try switching it to !=
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your help Mark
I finally managed to start, record and stop an audio file.
When I step thru the process first two "buffers" have no data recorded.
As you suggested , I just return the empty buffer back into the queue.
As far as I can tell there is nothing missing in the file and no waveInReset was performed.
But is is really noisy – background noise. I'll play with it to see how to improve the noise.
Vaclav
|
|
|
|
|
I have a varibale of 8 bytes (ULONGLONG). How to extract first 6 bytes from that?
|
|
|
|
|
Bit Masking[^]
"Real men drive manual transmission" - Rajesh.
modified on Tuesday, July 5, 2011 9:43 AM
|
|
|
|
|
Bitwise?
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]
|
|
|
|
|
Brain fart.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
{OT} where is your MVP tag??
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
The MVP tag? That, I lost in the forest.
Actually, I didn't win it this year.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
#include <windows.h>
#include <iostream>
using namespace std;
union MyUnion
{
ULONGLONG ull;
BYTE b[8];
};
int main()
{
ULONGLONG v = 0x0123456789ABCDEF;
MyUnion mu;
mu.ull = v;
for (int i=0; i<6; i++)
{
cout << hex << (INT) mu.b[i] << endl;
}
}
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]
|
|
|
|
|
Hi all,
char possibles[37] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
i am renerating random string with help of rand function.
how can i calculate the maximum combination for generate random string of given length?
like if i give length = 4?
so how cany maximum string generated of length 4 from given cahr array?
please help me for this.
thanks in advance.
|
|
|
|
|
It's known as Permutation[^], and there's formulae on that page that answers your question.
By the way, this is not even a programming question, and has nothing to do with C++ or MFC.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
If order is important you have to use "Permutation". Otherwise you have to use "Combination". You have to select 4 characters out of the 36 characters. 36c4 is what you need. 36!/32!*4! is the way to calculate if my memory is good.
|
|
|
|
|
Depends on whether or not a character may be repeated in a string.
If so, it's very,very,very easy:
# combinations = pow(numCharsToChooseFrom, lengthOfGeneratedString)
4 char string - 37^4 = 1,874,161
5 char string - 37^5 = 69,343,957
If a character may not be repeated, it is a little more involved.
# combinations = (numCharsToChooseFrom!) / ((numCharsToChooseFrom-lengthOfGeneratedString)!)
4 character string - 37 * 36 * 35 * 34 = 1,585,080
5 char string - 37 * 36 * 35 * 34 * 33 = 52,307,640
or to put it more simply
4 character string - (37! / 33!) = 1,585,080
5 char string - (37! / 32!) = 52,307,640
Where the ! operator means factorial[^].
|
|
|
|
|
how to compress the data in c programming?
what is the algorithm in c?
|
|
|
|
|
|
|
I found ReadFile operation is slow. Is there ay way to make it fast? Or is there any assemble code available to read from file/disk
|
|
|
|
|
Often times, when disk-io needs to be sped-up there are gains to be made in the way that the data is accessed -but not so much (if any gain) available in the function used to get that data.
For example - if you have (say)a million pieces of data stored in a file, it's a better(faster) option to use ReadFile just once and read in the 1,000,000 pieces of data than it is to call the function 1,000,000 times to read 1 piece of data.
Provided you're running in an OS with protected memory (i.e not DOS), no - not practically. You could attempt to write some low level code, but I'd suspect that the folk that wrote that part of windows would be more capable of speed than you.
Are you able to elaborate on the conditions in which you're using ReadFile, and the reasons you've come to the conclusion it's slow? It's very likely that algorithmic improvements can be made. 
|
|
|
|
|
How do you measure "slow"? At the very best a ReadFile() operation will operate at the transfer speed of the disk and its interface. At the very worst there are lots of factors that may affect it.
The best things in life are not things.
|
|
|
|
|
Disk I/O in itself is slow, regardless of the API used. What exactly are you needing to do?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I read data from a drive at different locations. I can not read large data because of some memory issue.
Why it's slow because i check one software which reads it fast.
|
|
|
|
|
Usually when reading from a file, then one reads in small chunks like one byte at a time.
If using a wrapper around ReadFile like fstream, then it will perform readahead caching by reading large chunks from the file into memory. When reading small chunks from fstream, then it will actually read directly from the internal cache inside fstream.
|
|
|
|
|
Hi all,
i want to send info to my server and on server side server processed on received information and get back some result on my side i receive the result and display a message what is returned by server.
so please tell me how can i do this processing?
what function or methods are use for this.
please help me for this and provide info and guidance for this.
thanks in advance.
|
|
|
|
|
There are many ways to do this (TCP/IP for instance), and most of them can be found with a simple Google search. CodeProject also has many articles on the subject.
"Real men drive manual transmission" - Rajesh.
|
|
|
|