/// <summary> /// Converts to X3DAudio emitter. /// </summary> /// <returns></returns> internal SharpDX.X3DAudio.Emitter ToEmitter() { // Pulling out Vector properties for efficiency. var pos = this.Position; var vel = this.Velocity; var fwd = this.Forward; var up = this.Up; // From MSDN: // X3DAudio uses a left-handed Cartesian coordinate system, // with values on the x-axis increasing from left to right, on the y-axis from bottom to top, // and on the z-axis from near to far. // Azimuths are measured clockwise from a given reference direction. // // From MSDN: // The XNA Framework uses a right-handed coordinate system, // with the positive z-axis pointing toward the observer when the positive x-axis is pointing to the right, // and the positive y-axis is pointing up. // // Programmer Notes: // According to this description the z-axis (forward vector) is inverted between these two coordinate systems. // Therefore, we need to negate the z component of any position/velocity values, and negate any forward vectors. fwd *= -1.0f; pos.Z *= -1.0f; vel.Z *= -1.0f; var emitter = new SharpDX.X3DAudio.Emitter(); emitter.ChannelCount = 1; emitter.Position = SharpDXHelper.Convert(pos); emitter.Velocity = SharpDXHelper.Convert(vel); emitter.OrientFront = SharpDXHelper.Convert(fwd); emitter.OrientTop = SharpDXHelper.Convert(up); emitter.DopplerScaler = DopplerScale; emitter.CurveDistanceScaler = DistanceScale; emitter.VolumeCurve = volumeCurve; return(emitter); }
/// <summary> /// <p>Calculates DSP settings with respect to 3D parameters.</p> /// </summary> /// <param name="instance"><dd> <p>3D audio instance handle. Call <strong><see cref="SharpDX.X3DAudio.X3DAudio.X3DAudioInitialize"/></strong> to get this handle.</p> </dd></param> /// <param name="listenerRef"><dd> <p>Pointer to an <strong><see cref="SharpDX.X3DAudio.Listener"/></strong> representing the point of reception.</p> </dd></param> /// <param name="emitterRef"><dd> <p>Pointer to an <strong><see cref="SharpDX.X3DAudio.Emitter"/></strong> representing the sound source.</p> </dd></param> /// <param name="flags"><dd> <table> <tr><th>Value</th><th>Description</th></tr> <tr><td><see cref="SharpDX.X3DAudio.CalculateFlags.Matrix"/></td><td>Enables matrix coefficient table calculation.?</td></tr> <tr><td><see cref="SharpDX.X3DAudio.CalculateFlags.Delay"/></td><td>Enables delay time array calculation (stereo only).?</td></tr> <tr><td><see cref="SharpDX.X3DAudio.CalculateFlags.LpfDirect"/></td><td>Enables low pass filter (LPF) direct-path coefficient calculation.?</td></tr> <tr><td><see cref="SharpDX.X3DAudio.CalculateFlags.LpfReverb"/></td><td>Enables LPF reverb-path coefficient calculation.?</td></tr> <tr><td><see cref="SharpDX.X3DAudio.CalculateFlags.Reverb"/></td><td>Enables reverb send level calculation.?</td></tr> <tr><td><see cref="SharpDX.X3DAudio.CalculateFlags.Doppler"/></td><td>Enables Doppler shift factor calculation.?</td></tr> <tr><td><see cref="SharpDX.X3DAudio.CalculateFlags.EmitterAngle"/></td><td>Enables emitter-to-listener interior angle calculation.?</td></tr> <tr><td><see cref="SharpDX.X3DAudio.CalculateFlags.ZeroCenter"/></td><td>Fills the center channel with silence. This flag allows you to keep a 6-channel matrix so you do not have to remap the channels, but the center channel will be silent. This flag is only valid if you also set <see cref="SharpDX.X3DAudio.CalculateFlags.Matrix"/>.?</td></tr> <tr><td><see cref="SharpDX.X3DAudio.CalculateFlags.RedirectToLfe"/></td><td> Applies an equal mix of all source channels to a low frequency effect (LFE) destination channel. It only applies to matrix calculations with a source that does not have an LFE channel and a destination that does have an LFE channel. This flag is only valid if you also set <see cref="SharpDX.X3DAudio.CalculateFlags.Matrix"/>.?</td></tr> </table> <p>?</p> </dd></param> /// <param name="dSPSettingsRef"><dd> <p>Pointer to an <strong><see cref="SharpDX.X3DAudio.DspSettings"/></strong> structure that receives the calculation results.</p> </dd></param> /// <remarks> /// <p>You typically call <strong><see cref="SharpDX.X3DAudio.X3DAudio.X3DAudioCalculate"/></strong> once for each pair of emitting objects and listeners in the scene. After each call, to apply the 3D effects, the app manually applies the calculation results at <em>pDSPSettings</em> to the XAUDIO2 graph. For more info, see How to: Integrate X3DAudio with XAudio2.</p><p><strong>Important</strong>?? The listener and emitter values must be valid. Floating-point specials (NaN, QNaN, +INF, -INF) can cause the entire audio output to go silent if introduced into a running audio graph.</p> /// </remarks> /// <include file='Documentation\CodeComments.xml' path="/comments/comment[@id='X3DAudioCalculate']/*"/> /// <msdn-id>microsoft.directx_sdk.x3daudio.x3daudiocalculate</msdn-id> /// <unmanaged>void X3DAudioCalculate([In] const X3DAUDIOHANDLE* Instance,[In] const X3DAUDIO_LISTENER* pListener,[In] const X3DAUDIO_EMITTER* pEmitter,[In] X3DAudioCalculateFlags Flags,[In] void* pDSPSettings)</unmanaged> /// <unmanaged-short>X3DAudioCalculate</unmanaged-short> public static void X3DAudioCalculate(ref SharpDX.X3DAudio.X3DAudioHandle instance, SharpDX.X3DAudio.Listener listenerRef, SharpDX.X3DAudio.Emitter emitterRef, SharpDX.X3DAudio.CalculateFlags flags, System.IntPtr dSPSettingsRef) { unsafe { var listenerRef_ = new SharpDX.X3DAudio.Listener.__Native(); listenerRef.__MarshalTo(ref listenerRef_); var emitterRef_ = new SharpDX.X3DAudio.Emitter.__Native(); emitterRef.__MarshalTo(ref emitterRef_); fixed(void *instance_ = &instance) X3DAudioCalculate_(instance_, &listenerRef_, &emitterRef_, unchecked ((int)flags), (void *)dSPSettingsRef); listenerRef.__MarshalFree(ref listenerRef_); emitterRef.__MarshalFree(ref emitterRef_); } }
/// <summary> /// Converts to X3DAudio emitter. /// </summary> /// <returns></returns> internal SharpDX.X3DAudio.Emitter ToEmitter() { // Pulling out Vector properties for efficiency. var pos = this.Position; var vel = this.Velocity; var fwd = this.Forward; var up = this.Up; // From MSDN: // X3DAudio uses a left-handed Cartesian coordinate system, // with values on the x-axis increasing from left to right, on the y-axis from bottom to top, // and on the z-axis from near to far. // Azimuths are measured clockwise from a given reference direction. // // From MSDN: // The XNA Framework uses a right-handed coordinate system, // with the positive z-axis pointing toward the observer when the positive x-axis is pointing to the right, // and the positive y-axis is pointing up. // // Programmer Notes: // According to this description the z-axis (forward vector) is inverted between these two coordinate systems. // Therefore, we need to negate the z component of any position/velocity values, and negate any forward vectors. fwd *= -1.0f; pos.Z *= -1.0f; vel.Z *= -1.0f; var emitter = new SharpDX.X3DAudio.Emitter(); emitter.ChannelCount = 1; emitter.Position = SharpDXHelper.Convert( pos ); emitter.Velocity = SharpDXHelper.Convert( vel ); emitter.OrientFront = SharpDXHelper.Convert( fwd ); emitter.OrientTop = SharpDXHelper.Convert( up ); emitter.DopplerScaler = DopplerScale; emitter.CurveDistanceScaler = DistanceScale; emitter.VolumeCurve = volumeCurve; return emitter; }