WASAPI: Microphone -> Speakers stream

Hey everyone,

i wrote a program that streams the microphone input directly to the speakers. The program works so far, but now i have two problems. I followed the example here:


Problem 1: The speakers just play noise. I can hear a bang when i tap on the microphone but not much more. When i speak it's not recognizable. I don't really know how to improve the quality of the stream. I use the same microphone for skype and it works just fine there.

Problem 2: The microphone records the sound from the speakers creating a loop and a lot of noise. I tested it using earphones but that is not really what i wanted. Any ideas here ?

Here is a pseudo code example of my program:

while(true) {
memcpy(renderBuffer, CaptureBuffer...) //copy all available frames
You have a feedback loop. There really is not a lot you can do about this because the problem is with the physical proximity of the speaker to the microphone. We have this issue where I work when our VoIP phones are used on laptops and a headset has been the most practical solution so far. Otherwise a separate microphone or a separate set of speakers moved away from it's counter part would help mitigate this issue.
Thank you for the answer. I am currently testing it with earphones. But curiously the feedback loop is still there. I have two theories: 1) The frame size is wrong and i am reading overlapping frames or 2) The program is reading out the same frames over and over again.

I calculated the frame size (BitsPerSample * nChannels) / 8. Is that right ? (I divided through 8 because memcpy takes bytes as argument)

If i understood the API right the releaseBuffer call should tell the buffer which frames have already been read. I use the numAvailableFrames as Argument because i copy all the frames from the input buffer. Does anyone have experience with the WASAPI ?
Use a high quality microphone (unidirectional one) and keep some distance from the speakers to minimize "microphony" effect.
I think i found the error. The Audio Endpoint device uses six channels while the microphone uses only two. So I record frames with 8Bytes but the endpoint buffer thinks they are 24Bytes. Does anyone know how i can set the AudioClient->MixFormat ? There seems to be no Method for it.
Topic archived. No new replies allowed.