Question by
Unity-1989 · Sep 04, 2019 at 10:55 PM ·
androidiossoundmicrophone
spectrum of microphone
How are you?
i'm new in unity, in this moment i need move object with microphone's spectrum in android e IOS, i have this sourcecode but i have problem because in the emulator function good but in the Android not function good. I don't no what happend.
If do you now what happend please tell me.
Thank for your help.
I share my sourcecode.
void Start()
{
audioSource = GetComponent<AudioSource>();
audioSource.outputAudioMixerGroup = _mixerGroupMicrophone;
audioSource.clip = Microphone.Start(null, true, 10, AudioSettings.outputSampleRate);
audioSource.loop = true;
audioSource.mute = false;
while (!(Microphone.GetPosition(null) > 0))
{
audioSource.outputAudioMixerGroup = _mixerGroupMaster;
audioSource.Play();
}
spectrum = new float[1024];
}
void Update()
{
audioSource.GetSpectrumData(spectrum, 0, FFTWindow.BlackmanHarris);
this.GetComponent<Rigidbody2D>().position = new Vector2(this.GetComponent<Rigidbody2D>().position.x, Mathf.Log(spectrum[2]));
}
Comment