- Home /
Get microphone FFT input without playback
Hi,
I am trying to get the spectrum data from a smartphone's microphone, but I don't want the microphone audio to play in the scene. (The clip is being recorded and loops)
Evidently, the audiosource must be playing in order to fetch the spectrum data, so I presumed that putting "audioSource.muted = true" would do the trick. This also mutes the spectrum data however.
The common workaround suggested currently is to create a mixer group that puts the volume to -80db, and assign that to the microphone audiosource. Doing this currently on iOS bugs out my global game volume however, making it impossible to increase the maximum volume above 50% (Unity 5.5.2p4)
Any suggestions on how I can achieve getting the spectrum data without having to actually play the recorded audioclip?
Answer by MD_Reptile · Apr 07, 2017 at 02:51 PM
As it turns out, when Unity is using the microphone on iOS, the maximum speaker volume of the OS gets reduced by about half. (As mentioned in this post)
I am looking for a way to fetch the microphone FFT without it affecting the speaker volume on the device, preferably in a way that doesn't require an audio source in the scene with any workaround mixer values attached.
In an ideal situation, I would just be able to get the spectrum data directly from the audio clip, but I presume that is impossible without some kind of playback.
Thanks in advance
Answer by Bunny83 · Apr 12, 2017 at 04:07 PM
I never really worked with microphone input. However when you can access the PCM data you could try my FFT implementation