// Coroutine that varies the frequency with which it plays audio files
 IEnumerator cycleTracksFrequenecyRange(RandomizedQueue <AudioFile> files, float minFrequency, float maxFrequency)
 {
     while (coroutinesActive)
     {
         Play(files.Cycle());
         yield return(new WaitForSeconds(UnityEngine.Random.Range(minFrequency, maxFrequency)));
     }
 }
 // Plays audio files on a set frequenecy
 IEnumerator cycleTracksFrequenecy(RandomizedQueue <AudioFile> files, float frequenecy)
 {
     while (coroutinesActive)
     {
         Play(files.Cycle());
         yield return(new WaitForSeconds(frequenecy));
     }
 }
 // Plays audio files back to back
 IEnumerator cycleTracksContinuous(RandomizedQueue <AudioFile> files)
 {
     while (coroutinesActive)
     {
         AudioFile nextTrack = files.Cycle();
         Play(nextTrack);
         yield return(new WaitForSeconds(nextTrack.Clip.length));
     }
 }
	// Test randomized queue
	void randomizedQeueDemo () {
		string[] testList = new string[]{"one", "two", "three"};

		RandomizedQueue<string> queue = new RandomizedQueue<string>(testList);

		// Cycle ensures that the randomized queue does not return the same value two times in a row
		// But it also re-adds the value
		for (int i = 0; i < 20; i++) {
			Debug.Log(queue.Cycle());
		}
	}
Beispiel #5
0
 public AudioFile GetRandomFile()
 {
     checkFileQueue();
     return(currentFile = fileQueue.Cycle());
 }
	// Coroutine that varies the frequency with which it plays audio files
	IEnumerator cycleTracksFrequenecyRange (RandomizedQueue<AudioFile> files, float minFrequency, float maxFrequency) {
		while (_coroutinesActive) {
			Play(files.Cycle());
			yield return new WaitForSeconds(
				UnityEngine.Random.Range(
					minFrequency, 
					maxFrequency
				)
			);
		}
	}
	// Plays audio files on a set frequenecy
	IEnumerator cycleTracksFrequenecy (RandomizedQueue<AudioFile> files, float frequenecy) {
		while (_coroutinesActive) {
			Play(files.Cycle());
			yield return new WaitForSeconds(frequenecy);
		}
	}
	// Plays audio files back to back
	IEnumerator cycleTracksContinuous (RandomizedQueue<AudioFile> files) {
		while (_coroutinesActive) {	
			AudioFile nextTrack = files.Cycle();
			Play(nextTrack);
			yield return new WaitForSeconds(nextTrack.Clip.length);
		}
	}