void stopSound(AudioManipulation AM) { IEnumerator fadeSound1 = AudioFadeOut.FadeOut(AM, 1f); audioManip[currentAudio].inFadeOut = true; audioManip[currentAudio].fadeSound = fadeSound1; StartCoroutine(fadeSound1); }
void startSound(AudioManipulation AM) { if (AM.inFadeOut) { StopCoroutine(AM.fadeSound); AM.inFadeOut = false; /*AM.startVolume */ } AM.startSound(); }
public static IEnumerator FadeOut(AudioManipulation AM, float FadeTime) { AudioSource audioSource = AM.audioSource; float startVolume = audioSource.volume; while (audioSource.volume > 0) { audioSource.volume -= startVolume * Time.deltaTime / FadeTime; yield return(null); } audioSource.Stop(); audioSource.volume = startVolume; AM.inFadeOut = false; }
// Use this for initialization void Start() { leadersArray = flock.getLeadersArray(); gridsArray = flock.getGridsArray(); InvokeRepeating("spawnSoundLength", 5f, 1f); audioSpectrum = GetComponent <AudioSpectrum>(); initializeCheckSound(); currentAudio = -1; aSource = sounds.GetComponentsInChildren <AudioSource>(); /*foreach(var source in aSource) { * Debug.Log(source.gameObject.name); * }*/ /*for (int i = 0; i < aSource.Length; i++) { * audioManip[i] = new AudioManipulation(aSource[i], 22000f, 10f, 0f); * audioManip[i].initializeIt(); * }*/ /*attention on gère les inputs en prenant la longueur de ce tableau*/ audioManip[0] = new AudioManipulation(masterMix, aSource[0], 22000f, 10f, 0f, 0f, 1f); audioManip[0].initializeIt(); audioManip[2] = new AudioManipulation(masterMix, aSource[1], 6000f, 2100f, 5f, 5f, 1.5f); audioManip[2].initializeIt(); audioManip[3] = new AudioManipulation(masterMix, aSource[2], 500f, 10f, 0f, 0f, 1f); audioManip[3].initializeIt(); audioManip[1] = new AudioManipulation(masterMix, aSource[3], 22000f, 10f, 0f, 0f, 1f); audioManip[1].initializeIt(); nbSounds = 4; }