Ejemplo n.º 1
0
        protected override void LoadContent()
        {
            ergonWave                  = Content.Load <SoundEffect>("ergon.adpcm");
            ergonWaveInstance          = ergonWave.Create();
            ergonWaveInstance.IsLooped = true;
            waveBank = Content.Load <WaveBank>("TestBank");
            //waveBankXbox = Content.Load<WaveBank>("TestBankXbox.xwb"); //does not play correctly

            // SpriteFont supports the following font file format:
            // - DirectX Toolkit MakeSpriteFont or SharpDX Toolkit tkfont
            // - BMFont from Angelcode http://www.angelcode.com/products/bmfont/
            arial16BMFont = Content.Load <SpriteFont>("Arial16");

            // Instantiate a SpriteBatch
            spriteBatch = new SpriteBatch(GraphicsDevice);

            primitiveBatch       = new PrimitiveBatch <VertexPositionColor>(GraphicsDevice);
            primitiveBatchEffect = new BasicEffect(GraphicsDevice);
            primitiveBatchEffect.VertexColorEnabled = true;


            // setup tests
            tiles = new List <SoundTile>();
            Rectangle border = new Rectangle();

            border.X = SoundTile.Padding.X;
            border.Y = SoundTile.Padding.Y;

            AddTile(ref border, "Click to play looped SoundEffectInstance of " + ergonWave.Name, PlayMusic, PauseMusic);
            AddTile(ref border, "Click to play 'PewPew' wave bank entry", () => waveBank.Play("PewPew"));
            AddTile(ref border, "Click to play 'PewPew' wave bank entry with random pitch and pan", () => waveBank.Play("PewPew", 1, random.NextFloat(-1, 1), random.NextFloat(-1, 1)));
            AddTile(ref border, "Click to play 'PewPew' with 3D audio", PlayAudio3D, StopAudio3D);

            // setup 3D
            geometryEffect = ToDisposeContent(new BasicEffect(GraphicsDevice)
            {
                View       = Matrix.LookAtRH(new Vector3(0, 10, 20), new Vector3(0, 0, 0), Vector3.UnitY),
                Projection = Matrix.PerspectiveFovRH((float)Math.PI / 4.0f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f),
                World      = Matrix.Identity
            });

            cube = ToDisposeContent(GeometricPrimitive.Cube.New(GraphicsDevice));

            // Load the texture
            listenerTexture = Content.Load <Texture2D>("listen");
            emitterTexture  = Content.Load <Texture2D>("speaker");
            geometryEffect.TextureEnabled = true;

            base.LoadContent();
        }
Ejemplo n.º 2
0
        void LoadContent_Sound()
        {
            beep         = Content.Load <SoundEffect>("button-42");
            beepInstance = beep.Create();

            // Load Sounds
            ergonWave                  = Content.Load <SoundEffect>("ergon.adpcm");
            ergonWaveInstance          = ergonWave.Create();
            ergonWaveInstance.IsLooped = true;
            waveBank = Content.Load <WaveBank>("TestBank");

            // setup tests
            tiles = new List <SoundTile>();
            Rectangle border = new Rectangle();

            border.X = SoundTile.Padding.X;
            border.Y = SoundTile.Padding.Y;

            AddTile(ref border, "Click to play looped SoundEffectInstance of " + ergonWave.Name, PlayMusic, PauseMusic);
            AddTile(ref border, "Click to play 'PewPew' wave bank entry", () => waveBank.Play("PewPew"));
            AddTile(ref border, "Click to play 'PewPew' wave bank entry with random pitch and pan", () => waveBank.Play("PewPew", 1, random.NextFloat(-1, 1), random.NextFloat(-1, 1)));
            AddTile(ref border, "Click to play 'PewPew' with 3D audio", PlayAudio3D, StopAudio3D);

            AddTile(ref border, "Click to play 'Button-42' ", beepInstance.Play, beepInstance.Stop);

            // setup 3D
            geometryEffect = ToDisposeContent(new BasicEffect(GraphicsDevice)
            {
                View       = Matrix.LookAtRH(new Vector3(0, 10, 20), new Vector3(0, 0, 0), Vector3.UnitY),
                Projection = Matrix.PerspectiveFovRH((float)Math.PI / 4.0f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f),
                World      = Matrix.Identity
            });

            cube = ToDisposeContent(GeometricPrimitive.Cube.New(GraphicsDevice));

            // Load the texture
            listenerTexture = Content.Load <Texture2D>("listen");
            emitterTexture  = Content.Load <Texture2D>("speaker");
            geometryEffect.TextureEnabled = true;
        }