add docs about 3D audio
continuous-integration/drone/push Build is passing Details

main
cosmonaut 2021-03-17 12:33:37 -07:00
parent 18c02a5173
commit d66c492229
1 changed files with 22 additions and 0 deletions

View File

@ -46,3 +46,25 @@ jumpSoundEffectInstance.Pitch = -0.25f;
jumpSoundEffectInstance.Pan = -0.5f;
jumpSoundEffectInstance.Play();
```
### 3D Audio
MoonWorks has support for 3-dimensional audio.
To use it, you must create an AudioListener, and any sounds that are emitted in 3-dimensional space should use an AudioEmitter.
Emitters and listeners use position, orientation, and velocity to determine audio playback.
Then you can call `Apply3D` on a sound effect instance and provide the emitter and listener.
```cs
var audioEmitter = new AudioEmitter(AudioDevice);
var audioListener = new AudioListener(AudioDevice);
audioEmitter.Position = thingPosition;
audioEmitter.Forward = thingForward;
audioEmitter.Up = thingUp;
audioListener.Position = cameraPosition;
audioListener.Forward = cameraForward;
audioListener.Up = cameraUp;
thingSound.Apply3D(audioListener, audioEmitter);
```