Playing audio chunks one after the other causes a stutter/click sound at the start of each chunk

Hi all, the title pretty much says it all.

Before we talk about importing configurations (such as load types and stuff like that), these are audio clips that are being recorded at runtime, each chunk is 1 second, and has to keep small since they are sent to a server in real time.
I basically create an audio clip from the microphone’s Input (using Microphone.Start), and after a chunk length’s time, I stop the mic and create a new audio clip. Each clip is added to a list, and the playback method simply iterates over every clip in the array, and plays the next element when AudioSource.isPlaying is false (meaning the current clip ended). This is the coroutine:

IEnumerator IterateOverRecordedClips()
        {
            source.clip = clips[0];
            source.Play();
            int i = 1;

            while (i < clips.Count)
            {
                if (!source.isPlaying)
                {
                    Debug.Log("Source stopped playing");
                    source.clip = clips[i];
                    source.Play();
                    i++;
                }
                yield return null;
            }
        }

So my problem is that a sharp stutter/click sound is heard after each iteration.

I’ve thought about recording 2 separate audio clips, one would be a long one that the user can playback, and the other(s) would be small chuncks that are sent to the server. The problem is that Microphone.Start returns only 1 audio clip each time.

Anybody got an idea on how to fix this? Is there a better approach to audio recording-streaming and playing back?

Thanks!

Clicks at the beginning in audio clips are common with audio that is not mixed and mastered properly. When creating music and sound the approach is to set volume to zero at the beginning and end to avoid this. You could try to set your volume to 0 at the beginning of the clip and smooth it up over a few milliseconds, that might help.

1 Like

Thanks for the reply!

I’ll try that when I get back to the office and let you know if that worked for me