Example #1
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();
            }
        }
Example #2
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();
            }
        }
Example #3
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();
            }
        }
Example #4
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();
            }
        }
Example #5
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();
     }
 }
Example #6
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();
            }
        }
Example #7
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();
     }
 }
Example #8
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();
            }
        }
Example #9
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();
 }