Click here to Skip to main content
15,922,696 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Compiler Error C2504 please help Pin
WernerP28-Sep-05 22:38
WernerP28-Sep-05 22:38 
GeneralRe: Compiler Error C2504 please help Pin
WernerP28-Sep-05 22:46
WernerP28-Sep-05 22:46 
GeneralRe: Compiler Error C2504 please help Pin
WernerP29-Sep-05 1:42
WernerP29-Sep-05 1:42 
QuestionHow to get voice data Pin
pakFari28-Sep-05 21:14
pakFari28-Sep-05 21:14 
AnswerRe: How to get voice data Pin
kakan28-Sep-05 21:55
professionalkakan28-Sep-05 21:55 
GeneralRe: How to get voice data Pin
pakFari29-Sep-05 7:41
pakFari29-Sep-05 7:41 
GeneralRe: How to get voice data Pin
kakan29-Sep-05 19:32
professionalkakan29-Sep-05 19:32 
AnswerRe: How to get voice data Pin
Remco Hoogenboezem28-Sep-05 22:25
Remco Hoogenboezem28-Sep-05 22:25 
Hello pakFari,

You can use the standard windows functions to do this:

MMRESULT waveInOpen
(
LPHWAVEIN phwi,
UINT uDeviceID,
LPWAVEFORMATEX pwfx,
DWORD dwCallback,
DWORD dwCallbackInstance,
DWORD fdwOpen
);

MMRESULT waveInPrepareHeader
(
HWAVEIN hwi,
LPWAVEHDR pwh,
UINT cbwh
);

MMRESULT waveInAddBuffer
(
HWAVEIN hwi,
LPWAVEHDR pwh,
UINT cbwh
);

MMRESULT waveInStart
(
HWAVEIN hwi
);

MMRESULT waveInUnprepareHeader
(
HWAVEIN hwi,
LPWAVEHDR pwh,
UINT cbwh
);

MMRESULT waveInClose
(
HWAVEIN hwi
);

Details on these functions can be found in de Win32 Developer's References.
I wrote a little example program to demonstrate these functions. This example records 60 seconds of low quality audio from the wave audio input device. I use a simple event callback mechanisme to signal the thread when recording is done. There are more elegant way's of doing this. But i think it is up to you to discover how...

HANDLE hEvent;

HWAVEIN hWaveIn;

WAVEFORMATEX WaveFormat=
{
1, //wFormatTag
1, //nChannels
8000, //nSamplesPerSec
8000, //nAvgBytesPerSec
1, //nBlockAlign
8, //wBitsPerSample
0 //cbSize
};

WAVEHDR WaveHeader;

hEvent=CreateEvent(NULL,TRUE,FALSE,NULL);

if(hEvent==NULL)
{
//Handle error

return;
}

//Open wave audio input device

if(waveInOpen(&hWaveIn,WAVE_MAPPER,&WaveFormat,(DWORD)hEvent,0,CALLBACK_EVENT)!=MMSYSERR_NOERROR)
{
//Handle Error

return;
}

WaveHeader.lpData=new BYTE[60*WaveFormat.nAvgBytesPerSec];
WaveHeader.dwBufferLength=60*WaveFormat.nAvgBytesPerSec;
WaveHeader.dwFlags=0;

//Prepare a wave header for waveform-audio input

if(waveInPrepareHeader(hWaveIn,&WaveHeader,sizeof(WAVEHDR))!=MMSYSERR_NOERROR)
{
//Handle Error

return;
}

//Send a input buffer to the given waveform-audio input device

if(waveInAddBuffer(hWaveIn,&WaveHeader,sizeof(WAVEHDR))!=MMSYSERR_NOERROR)
{
//Handle Error

return;
}

if(waveInStart(hWaveIn)!=MMSYSERR_NOERROR)
{
//Handle Error

return;
}

ResetEvent(hEvent);

WaitForSingleObject(hEvent,INFINITE);

if(waveInUnprepareHeader(hWaveIn,&WaveHeader,sizeof(WAVEHDR))!=MMSYSERR_NOERROR)
{
//Handle Error

return;
}

if(waveInReset(hWaveIn)!=MMSYSERR_NOERROR)
{
//Handle Error

return;
}

waveInClose(hWaveIn);

//Process data

WaveHeader.lpData[dwIndex]=//etc...

You can also use the Direct sound api.


QuestionCScrollView Pin
karmendra_js28-Sep-05 21:09
karmendra_js28-Sep-05 21:09 
AnswerRe: CScrollView Pin
Mircea Puiu28-Sep-05 22:01
Mircea Puiu28-Sep-05 22:01 
AnswerRe: CScrollView Pin
followait28-Sep-05 22:38
followait28-Sep-05 22:38 
AnswerRe: CScrollView Pin
vikas amin29-Sep-05 3:09
vikas amin29-Sep-05 3:09 
Questionerror C2664 with InterlockedExchangePointer Pin
Boaz V28-Sep-05 20:51
Boaz V28-Sep-05 20:51 
AnswerRe: error C2664 with InterlockedExchangePointer Pin
Boaz V28-Sep-05 22:16
Boaz V28-Sep-05 22:16 
QuestionShChangeNotifyRegister Pin
ragavan28-Sep-05 20:44
ragavan28-Sep-05 20:44 
QuestionMFC-App and Hyper-Threading Pin
tabor2528-Sep-05 20:24
tabor2528-Sep-05 20:24 
AnswerRe: MFC-App and Hyper-Threading Pin
Marc Soleda28-Sep-05 23:05
Marc Soleda28-Sep-05 23:05 
AnswerRe: MFC-App and Hyper-Threading Pin
vikas amin29-Sep-05 3:19
vikas amin29-Sep-05 3:19 
QuestionMFC Windows Application Question Pin
micutzu28-Sep-05 20:09
micutzu28-Sep-05 20:09 
AnswerRe: MFC Windows Application Question Pin
followait28-Sep-05 22:44
followait28-Sep-05 22:44 
AnswerRe: MFC Windows Application Question Pin
vikas amin28-Sep-05 22:58
vikas amin28-Sep-05 22:58 
GeneralRe: MFC Windows Application Question Pin
micutzu29-Sep-05 3:08
micutzu29-Sep-05 3:08 
QuestionURGENT HELP Pin
dharani28-Sep-05 19:35
dharani28-Sep-05 19:35 
AnswerRe: URGENT HELP Pin
*Dreamz28-Sep-05 19:45
*Dreamz28-Sep-05 19:45 
QuestionAbout ADOs Pin
Venkata Ramana Raju28-Sep-05 19:33
Venkata Ramana Raju28-Sep-05 19:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.