I am working on a C++ program which will do the following:
1. Waits for any audio signal from an integrated laptop microphone
2. Logs that an event occurred in a .txt file (time calculated by counter)
3. Repeats
Eventually the sound will be a single clap in an otherwise quiet room. However at this point detection of ANY sound will be fine. I have investigated the use of waveIn() and the DirectSound libraries, also the use of APIs, but they seem to be complete overkill for this task. All I would like is to detect an audio signal in so that a flag may be set. From this flag the log loop will execute. Then the flag is reset and the system continues to listen. It will do this in 1 second intervals. I am not looking for code from you, I would just like some feedback on what to start with. I'm drowning in library features right now that I don't need.
Here is my code. Please note that I am not including the headers and all of my Visual C++ 2008 Express Edition project files. If it is needed I will post them, but I thought I would make this concise at first. Also ignore the rest of the stuff, I am still working on it. The part where I need to put the audio event detection code is labeled "// Audio signal event detection." Thanks in advance.
// CodeTimer.cpp : main project file.
// Using Query Performance Counter.
Console::WriteLine(S"QueryPerformanceCounter minimum resolution: 1/{0} Seconds.",freq.ToString());
// In Visual Studio 2005, this line should be changed to: Console::WriteLine("QueryPerformanceCounter minimum resolution: 1/{0} Seconds.",freq.ToString());
Console::WriteLine("100 Increment time: {0} seconds.",((ctr2 - ctr1) * 1.0 / freq).ToString());
}
else
{
DWORD dwError = GetLastError();
Console::WriteLine(S"Error value = {0}",dwError.ToString());// In Visual Studio 2005, this line should be changed to: Console::WriteLine("Error value = {0}",dwError.ToString());
}
// Make the console window wait.
Console::WriteLine();
Console::Write("Press ENTER to finish.");
Console::Read();
}