AudioSource doesn't make sound for a couple seconds

I am triggering an audio file when a certain property is the right value. I have all the audio files in memory, I set the clip on the audio source, set the time to 0, and tell it to play. If I haven’t played a sound for a few minutes then the audio doesn’t start playing for about 2 seconds. I can see that the play function is being called at the right time, and when the audio starts making sounds it is at the right position from when I called it.

Thanks for the help.

Edit:

Here’s my AudioController class. The “d” class that is referenced is for logging and debugging. Yes, there is no silence at the beginning of the audio files. The problem occurs when the app has been left alone for about 5 minutes or more. If the value is triggered before 5 minutes then the audio files work fine, but after 5 minutes the first couple seconds are cut off.

public class AudioController : MonoBehaviour {
    
    	public delegate void ClipCompleteEvent(AudioSource audioSource);
    	public event ClipCompleteEvent OnClipComplete;
    	
    	public AudioSource voSource;
    	public AudioClip silence;
    
    	protected ArrayList sourcesPlaying = new ArrayList();
    
        void Start()
        {
    //		d.l("AudioController.Start");
    		if(!playing) playSilence();
        }
    
    	void Update()
    	{
    		for(int i = 0; i < sourcesPlaying.Count; i++)
    		{
    			if(!((AudioSource)sourcesPlaying*).isPlaying &&*

_ ((AudioSource)sourcesPlaying*).clip != silence)_
_
{_
_
// d.l (“audio done”, OnClipComplete, audioSource);_
_
if(OnClipComplete != null)_
_ OnClipComplete((AudioSource)sourcesPlaying);
sourcesPlaying.RemoveAt(i);
playSilence();
i–;
}
}
}*_

* public void play(AudioClip clip, float startPlayheadAtTime = 0, bool loop = false)*
* {*
* d.l(d.ms.most, “playAudio”, clip.name);*
* if(clip == null) return;*

* playClipOnSource(voSource, clip, startPlayheadAtTime);*
}

* public void stop()*
* {*
* voSource.Stop();*
* sourcesPlaying.Remove(voSource);*

* playSilence();*
* }*

* protected void playSilence()*
* {*
* voSource.clip = silence;*
* voSource.volume = .01f;*
* voSource.Play();*
* voSource.loop = true;*
* }*

* protected void playClipOnSource(AudioSource source, AudioClip clip, float startPlayheadAtTime = 0)*
* {*
* source.Stop();*
* source.clip = clip;*
* source.time = startPlayheadAtTime;*
* source.loop = false;*
* voSource.volume = 1f;*
* source.Play();*
* if(sourcesPlaying.IndexOf(source) == -1)*
* sourcesPlaying.Add(source);*
* }*

* public bool playing { get { return voSource.isPlaying && voSource.clip != silence; } }*

* public delegate void FadeCompleteEvent();*
* public event FadeCompleteEvent OnFadeComplete;*

* public iTween.EaseType easeFunc = iTween.EaseType.easeInOutCubic;*

* protected bool fading;*

* public void setVolume(float value)*
* {*
* if(playing)*
* voSource.volume = value;*
* }*

* protected void onFadeUpdate(float value)*
* {*
* setVolume(value);*
* }*

* protected void onFadeComplete()*
* {*

* if(voSource.isPlaying)*
* stop();*

* fading = false;*
* if(OnFadeComplete != null)*
* OnFadeComplete();*
* }*

* public float fade(float volume = 1, float scnds = 1, float delay = 0)*
* {*
* if(fading) return delay;*

* fading = true;*
* iTween.ValueTo(gameObject, iTween.Hash(“time”, scnds, “easetype”, easeFunc, “from”, voSource.volume,*
* “to”, volume, “delay”, delay, “onupdate”, “onFadeUpdate”,*
* “oncomplete”, “onFadeComplete”));*
* return delay + scnds;*
* }*
}

I haven’t found out why this is happening but I have something in place that’s working well enough. I load the next audio file that is going to play and play it on loop very quietly until I need to hear it. Then when I need to play it I raise the volume and seek back to the beginning of the file. I couldn’t set the silent playing to 0 or else the problem would still happen, I had to have it play very quietly (volume at 0.05 out of 1). Hope this helps someone.