Exemplo n.º 1
0
        private void TestLocalizationCoherencyLoopImpl(Game game, int loopCount, int loopCountSum)
        {
            // useless motion on the root entities just to check that is does not disturb to calculations.
            rootSubEntity1.Transform.Position += new Vector3(1, 2, 3);
            listCompEntities[0].Transform.Position += new Vector3(3, 2, -1);
            // have the emitter turn clockwise around the listener.
            emitCompEntities[0].Transform.Position = new Vector3((float)Math.Cos(loopCount * Math.PI / 100), 0, (float)Math.Sin(loopCount * Math.PI / 100));

            // the sound should turn around clockwise 
            if (loopCount == 800)
            {
                game.Exit();
            }
        }
Exemplo n.º 2
0
        private void TestDopplerCoherencyLoopImpl(Game game, int loopCount, int loopCountSum)
        {
            // useless motion on the root entities just to check that is does not disturb to calculations.
            rootSubEntity1.Transform.Position += new Vector3(1, 2, 3);
            listCompEntities[0].Transform.Position += new Vector3(3, 2, -1);
            // apply a left to right motion to the emitter entity
            emitCompEntities[0].Transform.Position = new Vector3(20*(loopCount-200), 0, 2);

            // the sound should be modified in pitch depending on which side the emitter is
            // ( first pitch should be increased and then decreased)
            if (loopCount == 400)
            {
                game.Exit();
            }
        }
Exemplo n.º 3
0
        private void TestAttenuationCoherencyLoopImpl(Game game, int loopCount, int loopCountSum)
        {
            // put away progressively the emitter.
            emitCompEntities[0].Transform.Position = new Vector3(0, 0, loopCount / 10f);

            // the sound should progressively attenuate
            if (loopCount == 800)
            {
                game.Exit();
            }
        }
Exemplo n.º 4
0
 private void TestEffectsAndMusicLoopImpl(Game game, int loopCount, int loopCountSum)
 {
     if (loopCount == 0)
     {
         // start the sound music in background.
         var music = game.Asset.Load<SoundMusic>("MusicFishLampMp3");
         music.Play();
     }
     // here we should hear the mp3.
     else if (loopCount == 240)
     {
         // check that AudioEmitterComponent can be played along with soundMusic.
         soundControllers[0].Play();
     }
     // here we should hear the soundEffect 0 and the mp3.
     else if (loopCount == 260)
     {
         // check that two AudioEmitterComponent can be played along with a soundMusic.
         soundControllers[2].Play();
     }
     // here we should hear the soundEffect 0 and 2 and the mp3.
     else if (loopCount == 500)
     {
         game.Exit();
     }
 }
Exemplo n.º 5
0
        private void TestSeveralControllersLoopImpl(Game game, int loopCount, int loopCountSum)
        {
            // have the emitter turn around the listener to check that all sounds are coming from the same emitter.
            emitCompEntities[0].Transform.Position = new Vector3((float)Math.Cos(loopCount * Math.PI / 30), 0, (float)Math.Sin(loopCount * Math.PI / 30));

            if (loopCount == 0)
            {
                // start a first controller
                soundControllers[0].Play();
            }
            // here we should hear SoundEffect 0
            else if (loopCount == 30)
            {
                // start a second controller while controller 1 has not finished to play
                soundControllers[1].Play();
            }
            // here we should hear SoundEffect 0 and 1
            else if (loopCount == 60)
            {
                // start a third controller while controller 2 has not finished to play
                soundControllers[3].Play();
            }
            // here we should hear the soundEffect 1 and 2
            else if (loopCount == 120)
            {
                game.Exit();
            }
        }
Exemplo n.º 6
0
 private void TestRemoveListenerLoopImpl(Game game, int loopCount, int loopCountSum)
 {
     if (loopCount == 0)
     {
         // check that initially the sound are hear via the two listeners.
         soundControllers[0].Play();
         soundControllers[2].Play();
     }
     // here we should hear the soundEffect 0 on left ear and the soundEffect 2 on right ear
     else if (loopCount == 60)
     {
         // remove listener 3 from the entity system => check that the sounds are now heard only via listener 1
         throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
         //game.Entities.Remove(listCompEntities[2]);
     }
     // here we should hear the soundEffect 0 on left ear only
     else if (loopCount == 120)
     {
         // remove listener 1 from the audio system  => check that the sounds are not outputted anymore.
         game.Audio.RemoveListener(listComps[0]);
     }
     // here we should hear nothing.
     else if (loopCount == 180)
     {
         game.Exit();
     }
 }
Exemplo n.º 7
0
        private void TestAddRemoveEmitterLoopImpl(Game game, int loopCount, int loopCountSum)
        {
            if (loopCount == 0)
            {
                // check there is no sound output if the emitterComponents are not added to the entity system.
                soundControllers[0].Play();
                soundControllers[2].Play();
            }
            // here we should hear nothing.
            else if (loopCount == 60)
            {
                // add emitter 1 to the entity system
                throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
                //game.Entities.Add(emitCompEntities[0]);

                // check that emitter 1 can now be heard.
                soundControllers[0].Play();
                soundControllers[2].Play();
            }
            // here we should hear the soundEffect 0 on left ear only
            else if (loopCount == 120)
            {
                // add now emitter 2 to the entity system
                throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
                //game.Entities.Add(emitCompEntities[1]);

                // test that now both emitters can be heard.
                soundControllers[0].Play();
                soundControllers[2].Play();
            }
            // here we should hear the soundEffect 0 on left ear and the soundEffect 2 on right ear
            else if (loopCount == 180)
            {
                // remove emitter 2 from the entity system  
                throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
                //game.Entities.Remove(emitCompEntities[1]);

                // test that now only emitter 1 can be heard.
                soundControllers[0].Play();
                soundControllers[2].Play();
            }
            // here we should hear the soundEffect 0 on left ear only
            else if (loopCount == 240)
            {
                // remove emitter 1 from the entity system  
                throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
                //game.Entities.Remove(emitCompEntities[0]);

                // check that there is not more audio output at all
                soundControllers[0].Play();
                soundControllers[2].Play();
            }
            // here we should hear nothing.
            else if (loopCount == 320)
            {
                game.Exit();
            }
        }
Exemplo n.º 8
0
 private void TestExitLoopLoopImpl(Game game, int loopCount, int loopCountSum)
 {
     if (loopCount == 0)
     {
         mainController.Play();
     }
     // should hear the beginning of the sound
     else if (loopCount == 10)
     {
         // test a basic utilisation of exitLoop.
         mainController.ExitLoop();
     }
     // should hear the end of the sound
     else if (loopCount == 60)
     {
         Assert.IsTrue(mainController.IsLooped, "The value of isLooped has been modified by ExitLoop.");
         Assert.AreEqual(SoundPlayState.Stopped, mainController.PlayState, "The sound did not stopped after exitloop.");
     }
     // should hear nothing
     else if (loopCount == 80)
     {
         // check that performing an exitLoop before the play commit does not fail (bfr next AudioSystem.Uptade).
         mainController.Play();
         mainController.ExitLoop();
     }
     // should hear a sound not looped
     else if (loopCount == 140)
     {
         Assert.IsTrue(mainController.IsLooped, "The value of isLooped has been modified by ExitLoop just after play.");
         Assert.AreEqual(SoundPlayState.Stopped, mainController.PlayState, "The sound did not stopped after Exitloop just after play.");
     }
     // should hear nothing
     else if (loopCount == 160)
     {
         mainController.Play();
     }
     // should hear the beginning of the sound
     else if (loopCount == 170)
     {
         // check that performing an ExitLoop while the sound is paused does not fails.
         mainController.Pause();
         mainController.ExitLoop();
     }
     // should hear nothing
     else if (loopCount == 220)
     {
         mainController.Play();
     }
     // should hear the end of the sound (not looped)
     else if (loopCount == 270)
     {
         Assert.IsTrue(mainController.IsLooped, "The value of isLooped has been modified by ExitLoop after pause.");
         Assert.AreEqual(SoundPlayState.Stopped, mainController.PlayState, "The sound did not stopped after exitloop after pause.");
     }
     // should hear nothing
     else if (loopCount == 320)
     {
         // check that performing an exitLoop while the sound is stopped is ignored.
         mainController.ExitLoop();
         mainController.Play();
     }
     // should hear the sound looping
     else if (loopCount == 500)
     {
         Assert.IsTrue(mainController.IsLooped, "The value of isLooped has been modified by ExitLoop before play.");
         Assert.AreEqual(SoundPlayState.Playing, mainController.PlayState, "The sound did not looped.");
         game.Exit();
     }
 }
Exemplo n.º 9
0
        private void TestAddListenerLoopImpl(Game game, int loopCount, int loopCountSum)
        {
            if (loopCount == 0)
            {
                // check that a controller play call output nothing if there is no listener currently listening.
                soundControllers[0].Play();
            }
            // nothing should come out from the speakers during this gap
            else if(loopCount == 60)
            {
                // check that the sound is correctly outputted when there is one listener
                game.Audio.AddListener(listComps[0]);
                soundControllers[0].Play();
            }
            // here we should hear soundEffect 0
            else if (loopCount == 120)
            {
                // isolate the two listeners such that emitter 1 can be heard only by listener 1 and emitter 2 by listener 2
                // and place emitters such that emitters 1 output on left ear and emitter 2 on right ear.
                listCompEntities[0].Transform.Position = listCompEntities[0].Transform.Position - new Vector3(1000, 0, 0);
                emitCompEntities[0].Transform.Position = emitCompEntities[0].Transform.Position - new Vector3(1, 0, 0);
                emitCompEntities[1].Transform.Position = emitCompEntities[1].Transform.Position + new Vector3(1, 0, 0);

                // add a new listener not present into the entity system yet to the audio system
                listComps.Add(new AudioListenerComponent());
                listCompEntities.Add(new Entity());
                listCompEntities[2].Add(listComps[2]);
                game.Audio.AddListener(listComps[2]);

                // check that the sound is not heard by the new listener (because not added to the entity system).
                soundControllers[0].Play();
                soundControllers[2].Play();
            }
            // here we should hear the soundEffect 0 on left ear only
            else if(loopCount == 180)
            {
                // add the new listener to the entity system
                throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
                //game.Entities.Add(listCompEntities[2]);

                // check the sounds are heard by the two listeners.
                soundControllers[0].Play();
                soundControllers[2].Play();
            }
            // here we should hear the soundEffect 0 on left ear and the soundEffect 2 on right ear
            else if(loopCount > 240)
            {
                game.Exit();
            }
        }
Exemplo n.º 10
0
 private void TestStopLoopImpl(Game game, int loopCount, int loopCountSum)
 {
     if (loopCount == 0)
     {
         // check that a call to stop works even though the call to play has not been comitted yet (next AudioSystem.Update).
         soundControllers[2].Play();
         soundControllers[2].Stop();
     }
     // should hear nothing
     else if (loopCount == 60)
     {
         Assert.AreEqual(SoundPlayState.Stopped, soundControllers[2].PlayState, "The sound play status was not stopped just after play.");
         soundControllers[2].Play();
     }
     // should hear the beginning of the sound
     else if (loopCount == 150)
     {
         // test the basic call to stop.
         soundControllers[2].Stop();
         Assert.AreEqual(SoundPlayState.Stopped, soundControllers[2].PlayState, "The sound play status was not stopped.");
     }
     // should hear nothing
     else if (loopCount == 200)
     {
         soundControllers[2].Play();
     }
     // should hear the beginning of the sound
     else if (loopCount == 400)
     {
         game.Exit();
     }
 }
Exemplo n.º 11
0
 private void TestPlayStateLoopImpl(Game game, int loopCount, int loopCountSum)
 {
     if (loopCount == 60)
     {
         // check that PlayState is automatically reset to 'Stopped' when all the subInstances have finished to play.
         Assert.AreEqual(SoundPlayState.Stopped, mainController.PlayState, "Value of playState with listeners is not valid after the end of the track.");
         game.Exit();
     }
 }
Exemplo n.º 12
0
        private void TestPlayLoopImpl(Game game, int loopCount, int loopCountSum)
        {
            if (loopCount == 0)
            {
                // test that the sound does not play when playing a sound associated to an entity which has not been added to the system yet.
                mainController.Play();
            }
            // should hear nothing
            else if (loopCount == 100)
            {
                Assert.AreEqual(SoundPlayState.Stopped, mainController.PlayState, "The sound play status was playing eventhough the entity was not added.");

                // check the behavious of a basic call to play.
                AddRootEntityToEntitySystem(game);
                mainController.Play();
            }
            // should hear the beginning of the sound
            else if (loopCount == 120)
            {
                Assert.AreEqual(SoundPlayState.Playing, mainController.PlayState, "The sound play status was not playing eventhough the entity was added.");
            }
            // should hear the end of the sound
            else if (loopCount == 160)
            {
                // add a longuer sound
                sounds.Add(game.Content.Load<SoundEffect>("EffectFishLamp"));
                emitComps[0].AttachSoundEffect(sounds[2]);
                soundControllers.Add(emitComps[0].GetSoundEffectController(sounds[2]));
                soundControllers[2].Play();
            }
            // should hear the beginning of the sound
            else if (loopCount == 300)
            {
                // check that the sound is stopped when removing the listeners.
                game.Audio.RemoveListener(listComps[0]);
                game.Audio.RemoveListener(listComps[1]);
                Assert.AreEqual(SoundPlayState.Stopped, soundControllers[2].PlayState, "The sound has not been stopped when the listeners have been removed.");
            }
            // should hear nothing
            else if (loopCount == 360)
            {
                game.Audio.AddListener(listComps[0]);
                game.Audio.AddListener(listComps[1]);
                soundControllers[2].Play();
            }
            // should hear the beginning of the sound
            else if (loopCount == 500)
            {
                // check that the sound is stopped when removing the sound Entity from the system.
                Internal.Refactor.ThrowNotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
                //game.Entities.Remove(rootEntity);
                Assert.AreEqual(SoundPlayState.Stopped, soundControllers[2].PlayState, "The sound has not been stopped when the emitter's entities have been removed.");
            }
            // should hear nothing
            else if (loopCount == 560)
            {
                game.Exit();
            }
        }
Exemplo n.º 13
0
 private void TestIsLoopedLoopImpl(Game game, int loopCount, int loopCountSum)
 {
     if (loopCount == 0)
     {
         // check that the sound loops as it should.
         mainController.IsLooped = true;
         mainController.Play();
     }
     // should hear looped sound
     else if (loopCount == 100)
     {
         Assert.AreEqual(SoundPlayState.Playing, mainController.PlayState, "The sound play status was stopped but the sound is supposed to be looped.");
         mainController.Stop();
     }
     // should hear nothing
     else if (loopCount == 150)
     {
         // check that the sound does not loop  as it should.
         mainController.IsLooped = false;
         mainController.Play();
     }
     // should hear not a looped sound
     else if (loopCount == 250)
     {
         Assert.AreEqual(SoundPlayState.Stopped, mainController.PlayState, "The sound play status was playing but the sound is supposed to do so.");
         mainController.Stop();
     }
     // should hear not a looped sound
     else if (loopCount == 300)
     {
         // check that setting the isLooped without listener works too
         game.Audio.RemoveListener(listComps[0]);
         game.Audio.RemoveListener(listComps[1]);
         mainController.IsLooped = true;
         game.Audio.AddListener(listComps[0]);
         game.Audio.AddListener(listComps[1]);
         mainController.Play();
     }
     // should hear looped sound
     else if (loopCount == 400)
     {
         Assert.AreEqual(SoundPlayState.Playing, mainController.PlayState, "The sound play status was stopped but the sound is supposed to be looped.");
         mainController.Stop();
     }
     // should hear looped sound
     else if (loopCount == 450)
     {
         mainController.Play();
     }
     else if (loopCount == 475)
     {
         // check that IsLooped throws InvalidOperationException when modified while playing.
         Assert.Throws<InvalidOperationException>(() => mainController.IsLooped = true, "setting isLooped variable during playing sound did not throw InvalidOperationException");
         game.Exit();
     }
 }
Exemplo n.º 14
0
 private void TestVolumeLoopImpl(Game game, int loopCount, int loopCountSum)
 {
     if (loopCount == 0)
     {
         // check that setting the volume before play works.
         mainController.Volume = 0.1f;
         mainController.Play();
     }
     // should hear low volume
     else if(loopCount == 60)
     {
        mainController.Volume = 1f;
        mainController.Play();
     }
     // should hear normal volume
     else if (loopCount == 120)
     {
         // check that setting the volume without listener works too
         game.Audio.RemoveListener(listComps[0]);
         game.Audio.RemoveListener(listComps[1]);
         mainController.Volume = 0.1f;
         game.Audio.AddListener(listComps[0]);
         game.Audio.AddListener(listComps[1]);
         mainController.Play();
     }
     // should hear low volume
     else if (loopCount == 180)
     {
         mainController.Volume = 1f;
         mainController.Play();
     }
     // should hear normal volume
     else if (loopCount == 240)
     {
         mainController.Volume = 0f;
         mainController.IsLooped = true;
         mainController.Play();
     }
     else if(loopCount > 240)
     {
         // check that sound goes smoothly from nothing to full intensity
         mainController.Volume = Math.Abs((loopCount - 440) / 200f);
     }
     // the sound should go up and down
     if (loopCount == 640)
     {
         game.Exit();
     }
 }
Exemplo n.º 15
0
        private static void Quit(Game game)
        {
            game.Exit();

#if SILICONSTUDIO_PLATFORM_ANDROID
            global::Android.OS.Process.KillProcess(global::Android.OS.Process.MyPid());
#endif
        }
Exemplo n.º 16
0
 /// <summary>
 /// Utility function to quit the game directly.
 /// </summary>
 /// <remarks>Can be used as parameter for function <see cref="CreateAndRunGame"/>.</remarks>
 /// <param name="game">The <see cref="Game"/> instance.</param>
 static public void ExitGame(Game game)
 {
     game.Exit();
 }