本文整理汇总了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;
}
示例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);
}
示例3: SoundManager
public SoundManager(Game game)
: base(game)
{
_sounds = new List<AudioSound>();
_listener = new AudioListener();
_emitter = new AudioEmitter();
}
示例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);
}
示例5: PlaySound
public Cue PlaySound(string soundName, AudioListener audioListener, AudioEmitter audioEmitter)
{
Cue result = GetCue(soundName);
result.Apply3D(audioListener, audioEmitter);
result.Play();
return result;
}
示例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);
}
示例7: CameraController
public CameraController(Game game, CarActor carActor)
: base(game)
{
this.carActor_ = carActor;
cameraState_ = new LinkedList<CameraState>();
listener_ = new AudioListener();
SetupCamera();
}
示例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();
}
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}