I finished my program so I went to test it on other computer. And it stopped working as soon as I started it. The problem was that I put "Sleep" function inside between WaveInStart and WaveInStop to allow the program to record 6.5 seconds of audio and then stop.
When I removed Sleep function everything worked fine. So, is there any other way to automatically stop recording after some time? With Sleep it works fine on my computer but it doesn't on the other.
I have now tried even with this code instead Sleep(), but the same thing. Could it be something else? Why it won't work on my laptop but it works on a computer that I compiled the code on?
MMRESULT wavStrt = waveInStart(wih);
time_t ft;
time(&ft);
int tdif=0;
while (tdif <= 7){
time_t st;
time(&st);
tdif = difftime(st, ft);
}
if (tdif > 6){
MMRESULT wavStop = waveInStop(wih);
MMRESULT unprep = waveInUnprepareHeader(wih, &header, sizeof(WAVEHDR));
if (unprep == MMSYSERR_NOERROR)
This usually happens when your application is trying to link to something at run time that isn't there. Try installing the appropriate C-Run Time library for the compiler you are using on the laptop.
It would depend on the compiler that you are using. If for example you are using the version of cl for MS Visual Studio 2012, then you want to install the MSCRT 2012 version.
I figured it out. It was my own stupidity. I told my timer to wait for "t" miliseconds. And "t" was calculated from signal coming in to my microphone. I did not setup microphone correctly so no sound was coming into a program and no data was extracted from it. So then my timer went crazy and crashed. :) Now I set it up so "t" was pre-set and updated later if a signal appears.