Esempio n. 1
0
        public void SoundEffectPlayer_SlidesVolumeCorrectly(AudioImplementation audioImplementation)
        {
            var sfxPlayer = default(SoundEffectPlayer);
            var sfx       = default(SoundEffect);

            GivenAnUltravioletApplicationWithNoWindow()
            .WithAudioImplementation(audioImplementation)
            .WithInitialization(uv => uv.GetAudio().AudioMuted = true)
            .WithContent(content =>
            {
                sfxPlayer = SoundEffectPlayer.Create();
                sfx       = content.Load <SoundEffect>("SoundEffects/grenade");

                sfxPlayer.Play(sfx, false);

                TheResultingValue(sfxPlayer.Volume).ShouldBe(1f);

                sfxPlayer.SlideVolume(0f, TimeSpan.FromSeconds(1));
            })
            .OnUpdate((app, time) =>
            {
                sfxPlayer.Update(time);
            })
            .RunFor(TimeSpan.FromSeconds(2));

            TheResultingValue(sfxPlayer.Volume).ShouldBe(0f);
        }
Esempio n. 2
0
        public void SoundEffectPlayer_PlayResetsVolumePitchAndPanWhenNotSpecified(AudioImplementation audioImplementation)
        {
            var sfxPlayer = default(SoundEffectPlayer);
            var sfx       = default(SoundEffect);

            GivenAnUltravioletApplicationWithNoWindow()
            .WithAudioImplementation(audioImplementation)
            .WithInitialization(uv => uv.GetAudio().AudioMuted = true)
            .WithContent(content =>
            {
                sfxPlayer = SoundEffectPlayer.Create();
                sfx       = content.Load <SoundEffect>("SoundEffects/grenade");

                sfxPlayer.Play(sfx, 0.25f, 0.50f, 0.75f, false);
                sfxPlayer.Stop();
                sfxPlayer.Play(sfx, false);

                TheResultingValue(sfxPlayer.Volume).ShouldBe(1f);
                TheResultingValue(sfxPlayer.Pitch).ShouldBe(0f);
                TheResultingValue(sfxPlayer.Pan).ShouldBe(0f);
            })
            .OnUpdate((app, time) =>
            {
                sfxPlayer.Update(time);
            })
            .RunForOneFrame();
        }
Esempio n. 3
0
        public void BASS_SoundEffectPlayer_ThrowsExceptionIfPanSetWhileNotPlaying()
        {
            var sfxPlayer = default(SoundEffectPlayer);

            Assert.That(() =>
            {
                GivenAnUltravioletApplicationWithNoWindow()
                .WithInitialization(uv => uv.GetAudio().AudioMuted = true)
                .WithContent(content =>
                {
                    sfxPlayer     = SoundEffectPlayer.Create();
                    sfxPlayer.Pan = 0f;
                })
                .RunFor(TimeSpan.FromSeconds(1));
            },
                        Throws.TypeOf <InvalidOperationException>());
        }
Esempio n. 4
0
        protected override void OnLoadingContent()
        {
            this.content = ContentManager.Create("Content");
            LoadContentManifests();

            this.spriteFont         = this.content.Load <SpriteFont>(GlobalFontID.SegoeUI);
            this.spriteBatch        = SpriteBatch.Create();
            this.textRenderer       = new TextRenderer();
            this.textLayoutCommands = new TextLayoutCommandStream();

            for (int i = 0; i < this.soundEffectPlayers.Length; i++)
            {
                this.soundEffectPlayers[i] = SoundEffectPlayer.Create();
            }

            this.soundEffect = this.content.Load <SoundEffect>(GlobalSoundEffectID.Explosion);

            base.OnLoadingContent();
        }
Esempio n. 5
0
        public void BASS_SoundEffectPlayer_PlaySetsVolumePitchAndPan()
        {
            var sfxPlayer = default(SoundEffectPlayer);
            var sfx       = default(SoundEffect);

            GivenAnUltravioletApplicationWithNoWindow()
            .WithInitialization(uv => uv.GetAudio().AudioMuted = true)
            .WithContent(content =>
            {
                sfxPlayer = SoundEffectPlayer.Create();
                sfx       = content.Load <SoundEffect>("SoundEffects/grenade");

                sfxPlayer.Play(sfx, 0.25f, 0.50f, 0.75f, false);

                TheResultingValue(sfxPlayer.Volume).ShouldBe(0.25f);
                TheResultingValue(sfxPlayer.Pitch).ShouldBe(0.50f);
                TheResultingValue(sfxPlayer.Pan).ShouldBe(0.75f);
            })
            .RunForOneFrame();
        }
Esempio n. 6
0
        public void BASS_SoundEffectPlayer_SlidesPitchCorrectly()
        {
            var sfxPlayer = default(SoundEffectPlayer);
            var sfx       = default(SoundEffect);

            GivenAnUltravioletApplicationWithNoWindow()
            .WithInitialization(uv => uv.GetAudio().AudioMuted = true)
            .WithContent(content =>
            {
                sfxPlayer = SoundEffectPlayer.Create();
                sfx       = content.Load <SoundEffect>("SoundEffects/grenade");

                sfxPlayer.Play(sfx, false);

                TheResultingValue(sfxPlayer.Pitch).ShouldBe(0f);

                sfxPlayer.SlidePitch(-1f, TimeSpan.FromSeconds(1));
            })
            .RunFor(TimeSpan.FromSeconds(2));

            TheResultingValue(sfxPlayer.Pitch).ShouldBe(-1f);
        }
Esempio n. 7
0
        public void SoundEffectPlayer_ThrowsExceptionIfPitchSetWhileNotPlaying(AudioImplementation audioImplementation)
        {
            var sfxPlayer = default(SoundEffectPlayer);

            Assert.That(() =>
            {
                GivenAnUltravioletApplicationWithNoWindow()
                .WithAudioImplementation(audioImplementation)
                .WithInitialization(uv => uv.GetAudio().AudioMuted = true)
                .WithContent(content =>
                {
                    sfxPlayer       = SoundEffectPlayer.Create();
                    sfxPlayer.Pitch = -1f;
                })
                .OnUpdate((app, time) =>
                {
                    sfxPlayer.Update(time);
                })
                .RunFor(TimeSpan.FromSeconds(1));
            },
                        Throws.TypeOf <InvalidOperationException>());
        }