Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
AudioListener.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 
4 using System;
5 
6 using SiliconStudio.Core.Mathematics;
7 
8 namespace SiliconStudio.Paradox.Audio
9 {
10  /// <summary>
11  /// Represents a 3D audio listener in the audio scene.
12  /// This object, used in combination with an <see cref="AudioEmitter"/>, can simulate 3D audio localization effects for a sound implemention the <see cref="IPositionableSound"/> interface.
13  /// For more details take a look at the <see cref="IPositionableSound.Apply3D"/> function.
14  /// </summary>
15  /// <seealso cref="IPositionableSound.Apply3D"/>
16  /// <seealso cref="AudioEmitter"/>
17  public class AudioListener
18  {
19  /// <summary>
20  /// The position of the listener in the 3D world.
21  /// </summary>
22  public Vector3 Position { get; set; }
23 
24  /// <summary>
25  /// The velocity of the listener in the 3D world.
26  /// </summary>
27  /// <remarks>This is only used to calculate the doppler effect on the sound effect</remarks>
28  public Vector3 Velocity { get; set; }
29 
30  /// <summary>
31  /// Gets or sets the forward orientation vector for this listener. This vector represents the orientation the listener is looking at.
32  /// </summary>
33  /// <remarks>
34  /// <para>By default, this value is (0,0,1).</para>
35  /// <para>The value provided will be normalized if it is not already.</para>
36  /// <para>The values of the Forward and Up vectors must be orthonormal (at right angles to one another).
37  /// Behavior is undefined if these vectors are not orthonormal.</para>
38  /// <para>Doppler and Matrix values between an <see name="AudioEmitter"/> and an <see cref="AudioListener"/> are effected by the listener orientation.</para>
39  /// </remarks>
40  /// <exception cref="InvalidOperationException">The value provided to the set accessor is (0,0,0) or <see cref="Up"/>.</exception>
41  public Vector3 Forward
42  {
43  get
44  {
45  return forward;
46  }
47  set
48  {
49  if(value == Vector3.Zero)
50  throw new InvalidOperationException("The value of the Forward vector can not be (0,0,0)");
51 
52  forward = Vector3.Normalize(value);
53  }
54  }
55  private Vector3 forward ;
56 
57  /// <summary>
58  /// Gets or sets the Up orientation vector for this listener. This vector up of the world for the listener.
59  /// </summary>
60  /// <remarks>
61  /// <para>By default, this value is (0,1,0).</para>
62  /// <para>The value provided will be normalized if it is not already.</para>
63  /// <para>The values of the Forward and Up vectors must be orthonormal (at right angles to one another).
64  /// Behavior is undefined if these vectors are not orthonormal.</para>
65  /// <para>Doppler and Matrix values between an <see name="AudioEmitter"/> and an <see cref="AudioListener"/> are effected by the listener orientation.</para>
66  /// </remarks>
67  /// <exception cref="InvalidOperationException">The value provided to the set accessor is (0,0,0).</exception>
68  public Vector3 Up
69  {
70  get
71  {
72  return up;
73  }
74  set
75  {
76  if (value == Vector3.Zero)
77  throw new InvalidOperationException("The value of the Up vector can not be (0,0,0)");
78 
79  up = Vector3.Normalize(value);
80  }
81  }
82 
83  private Vector3 up;
84 
85  /// <summary>
86  /// Create a new instance of AudioListener
87  /// </summary>
88  public AudioListener()
89  {
90  Forward = new Vector3(0,0,1);
91  Up = new Vector3(0,1,0);
92  }
93  }
94 }
Represents a 3D audio listener in the audio scene. This object, used in combination with an AudioEmit...
Represents a three dimensional mathematical vector.
Definition: Vector3.cs:42
static readonly Vector3 Zero
A SiliconStudio.Core.Mathematics.Vector3 with all of its components set to zero.
Definition: Vector3.cs:52
SiliconStudio.Core.Mathematics.Vector3 Vector3
AudioListener()
Create a new instance of AudioListener