• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Audio.AudioListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Xna.Framework.Audio.AudioListener的典型用法代码示例。如果您正苦于以下问题:C# AudioListener类的具体用法?C# AudioListener怎么用?C# AudioListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AudioListener类属于Microsoft.Xna.Framework.Audio命名空间,在下文中一共展示了AudioListener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: AudioManager

        public AudioManager(Game game)
        {
            soundBank = game.Content.LoadDirectory<SoundEffect>("audio/bz");
            musicBank = game.Content.LoadDirectory<Song>("audio/music");

            // register ourselves as a service
            if (game.Services != null)
                game.Services.AddService(typeof(IAudioManager), this);

            emitter = new AudioEmitter();
            listener = new AudioListener();

        }
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:13,代码来源:AudioManager.cs


示例17: ISoundEmitter3D

        /// <summary>
        /// Initializes a new instance of the <see cref="ISoundEmitter3D"/> class.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="SoundName">Name of the sound.</param>
        public ISoundEmitter3D(GraphicFactory factory,String SoundName)
        {
            System.Diagnostics.Debug.Assert(factory != null);
            System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(SoundName));

            this.internalName = SoundName;
            SoundEffect se = factory.GetAsset<SoundEffect>(SoundName);                        
            soundEngineInstance = se.CreateInstance();

            Name = se.Name;
            Duration = se.Duration;
            listener = new AudioListener();
            emiter = new AudioEmitter();
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:19,代码来源:ISoundEmitter3D.cs


示例18: AddedToStage

        public override void AddedToStage(EventArgs e)
        {
            base.AddedToStage(e);

            if (audioListener == null)
            {
                audioListener = new AudioListener();
                audioListener.Position = new Vector3(600, 0, 0);
                audioListener.Velocity = new Vector3(0, 0, 0);
                audioListener.Forward = new Vector3(-1, 0, 0);
            }
            audioEmitter = new AudioEmitter();
            audioEmitter.Forward = new Vector3(1, 0, 0);
        }
开发者ID:debreuil,项目名称:PlayingInTrafficGame,代码行数:14,代码来源:LaneVehicle.cs


示例19: LoadContent

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            soundEffect = this.Content.Load<SoundEffect>("circus");
            instance = soundEffect.CreateInstance();
            instance.IsLooped = true;

            listener = new AudioListener();
            emitter = new AudioEmitter();

            // WARNING!!!!  Apply3D requires sound effect be Mono!  Stereo will throw exception
            instance.Apply3D(listener, emitter);
            instance.Play();
        }
开发者ID:serapth,项目名称:MonoGameBook,代码行数:15,代码来源:Game1.cs


示例20: AudioManager

        public AudioManager(bool soundEnabled, float soundVolume, bool musicEnabled, float musicVolume)
            : base()
        {
            sounds = new Dictionary<string, SoundEffect>();
            songs = new Dictionary<string, Song>();

            listener = new AudioListener();
            listener.Forward = Vector3.Forward;
            listener.Up = Vector3.Up;

            SoundEnabled = soundEnabled;
            SoundVolume = soundVolume;
            MusicEnabled = musicEnabled;
            MusicVolume = musicVolume;

            SoundEffect.DistanceScale = 300.0f;
        }
开发者ID:ronforbes,项目名称:omega,代码行数:17,代码来源:AudioManager.cs



注:本文中的Microsoft.Xna.Framework.Audio.AudioListener类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Audio.Cue类代码示例发布时间:2022-05-26
下一篇:
C# Audio.AudioEngine类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap