567

Adding sound
BackgroundSound example code

  • Load sound data
    MediaContainer myWave = new MediaContainer( "canon.wav" );

  • Create a sound
    BackgroundSound mySound = new BackgroundSound( );
    mySound.setSoundData( myWave );
    mySound.setEnable( true );
    mySound.setInitialGain( 1.0f );
    mySound.setLoop( -1 );  // Loop forever

  • Set the scheduling bounds
    BoundingSphere myBounds = new BoundingSphere(
        new Point3d( ), 1000.0 );
    mySound.setSchedulingBounds( myBounds );