public IEnumerator Enso_FadeOutTrack()
        {
            SetUpMusicPlayer();

            yield return(null);

            MusicTrack track = new MusicTrack
            {
                Track = AudioClip.Create("test", 2000, 1, 1000, false)
            };

            track.CreateAndCacheClips();
            module.Play(track, EnsoConstants.PlayEndlessly);

            float originalVolume = speaker1.volume;

            yield return(null);

            module.FadeOut(2);

            Assert.AreEqual(Speaker.VolumeStatuses.FadingOut, module.VolumeStatus);

            yield return(null);

            Assert.AreNotEqual(speaker1.volume, originalVolume, "The volume isn't changing when fading out.");

            yield return(new WaitForSecondsRealtime(2));

            Assert.AreEqual(Speaker.VolumeStatuses.Static, module.VolumeStatus);
            Assert.AreEqual(speaker1.volume, 0f, "Speaker volume doesn't equal 0 when fading out is complete.");
        }
        public IEnumerator Enso_PlayAfterFadeOut()
        {
            SetUpMusicPlayer();

            yield return(null);

            MusicTrack track = new MusicTrack
            {
                Track = AudioClip.Create("test", 2000, 1, 1000, false)
            };

            track.CreateAndCacheClips();

            musicPlayer.Play(track);

            yield return(null);

            musicPlayer.FadeOut();

            yield return(new WaitForSeconds(2));

            Assert.IsTrue(speaker1.volume <= 0f, "Speaker should be muted after fadeout.");

            musicPlayer.Play("MusicTest");

            yield return(null);

            Assert.IsTrue(speaker1.volume == musicPlayer.Volume, "Speaker1 should be back at player volume after PlayTrack() is called.");
            Assert.IsTrue(speaker2.volume == musicPlayer.Volume, "Speaker2 should be back at player volume after PlayTrack() is called.");
            Assert.IsTrue(speaker3.volume == musicPlayer.Volume, "Speaker3 should be back at player volume after PlayTrack() is called.");
            Assert.IsTrue(speaker4.volume == musicPlayer.Volume, "Speaker4 should be back at player volume after PlayTrack() is called.");
        }
        public IEnumerator Enso_PlayShouldSetCurrentTrack()
        {
            // Arrange
            SetUpMusicPlayer();

            // Play(string) test
            // Act
            musicPlayer.Play("MusicTest");

            yield return(null);

            // Assert
            Assert.IsNotNull(musicPlayer.PlayingTrack);

            // Play(MusicTrack) test
            // Arrange
            MusicTrack track = new MusicTrack
            {
                Track = AudioClip.Create("test", 1000000, 1, 1000, false)
            };

            track.CreateAndCacheClips();

            // Act
            musicPlayer.Stop();
            musicPlayer.Play(track);

            yield return(null);

            // Assert
            Assert.IsNotNull(musicPlayer.PlayingTrack);
        }
        public IEnumerator Enso_CrossfadeShouldSetCurrentTrack()
        {
            // Arrange
            SetUpMusicPlayer();
            MusicTrack track = new MusicTrack
            {
                Name  = "test",
                Track = AudioClip.Create("test", 1000000, 1, 1000, false)
            };

            track.CreateAndCacheClips();

            musicPlayer.Tracks.Add(track);

            // Act
            musicPlayer.Play("MusicTest");

            yield return(null);

            musicPlayer.CrossFadeTo("test");

            yield return(null);

            // Assert
            Assert.AreNotSame(musicPlayer.PlayingTrack, musicPlayer.Tracks.Where(x => x.Name == "MusicTest").First());
        }
        public IEnumerator Enso_DontChangeVolumeWhileFading()
        {
            SetUpMusicPlayer();

            yield return(null);

            MusicTrack track = new MusicTrack
            {
                Track      = AudioClip.Create("test", 4000, 1, 1000, false),
                LoopStart  = 1000,
                LoopLength = 1000
            };

            track.CreateAndCacheClips();
            musicPlayer.Play(track);

            yield return(null);

            musicPlayer.FadeIn();
            float originalVolume = speaker1.volume;

            musicPlayer.SetVolume(.5f);

            Assert.AreNotEqual(speaker1.volume, .5f, "Volume should not be changeable while fading in.");

            yield return(new WaitForSeconds(2));

            musicPlayer.FadeOut();
            musicPlayer.SetVolume(.5f);

            Assert.AreNotEqual(speaker1.volume, .5f, "Volume should not be changeable while fading out.");
        }
        public IEnumerator Enso_ScrubbingToEndsOfTrackShouldNotThrowError()
        {
            SetUpMusicPlayer();

            yield return(null);

            MusicTrack track = new MusicTrack
            {
                Track      = AudioClip.Create("test", 13803264, 2, 44100, false),
                LoopStart  = 11130,
                LoopLength = 6477145
            };

            track.CreateAndCacheClips();

            yield return(null);

            musicPlayer.Play(track);

            yield return(null);

            musicPlayer.Scrub(152.098f);

            yield return(null);

            musicPlayer.ScrubAsPercentage(.97f);
        }
        public IEnumerator Enso_FadeInTrack()
        {
            SetUpMusicPlayer();

            yield return(null);

            musicPlayer.CrossFadeTime = 1f;
            musicPlayer.SetVolume(.75f);
            MusicTrack track = new MusicTrack
            {
                Track = AudioClip.Create("test", 2000, 1, 1000, false)
            };

            track.CreateAndCacheClips();
            module.Play(track, EnsoConstants.PlayEndlessly);
            module.SetSpeakerVolume(0f);

            yield return(null);

            module.FadeIn(musicPlayer.CrossFadeTime);
            float originalVolume = speaker1.volume;

            Assert.AreEqual(Speaker.VolumeStatuses.FadingIn, module.VolumeStatus);

            yield return(null);

            Assert.AreNotEqual(speaker1.volume, originalVolume, "The volume isn't changing when fading in.");

            yield return(new WaitForSeconds(2));

            Assert.AreEqual(Speaker.VolumeStatuses.Static, module.VolumeStatus);
            Assert.AreEqual(musicPlayer.Volume, speaker1.volume, "Speaker volume doesn't equal 1 when fading in is complete.");
        }
        public IEnumerator Enso_NullLoopPointsShouldNotThrowException()
        {
            SetUpMusicPlayer();

            yield return(null);

            MusicTrack track = new MusicTrack
            {
                Track = AudioClip.Create("test", 10000, 1, 1000, false),
            };

            track.CreateAndCacheClips();
        }
示例#9
0
        public void Enso_NoLoopSettings()
        {
            // Arrange
            var clip = AudioClip.Create("test", 20000, 2, 1000, false);

            MusicTrack track = new MusicTrack
            {
                Track      = clip,
                LoopStart  = 0,
                LoopLength = 0
            };

            track.Track = clip;

            // Act
            track.CreateAndCacheClips();
        }
示例#10
0
        public void Enso_OutOfBoundsFailsafe()
        {
            // Arrange
            var clip = AudioClip.Create("test", 20000, 2, 1000, false);

            MusicTrack track = new MusicTrack
            {
                Track      = clip,
                LoopStart  = 10,
                LoopLength = 50
            };

            track.Track = clip;

            // Act
            track.CreateAndCacheClips();
        }
示例#11
0
        public void Enso_LengthInSamples()
        {
            // Arrange
            var clip = AudioClip.Create("test", 20000, 2, 1000, false);

            MusicTrack track = new MusicTrack
            {
                Track      = clip,
                LoopStart  = 3,
                LoopLength = 10
            };

            track.Track = clip;

            // Act
            track.CreateAndCacheClips();

            // Assert
            Assert.AreEqual(13, track.LengthInSamples);
        }