I am just copying this code in other guy coding with waveinopen function and the codes capturing audio from any input like microphone and it works fine.
here is the code
#include <windows.h>
#include <mmsystem.h>
#include <stdio.h>
#define SOUNDBUFF 65536;
#pragma comment(lib,"libwinmm.a")//this will make the linker links
WAVEFORMATEX wf;
WAVEHDR whdr;
HWAVEIN hWaveIn;
HWAVEOUT hWaveOut;
LPSTR lpData;
int main(void)
{
char clpData[65536];
lpData=clpData;
wf.wFormatTag=WAVE_FORMAT_PCM;
wf.nChannels=1;
wf.nSamplesPerSec=8000;
wf.nAvgBytesPerSec=wf.nSamplesPerSec;
wf.nBlockAlign=1;
wf.wBitsPerSample=8;
wf.cbSize=0;
waveInOpen((LPHWAVEIN)&hWaveIn,WAVE_MAPPER,&wf,0,0,CALLBACK_NULL);
whdr.lpData = lpData;
whdr.dwBufferLength = SOUNDBUFF;
whdr.dwBytesRecorded = 0;
whdr.dwFlags = 0L;
whdr.dwLoops = 0L;
waveInPrepareHeader(hWaveIn,&whdr,sizeof(whdr));
waveInAddBuffer(hWaveIn,&whdr,sizeof(whdr));
waveInStart(hWaveIn);
int n=0;
do {
} while (!(whdr.dwFlags & WHDR_DONE));
waveInUnprepareHeader((HWAVEIN)hWaveOut,&whdr,sizeof(whdr));
waveInClose(hWaveIn);
waveOutOpen(&hWaveOut,WAVE_MAPPER,&wf,0,0,CALLBACK_NULL);
waveOutPrepareHeader(hWaveOut,&whdr,sizeof(whdr));
waveOutWrite(hWaveOut,&whdr,sizeof(whdr));
n=0;
do {
} while (!(whdr.dwFlags & WHDR_DONE));
waveOutUnprepareHeader(hWaveOut,&whdr,sizeof(whdr));
waveOutClose(hWaveOut);
return 0;
}
But i am wondering how could i code the audio input and play at the same time?
any help would be appreciated thanks guys. =)