Esempio n. 1
0
        /// <summary>
        /// Positions a sound in 3-D space
        /// </summary>
        /// <param name="sound">The ExtendedAudioBuffer to play.</param>
        /// <param name="stop">If true, will stop the sound and return its position to 0 before playing it. Passing false will have the effect of resuming the sound from the last position it was stopped at.</param>
        /// <param name="loop">Whether or not to loop the sound.</param>
        /// <param name="x">The x coordinate of the source.</param>
        /// <param name="y">The y coordinate of the source.</param>
        /// <param name="z">The z coordinate of the source.</param>
        /// <param name="vx">The x component of the velocity vector.</param>
        /// <param name="vy">The y component of the velocity  vector.</param>
        /// <param name="vz">The z component of the velocity vector.</param>
        /// <param name="flags">The 3D flags to calculate. The default will calculate volume and doppler shift. This parameter is useful if it is not desirable for XAudio2 to calculate doppler on sounds that modify their own frequencies as an example; in this case, the flags should omit doppler.</param>
        public static void PlaySound3d(ExtendedAudioBuffer sound, bool stop, bool loop, float x, float y, float z, float vx = 0, float vy = 0, float vz = 0, CalculateFlags flags = CalculateFlags.Matrix | CalculateFlags.Doppler)
        {
            Emitter emitter = new Emitter {
                ChannelCount        = 1,
                CurveDistanceScaler = 1.0f,
                OrientFront         = new Vector3(0, 0, 1),
                OrientTop           = new Vector3(0, 1, 0),
                Position            = new Vector3(x, y, z),
                Velocity            = new Vector3(vx, vy, vz)
            };

            sound.play(stop, loop);
            DspSettings dspSettings = x3DAudio.Calculate(listener, emitter, flags, sound.getVoiceDetails().InputChannelCount, mainMasteringVoice.VoiceDetails.InputChannelCount);

            sound.apply3D(dspSettings, sound.getVoiceDetails().InputChannelCount, mainMasteringVoice.VoiceDetails.InputChannelCount, flags);
        }
Esempio n. 2
0
 /// <summary>
 /// Plays a sound.
 /// </summary>
 /// <param name="sound">The ExtendedAudioBuffer to play.</param>
 /// <param name="stop">If true, will stop the sound and return its position to 0 before playing it. Passing false will have the effect of resuming the sound from the last position it was stopped at.</param>
 /// <param name="loop">Whether or not to loop the sound.</param>
 public static void PlaySound(ExtendedAudioBuffer sound, bool stop, bool loop)
 {
     sound.play(stop, loop);
 }