Dropped sounds with multiple audiosources

I have a little piano game where the user can touch piano keys to play the a piano key and hear a note sound. Additionally, the user can press a button that makes the piano play a sound on its own. Playing a note also plays a key up and down animation.

My implementation has 16 audio sources. Each piano key press looks for an audio source not running and then uses it. The audio sources are created in the Unity editor and put on the GameObject.

My problem: occasionally notes do not play. From debug I know an audiosource has been selected and plays the note audioClip. Before isPlaying is false, and after isPlaying is true but no sound occurs. The associated animation always works. It can happen on the second note played or the nth. It seems more likely to happen in certain sequences but not reliably. I am not a fan of non-repeatable bugs.

This happen in Windows and on the Android device making is appear to be a Unity issue.

My code.

		AudioSource audioSource  = nextPlayOnceSource(); // get an AudioSource
		audioSource.clip = clip;
		audioSource.Play();

I have also tried

		AudioSource audioSource  = nextPlayOnceSource();
		audioSource.PlayOneShot(clip);

Any ideas on what could be wrong or other things for me to experiment with are greatly appreciated.

perhaps your sounds just use too many channels for the target hardware to keep up and thus the last fired sound won’t play.

It frequently drops a played sound on the second one played. That typically happens when a note is repeated, which is to say the same AudioClip is played twice before the first time is finished.

If it was using up channels the behavior would be more predictable, wouldn’t it? My android device will reliably fail to play more than 4 looping audio clips while my development computer can handle over 20.

This dropping sounds happens the same on my development computer using a top end sound card and on my Samsung Galaxy device.

I’m having the same issue on Unity 3.1. Sounds intermittently don’t play on both Mac and the iPhone. I’m sure I’m not running out of channels since it sometimes happens when very few or no other sounds are playing.

Most of my sound effects are 16bit, 44Hz, mono, 2D .wav files and most are < 1 second. Here’s how I play them:

public AudioSource sfxSpawn;

...

void PlaySpawnSFX() {
	sfxSpawn.Play();

}

How many channels are available anyway?
Is it platform dependant?
How many on a computer (PC/Mac)?