Question by
MattTaylor · Sep 25, 2015 at 11:56 PM ·
soundaudiosourceaudioclipartifacts
Changing AudioSource.clip causes click/pop sound
Hi All, I've had this problem for a while now, and have not had much luck finding a solution.
I have a script attached to a gameObject called BGM.cs. In this script, a coroutine is started that picks a random AudioClip from a List and plays it. After a time delay it then plays another random clip.
Here's the play code:
// get the track from the playlist
AudioClip clip = tracks[CurretTrack];
// stop the audioplayer first (may cause Pop noise if clip is changed
// while playing) <-- Did not work
musicSource.Stop();
// set the clip and play it
musicSource.clip = clip;
musicSource.Play();
yield return new WaitForSeconds(time);
I am using MP3 music, and I have also noticed this with other audio assets in WAV, only when stopping or changing a clip.
I uploaded an example of the set-up and the bug to YT: https://youtu.be/G074KSn9IxE
If anyone can help me with this, I'd really appreciate it :)
Comment
Answer by ppizarro · Apr 19, 2019 at 02:03 AM
this happen when you set a new clip to the audio source and play it many times in a show period of time. try using :
musicSource.PlayOneShot(clip);