update audio docs
continuous-integration/drone/push Build is passing Details

main
cosmonaut 2022-04-07 14:21:40 -07:00
parent 7e5969da33
commit 11ad6cf812
1 changed files with 7 additions and 3 deletions

View File

@ -6,7 +6,7 @@ weight: 4
MoonWorks.Audio is implemented using the [FAudio](https://github.com/FNA-XNA/FAudio) library. The main entry point for audio-related functions is `AudioDevice`. A reference to this class is automatically created and can be retrieved from your `Game` subclass. MoonWorks.Audio is implemented using the [FAudio](https://github.com/FNA-XNA/FAudio) library. The main entry point for audio-related functions is `AudioDevice`. A reference to this class is automatically created and can be retrieved from your `Game` subclass.
There are two main kinds of audio content: static and streaming. MoonWorks supports only Ogg Vorbis files by default, but you can support whatever kind of audio file you want by providing a custom decoder of your choice. There are two main kinds of audio content: static and streaming. MoonWorks supports WAV and Ogg Vorbis files by default, but you can support whatever kind of audio file you want by providing a custom decoder of your choice.
### Static Audio ### Static Audio
@ -17,17 +17,19 @@ The trade-off is that static audio takes a lot more memory than streaming audio,
To load and play a static sound, you would do something like this: To load and play a static sound, you would do something like this:
```cs ```cs
var jumpSoundEffect = StaticSound.LoadOgg(AudioDevice, "jump.ogg"); var jumpSoundEffect = StaticSound.LoadWav(AudioDevice, "jump.wav");
var jumpSoundEffectInstance = jumpSoundEffect.CreateInstance(); var jumpSoundEffectInstance = jumpSoundEffect.CreateInstance();
jumpSoundEffectInstance.Play(); jumpSoundEffectInstance.Play();
``` ```
Static audio can be loaded from a WAV or Ogg Vorbis file.
### Streaming Audio ### Streaming Audio
Streaming audio is streamed from file storage over its duration, and only a small portion of the audio is stored in memory while it is played. This kind of audio is ideal for recorded dialogue and music. Streaming audio is streamed from file storage over its duration, and only a small portion of the audio is stored in memory while it is played. This kind of audio is ideal for recorded dialogue and music.
The trade-off here is that streaming audio needs to be read continuously from storage, which may be slow. If you stream too much audio at once you may notice audio stuttering. The trade-off here is that streaming audio needs to be read continuously and decoded from memory, which may be slow. If you stream too much audio at once you may notice audio stuttering.
To load and play streaming sound, you would do something like this: To load and play streaming sound, you would do something like this:
@ -36,6 +38,8 @@ var music = StreamingSoundOgg.Load(AudioDevice, "my_music.ogg");
music.Play(); music.Play();
``` ```
By default MoonWorks only provides Ogg Vorbis streaming, if you want to stream other kinds of audio you will need to hook up a decoder function.
### Effects ### Effects
MoonWorks.Audio sound playback can be modified with several effects, such as panning, reverb, pass filters, and more. To apply these effects, simply set the relevant properties on the sound instance. MoonWorks.Audio sound playback can be modified with several effects, such as panning, reverb, pass filters, and more. To apply these effects, simply set the relevant properties on the sound instance.