I’m developing a loop station kind of app which the user could tap on a slot to record his/her voice and tap again to replay their voice.
However, whenever I tap on the slot to record, there’s a 0.5 sec lag… (It works fine on Unity Editor, but there’s always a 0.5 sec lag on my iOS build)
below is my code:
public void OnPointerDown()
{
if (recordMode) {
StartCoroutine(RecordCoroutine());
} else {
GetComponent<AudioSource>().Play();
}
}
IEnumerator RecordCoroutine()
{
//change the color to show that it's currently recording
GetComponent<Image>().color = Color.red;
//start recording
GetComponent<AudioSource>().clip = Microphone.Start(null, false, 1, 44100);
yield return new WaitForSeconds(1f);
//stop the mic
Microphone.End(null);
//recover button color
GetComponent<Image>().color = Color.white;
}
Is there a way to get rid of the lag… I’ve been searching for a solution for an entire week but in vain…
P.S. I’ve already changed the DSP Buffer Size to Best latency to minimize the lag to play the audio clip.