Examples » Audio

Shows how to play spatialized audio with Magnum.

Image

The audio scene includes a 3D sound source and a (default) listener, which are visualized as a sphere and a box respectively, the listener initially facing the sound source. The sound source can be moved around the listener using the keyboard.

Key controls

  • Right / Left — rotate source on the Y axis
  • Up / Down — rotate source on the local X axis
  • Page Up / Page Down — move the source away/towards the listener

Credits

This example was originally contributed by Jonathan Hale. The sound file used is a Chimes Sound Effect from http://www.orangefreesounds.com/chimes-sound-effect/ , licensed under Creative Commons Attribution 4.0 International License. This example makes use of the OpenAL library, see the Audio library documentation for license information.

Source

Full source code is linked below and together with assets also available in the magnum-examples GitHub repository. This example depends on the Audio library and the StbVorbisAudioImporter plugin which is not a part of the core Magnum repository, see their documentation for usage instructions.

The ports branch contains additional patches for Emscripten support that aren't present in master in order to keep the example code as simple as possible.