Click here to Skip to main content
11,484,162 members (71,079 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: audio
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 
                                  //with this library
    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. =)
Posted 19-Dec-12 18:48pm
Edited 19-Dec-12 20:34pm
(no name)133.3K
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 185
1 Frankie-C 155
2 Raje_ 155
3 OriginalGriff 147
4 CPallini 110
0 Sergey Alexandrovich Kryukov 8,484
1 OriginalGriff 7,948
2 Sascha Lefèvre 3,189
3 Maciej Los 2,601
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web02 | 2.8.150520.1 | Last Updated 20 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100