當前位置: 首頁>>代碼示例>>C#>>正文


C# Audio.AudioListener類代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Audio.AudioListener的典型用法代碼示例。如果您正苦於以下問題:C# AudioListener類的具體用法?C# AudioListener怎麽用?C# AudioListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AudioListener類屬於Microsoft.Xna.Framework.Audio命名空間,在下文中一共展示了AudioListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SoundManager

        public SoundManager(ContentManager content)
        {
            //gameState = content.ServiceProvider.GetService(typeof(GameState)) as GameState;
            stateGame = content.ServiceProvider.GetService(typeof(StateGame)) as StateGame;
            renderingState = content.ServiceProvider.GetService(typeof(RenderingState)) as RenderingState;
            selection = content.Load<SoundEffect>("Sounds/select");
            explosion = content.Load<SoundEffect>("Sounds/explosion2");
            laser = content.Load<SoundEffect>("Sounds/laser");

            cameraListener = new AudioListener();
            cameraListener.Position =
                new Vector3(
                    renderingState.spriteBatch.GraphicsDevice.Viewport.Width / 2,
                    renderingState.spriteBatch.GraphicsDevice.Viewport.Height / 2,
                    0);

            explosionEmitter = new List<AudioEmitter>();
            explosionInstance = new List<SoundEffectInstance>();
            explosionPos = new List<Vector3>();

            laserEmitter = new List<AudioEmitter>();
            laserInstance = new List<SoundEffectInstance>();
            laserPos = new List<Vector3>();

            isSoundActive = true;
        }
開發者ID:JacopoV,項目名稱:Tap---Conquer,代碼行數:26,代碼來源:SoundManager.cs

示例2: PlatformApply3D

        private void PlatformApply3D(AudioListener listener, AudioEmitter emitter)
        {
            // If we have no voice then nothing to do.
            if (_voice == null)
                return;

            // Convert from XNA Emitter to a SharpDX Emitter
            var e = emitter.ToEmitter();
            e.CurveDistanceScaler = SoundEffect.DistanceScale;
            e.DopplerScaler = SoundEffect.DopplerScale;
            e.ChannelCount = _effect._format.Channels;

            // Convert from XNA Listener to a SharpDX Listener
            var l = listener.ToListener();

            // Number of channels in the sound being played.
            // Not actually sure if XNA supported 3D attenuation of sterio sounds, but X3DAudio does.
            var srcChannelCount = _effect._format.Channels;

            // Number of output channels.
            var dstChannelCount = SoundEffect.MasterVoice.VoiceDetails.InputChannelCount;

            // XNA supports distance attenuation and doppler.            
            var dpsSettings = SoundEffect.Device3D.Calculate(l, e, CalculateFlags.Matrix | CalculateFlags.Doppler, srcChannelCount, dstChannelCount);

            // Apply Volume settings (from distance attenuation) ...
            _voice.SetOutputMatrix(SoundEffect.MasterVoice, srcChannelCount, dstChannelCount, dpsSettings.MatrixCoefficients, 0);

            // Apply Pitch settings (from doppler) ...
            _voice.SetFrequencyRatio(dpsSettings.DopplerFactor);
        }
開發者ID:KennethYap,項目名稱:MonoGame,代碼行數:31,代碼來源:SoundEffectInstance.XAudio.cs

示例3: SoundManager

 public SoundManager(Game game)
     : base(game)
 {
     _sounds = new List<AudioSound>();
     _listener = new AudioListener();
     _emitter = new AudioEmitter();
 }
開發者ID:gabry90,項目名稱:BIOXFramework,代碼行數:7,代碼來源:SoundManager.cs

示例4: Initialize

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            frameinfo = new FrameInfo();
            text = new Text(GraphicsDevice, Services, "Content", "Arial");
            model = new SLModel(GraphicsDevice, Services, "Content", "earth");
            model.Para.BasePara.space = 200;
            model.Para.BasePara.speed3D = Vector3.Backward * 3f;
            model.Para.BasePara.rotationspeed3D = Vector3.UnitY * 0.3f;
            model.ProjectionType = ProjectionType.Perspective;
            model.globalCamera.Position = Vector3.UnitZ * 200;
            model.globalCamera.NearPlane = 1.0f;
            model.globalCamera.FarPlane = 1000f;

            audio = new SLAudio(SLConfig["content"] + "StiLib", SLConfig["content"] + "SLMWB", SLConfig["content"] + "SLSWB", SLConfig["content"] + "SLSB");
            audiolistener = new AudioListener()
                                {
                                    Forward = model.globalCamera.Direction,
                                    Position = model.globalCamera.Position,
                                    Up = model.globalCamera.Up,
                                    Velocity = Vector3.Zero
                                };
            audio.Listeners.Add(audiolistener);
            audioemitter = new AudioEmitter()
                               {
                                   DopplerScale = 1.0f,
                                   Forward = Vector3.Forward,
                                   Position = model.BasePara.center,
                                   Up = Vector3.Up,
                                   Velocity = model.BasePara.speed3D
                               };
            //audio.Update();
            audio.Play("Buzz", audioemitter);
        }
開發者ID:babaq,項目名稱:StiLib,代碼行數:41,代碼來源:MainGame.cs

示例5: PlaySound

 public Cue PlaySound(string soundName, AudioListener audioListener, AudioEmitter audioEmitter)
 {
     Cue result = GetCue(soundName);
     result.Apply3D(audioListener, audioEmitter);
     result.Play();
     return result;
 }
開發者ID:Hamsand,項目名稱:Swf2XNA,代碼行數:7,代碼來源:AudioManager.cs

示例6: Apply3DPosition

 public void Apply3DPosition(Cue cue, AudioListener listener, AudioEmitter emitter,
     Vector3 listenerPosition, Vector3 emitterPosition)
 {
     listenerPosition = listener.Position;
     emitterPosition = emitter.Position;
     cue.Apply3D(listener, emitter);
 }
開發者ID:bradleat,項目名稱:trafps,代碼行數:7,代碼來源:Audio.cs

示例7: CameraController

 public CameraController(Game game, CarActor carActor)
     : base(game)
 {
     this.carActor_ = carActor;
     cameraState_ = new LinkedList<CameraState>();
     listener_ = new AudioListener();
     SetupCamera();
 }
開發者ID:smanoharan,項目名稱:242TopGearElectrified,代碼行數:8,代碼來源:CameraController.cs

示例8: PlaySounds

 public void PlaySounds(AudioListener listener)
 {
     //If you do not apply 3D before using play, the sound will not be flagged as 3D.
     _tuneInstance.Apply3D(listener, _emitter);
     if (_tuneInstance.State == SoundState.Stopped)
     {
         _tuneInstance.Play();
     }
 }
開發者ID:Westerdals,項目名稱:PG2200LectureCode2013,代碼行數:9,代碼來源:PianoPlayer.cs

示例9: Apply3DAll

 public void Apply3DAll(Cue cue, AudioListener listener, AudioEmitter emitter, Vector3 listenerPosition,
     Vector3 emitterPosition, Vector3 listenerVelocity, Vector3 emitterVelocity)
 {
     listenerPosition = listener.Position;
     emitterPosition = emitter.Position;
     listener.Velocity = listener.Velocity;
     emitter.Velocity = emitter.Velocity;
     cue.Apply3D(listener, emitter);
 }
開發者ID:bradleat,項目名稱:trafps,代碼行數:9,代碼來源:Audio.cs

示例10: OpponentEngineSoundManager

        //Only one listener, several emitters
        //Store emitters in a list?
        //Store listener as a single variable in the class
        //Update receives emitters current position and velocity
        //
        public OpponentEngineSoundManager(Vector3 position, Vector3 velocity)
        {
            player = new AudioListener();
            player.Position = position;
            player.Velocity = velocity;

            opponentEngines = new Dictionary<string, MovingCueEmitter>();

            AEM = AudioEngineManager.GetInstance();
        }
開發者ID:MintL,項目名稱:datx02-rally,代碼行數:15,代碼來源:OpponentEngineSoundManager.cs

示例11: CorvSoundEffectCue

        /// <summary>
        /// Creates a new instance of CorvSoundEffectCue with attenuation.
        /// </summary>
        public CorvSoundEffectCue(Cue cue, Vector2 listenerPosition, Vector2 emitterPosition)
            : base(cue)
        {
            this._Listener = new AudioListener();
            this._Listener.Position = new Vector3(listenerPosition, 0);
            this._Emitter = new AudioEmitter();
            this._Emitter.Position = new Vector3(emitterPosition, 0);

            Cue.Apply3D(this._Listener, this._Emitter);
        }
開發者ID:Octanum,項目名稱:Corvus,代碼行數:13,代碼來源:CorvSoundEffectCue.cs

示例12: EnvironmentSoundManager

        //Only one listener, several emitters
        //Store emitters in a list?
        //Store listener as a single variable in the class
        //Update receives emitters current position and velocity
        //
        public EnvironmentSoundManager(Vector3 position, Vector3 velocity)
        {
            player = new AudioListener();
            player.Position = position;
            player.Velocity = velocity;

            environmentSounds = new List<CueEmitter>();

            AEM = AudioEngineManager.GetInstance();
        }
開發者ID:MintL,項目名稱:datx02-rally,代碼行數:15,代碼來源:EnvironmentSoundManager.cs

示例13: SoundManager

 public SoundManager()
 {
     UpdateDeltaTime();
     _audioBufferList = new byte[AudioBufferCount][];
     for (int i = 0; i < _audioBufferList.Length; ++i)
         _audioBufferList[i] = new byte[ChannelCount * BytesPerSample * AudioBufferSize];
     _renderingBuffer = new short[ChannelCount*AudioBufferSize];
     SoundFunction = MySin;
     AudioListener x = new AudioListener();
 }
開發者ID:ApexHAB,項目名稱:apex-lumia,代碼行數:10,代碼來源:SoundManager.cs

示例14: SoundManager

 //See http://rbwhitaker.wikidot.com/audio-tutorials
 //See http://msdn.microsoft.com/en-us/library/ff827590.aspx
 //See http://msdn.microsoft.com/en-us/library/dd940200.aspx
 public SoundManager(Main game, string audioEngineStr, string waveBankStr, string soundBankStr)
     : base(game)
 {
     this.game = game;
     this.audioEngine = new AudioEngine(@"" + audioEngineStr);
     this.waveBank = new WaveBank(audioEngine, @"" + waveBankStr);
     this.soundBank = new SoundBank(audioEngine, @"" + soundBankStr);
     this.cueList = new List<Cue3D>();
     this.playSet = new HashSet<string>();
     this.audioListener = new AudioListener();
 }
開發者ID:SongmanW,項目名稱:Group-Project-2016-Team-Magia,代碼行數:14,代碼來源:SoundManager.cs

示例15: Initialize

 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     for (int i = 0; i < 3; i++)
     {
         _gameObjects.Add(new GameObject());
         _gameObjects.Add(new Bonfire());
     }
     _listener = new AudioListener();
     _listener.Position = Vector3.Zero; //It's already set to this but never mind :)
     _listener.Forward = Vector3.Forward;
     _listener.Up = Vector3.Up;
     base.Initialize();
 }
開發者ID:Westerdals,項目名稱:PG2200LectureCode2013,代碼行數:19,代碼來源:Lecture6ExampleGame.cs


注:本文中的Microsoft.Xna.Framework.Audio.AudioListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。