Exemple #1
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		void InputDevice_KeyDown(object sender, InputDevice.KeyEventArgs e)
		{
			if (e.Key == Keys.F1) {
				//DevCon.Show( this );
			}

			if (e.Key == Keys.F2) {
				Parameters.ToggleVSync();
			}

			if (e.Key == Keys.F5) {
				Reload();
			}

			if (e.Key == Keys.F12) {
				GraphicsDevice.Screenshot();
			}

			if (e.Key == Keys.Escape) {
				Exit();
			}

			if (e.Key==Keys.P) {
				if (soundInstance==null) {
					Log.Message("Play sound");
					soundInstance	=	soundEffect.CreateInstance();
					soundInstance.Apply3D( listener, emitter );
					soundInstance.IsLooped	=	true;
					soundInstance.Play();
				} else {
					soundInstance.Play();
				}
			}
			if (e.Key==Keys.I && soundInstance!=null) {
				soundInstance.Stop(false);
			}
			if (e.Key==Keys.O && soundInstance!=null) {
				var state = soundInstance.State;

				if (state==SoundState.Paused) {
					soundInstance.Resume();
				}
				if (state==SoundState.Playing) {
					soundInstance.Pause();
				}
			}
			if (e.Key==Keys.U && soundInstance!=null) {
				soundInstance.Stop(true);
			}

			if (e.Key==Keys.B) {
				soundEffectBite.Play();
			}
		}
Exemple #2
0
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
        public SoundEffectInstance CreateInstance()
        {
            SourceVoice voice = null;
            if (device.Device != null) {
                voice = new SourceVoice(device.Device, _format, VoiceFlags.UseFilter, XAudio2.MaximumFrequencyRatio);
			}

            var instance = new SoundEffectInstance(device, this, voice);
            return instance;
        }