Audio examples
The engine's audio examples: what each one shows, whether it runs in a browser and the command that runs it.
Playing sounds and music, controlling playback, and spatial audio. There are 8 examples on this page. For the concepts behind them, see Audio.
Run any of them from the engine core's workspace (the folder of the engine source that holds the neo crate's Cargo.toml); see Run an example.
Examples#
| Example | What it shows | Web | Run |
|---|---|---|---|
| Audio | Shows how to load and play an audio file | Yes | cargo run --example audio |
| Audio Control | Shows how to load and play an audio file, and control how it's played | Yes | cargo run --example audio_control |
| Decodable | Shows how to create and register a custom audio source by implementing the Decodable type. | Yes | cargo run --example decodable |
| Pitch | Shows how to directly play a simple pitch | Yes | cargo run --example pitch |
| Play Sound Effect | Shows how to play a sound effect in response to an event | Yes | cargo run --example play_sound_effect |
| Soundtrack | Shows how to play different soundtracks based on game state | Yes | cargo run --example soundtrack |
| Spatial Audio 2D | Shows how to play spatial audio, and moving the emitter in 2D | Yes | cargo run --example spatial_audio_2d |
| Spatial Audio 3D | Shows how to play spatial audio, and moving the emitter in 3D | Yes | cargo run --example spatial_audio_3d |