Reading WaveIn samples

Hello,

I've written some C code for a PIC microcontroller to do some ADC sampling and perform some signal processing, which is fully working.
For off-chip modelling on PC, I would like to use the same code in Visual C++. Most of the code should be directly compatible, but the sampling uses a timer interrupt to request an ADC and fill a buffer. What is the best way to emulate this?
I was thinking of a separate thread that loops, pulling a sample and sleeping for x period to emulate the timer interrupt. This way I could directly use the same interrupt code from my PIC project. (I'm ideally wanting to keep the code as consistent as possible.)
The problem is, I have no experience of pulling samples from an audio device in C++ under windows, and no experience of multi-threading. So those are my two questions really; How do I create a thread to do the sampling, and how do I make it grab a sample and sleep for x period before grabbing another (emulating the timer interrupt)?

Any help is much appreciated :)


the waveIn interface directly supports an interrupt mechanism via its callback option. You don't need to create a separate thread, you can just supply a callback routine that is called when more input data is available.

See reference pages:

waveInOpen: to specify the callback
https://msdn.microsoft.com/en-us/library/windows/desktop/dd743847%28v=vs.85%29.aspx

waveInProc: the format your callback needs to be... and what its parameters are to mean:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd743849%28v=vs.85%29.aspx
Topic archived. No new replies allowed.