3 #if SILICONSTUDIO_PLATFORM_IOS
6 using SiliconStudio.Core.Mathematics;
7 using SiliconStudio.Paradox.Audio.Wave;
9 namespace SiliconStudio.
Paradox.Audio
11 public partial class SoundEffectInstance
13 internal AudioVoice AudioVoice;
15 internal override void UpdateLooping()
17 AudioVoice.SetLoopingPoints(0, int.MaxValue, 0, IsLooped);
25 if (theoricPlayState !=
SoundPlayState.Stopped && AudioVoice.DidVoicePlaybackEnd())
28 DataBufferLoaded =
false;
29 PlayState = SoundPlayState.Stopped;
32 return theoricPlayState;
34 internal set { theoricPlayState = value; }
37 internal override void PlayImpl()
42 internal override void PauseImpl()
47 internal override void StopImpl()
52 internal override void ExitLoopImpl()
54 AudioVoice.SetLoopingPoints(0, int.MaxValue, 0,
false);
57 private void CreateVoice(WaveFormat waveFormat)
59 AudioVoice =
new AudioVoice(AudioEngine,
this, waveFormat);
62 internal override void LoadBuffer()
64 AudioVoice.SetAudioData(soundEffect);
67 private void PlatformSpecificDisposeImpl()
72 private void UpdatePitch()
78 private void Apply3DImpl(AudioListener listener, AudioEmitter emitter)
80 var vectDirWorldBase = emitter.Position - listener.Position;
81 var baseChangeMat = Matrix.Identity;
82 baseChangeMat.Row2 =
new Vector4(listener.Up, 0);
83 baseChangeMat.Row3 =
new Vector4(listener.Forward, 0);
84 baseChangeMat.Row1 =
new Vector4(
Vector3.Cross(listener.Up, listener.Forward), 0);
86 var vectDirListBase = Vector3.TransformNormal(vectDirWorldBase, baseChangeMat);
87 var azimut = 180f * (float)(Math.Atan2(vectDirListBase.X, vectDirListBase.Z)/Math.PI);
88 var elevation = 180f * (float)(Math.Atan2(vectDirListBase.Y,
new Vector2(vectDirListBase.X, vectDirListBase.Z).Length())/Math.PI);
89 var distance = vectDirListBase.Length();
91 ComputeDopplerFactor(listener,emitter);
93 AudioVoice.Apply3D(azimut, elevation, distance / emitter.DistanceScale, MathUtil.Clamp((float)Math.Pow(2, Pitch) * dopplerPitchFactor, 0.5f, 2f));
96 private void UpdateStereoVolumes()
101 private void Reset3DImpl()
103 AudioVoice.Reset3D();
106 internal override void UpdateVolume()
108 AudioVoice.SetVolume(
Volume);
111 private void UpdatePan()
113 AudioVoice.SetPan(Pan);
SiliconStudio.Paradox.Games.Mathematics.Vector2 Vector2
SoundPlayState
Current state (playing, paused, or stopped) of a sound implementing the IPlayableSound interface...
SiliconStudio.Core.Mathematics.Vector3 Vector3