void addSoundSource(AudioClip sound, int ID) { Vector3 posistionVector = getNewPosistionVector(); GameObject source = Instantiate(soundSource, posistionVector, Quaternion.identity) as GameObject; audioSourceList.Add(source); SoundSourceBehaviour sourceBehaviour = source.GetComponent <SoundSourceBehaviour>(); sourceBehaviour.setID(ID); updateSoundSource(sound, (audioSourceList.Count - 1)); }
public void receiveFloats(float[] dataFloats, int ID) { AudioClip soundClip = AudioClip.Create("clip", dataFloats.Length, 1, 8000, true, false); soundClip.SetData(dataFloats, 0); for (int i = 0; i < audioSourceList.Count; i++) { SoundSourceBehaviour sourceBehaviour = audioSourceList[i].GetComponent <SoundSourceBehaviour>(); if (sourceBehaviour.getID() == ID) { //update current source updateSoundSource(soundClip, i); return; } } //add new source if loop completes addSoundSource(soundClip, ID); return; }