/// <summary> /// /// </summary> /// <param name="soundSystem"></param> public SoundWorld ( Game game ) { Game = game; Listener = new AudioListener(); }
/// <summary> /// /// </summary> /// <param name="listener"></param> /// <param name="emitter"></param> public void Apply3D (AudioListener listener, AudioEmitter emitter, int operationSet) { // 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(); // Apply overall Doppler and distance scale : e.DopplerScaler *= device.DopplerScale; e.CurveDistanceScaler *= device.DistanceScale; // 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 = 1;//_effect._format.Channels; // Number of output channels. var dstChannelCount = device.MasterVoice.VoiceDetails.InputChannelCount; var flags = CalculateFlags.Matrix | CalculateFlags.Doppler /*| CalculateFlags.Reverb | CalculateFlags.LpfDirect*/; // XNA supports distance attenuation and doppler. var dspSettings = device.Device3D.Calculate(l, e, flags, srcChannelCount, dstChannelCount); // Apply Volume settings (from distance attenuation) ... _voice.SetOutputMatrix(device.MasterVoice, srcChannelCount, dstChannelCount, dspSettings.MatrixCoefficients, operationSet); // USE: VoiceFlags.UseFilter !!! // _voice.SetFilterParameters( ... ); // Apply Pitch settings (from doppler) ... _voice.SetFrequencyRatio(dspSettings.DopplerFactor, operationSet); }
/// <summary> /// /// </summary> /// <param name="listener"></param> internal void Apply3D ( AudioListener listener, int operationSet ) { if (soundInstance!=null) { soundInstance.Apply3D( listener, this, operationSet ); } }
//public void Apply2D ( int operationSet ) //{ // _voice.SetFrequencyRatio(dspSettings.DopplerFactor, operationSet); //} /// <summary> /// /// </summary> /// <param name="listeners"></param> /// <param name="emitter"></param> public void Apply3D (AudioListener[] listeners,AudioEmitter emitter, int operationSet) { foreach ( var l in listeners ) Apply3D(l, emitter, operationSet); }