- Home /
Capture audio without playing it back
I am trying to use a microphone and process the audio captured. I managed to do all that, but I have a problem... My audio captured is automatically played to the user, and I don't want that.
audioSrc.clip = Microphone.Start(null, true, 1000, 44100);
while (!(Microphone.GetPosition(null) > 0)) { }
audioSrc.Play();
I tried to disable the audio listener and lower the volume of the audio source, but that didn't work.
Anyone knows how I can capture audio without playing it back?
Iv never tried setting up a mic system in Unity yet, though looking at the documentation for that, it seems like your 2nd condition "loop", will go back to the beginning of the recording and essentially "overlap" tracks... Then your playing it all while this is happening (im assu$$anonymous$$g all 3 lines of code are inside the Update function?) Im sure if you removed the "audioSrc.Play();" line, your issue would be solved, and put that in a condition that checks if the microphone should no longer be recording, THEN play it, if you want a playback right as soon as they finish recording.
You could also try setting audioSrc.$$anonymous$$ute to true as its recording, which may also help, ins$$anonymous$$d of doing it from the inspector.
Answer by KyleBlumreisinger · Nov 14, 2017 at 01:00 AM
I have the answer! I found this question today because I had the same question and was hoping someone answered it, but nope. So after hours more research, finally I can be the one to write the answer.
So basically, to stop the echo, you need the audiosource to not be muted, and still be outputting somewhere. Just not somewhere you can hear it. So in the "Output" slot in the inspector for the AudioSource, you just need to give it an output that you can't hear. The solution is to open an AudioMixer (tabs at the top-->Window-->AudioMixer), make a new mixer and a new group in that mixer, slide down the attenuation/volume slider for the new group, and click and drag that new group into your AudioSource's "Output" field.
For better instructions, here's where I got this information from: http://crazyminnowstudio.com/posts/unity-5.2-bug-audiosource.getoutputdata-no-data-when-source-is-muted/
And that very link also provides the following link to a video showing how to do it: https://drive.google.com/file/d/0B1WsYkuIdxLNNlhEb2NhV3F6Wlk/view
Cheers! :D
Your answer
Follow this Question
Related Questions
Voice Recording issue ?? 0 Answers
Mac Built-In Microphone Not Working 2 Answers
Unity 5 and using a microphone 1 Answer
Get volume from microphone to make something happen 0 Answers
Microphone input to Audio Clip. 4 Answers