Time for action – positional audio

We create a looping positional audio node, and attach it to a parent node that is positioned at the origin.

The following sample code introduces you to a simple case of positional audio.

  1. Make a copy of Main.java and name the class PositionalSound.java. Remember to also refactor the first line of the main() method to PositionalSoundapp = new PositionalSound();.
  2. Copy the provided file Sounds/Environment/River.ogg into your project's Sounds/Environment/ directory.
  3. In the simpleInitApp() method, attach some filler content (a node and a cube geometry) to the scene graph so you have a point of reference:
    public void simpleInitApp() { // Create a node for the object the sound belongs to Node riverbedNode = new Node("Riverbed"); ...

Get jMonkeyEngine 3.0 Beginner's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.