Click here to Skip to main content
11,584,612 members (62,584 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 17:48pm
Edited 19-Dec-12 19:34pm
(no name)137K
v2

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

  Print Answers RSS
0 OriginalGriff 430
1 Sergey Alexandrovich Kryukov 367
2 Dave Kreskowiak 260
3 Richard Deeming 220
4 virusstorm 194
0 OriginalGriff 1,703
1 Sergey Alexandrovich Kryukov 1,267
2 Abhinav S 711
3 Dave Kreskowiak 687
4 Suvendu Shekhar Giri 568


Advertise | Privacy | Mobile
Web03 | 2.8.150707.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