Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is it possible to implement music/SFX in game made using JMonkey? If yes, how did you do it? What did you use?

share|improve this question
2  
jmonkeyengine.org/wiki/doku.php/… Is that what you are looking for? –  Noctrine Mar 25 '11 at 17:13

1 Answer 1

http://jmonkeyengine.org/wiki/doku.php/jme3:beginner:hello_audio

Admittedly I don't have a ton of experience with JMonkey, however this page seems to have enough information to explain the system.

From what I can read, JMonkey's audio system uses a listener/source system. Regardless, it seems simple enough to implement and should be a fairly trivial task.

Edit: After reading the article, I'll try to explain it more here:

Each sound uses an instance of AudioNode, created like this:

AudioNode nodey;

To load the sounds themselves, simply create a new instance like so:

nodey = new AudioNode(assetManager, "a-file.wav", false);

The true/false sets if the sound will be streamed or not. For long sounds (think things like in-game Music,) this should be set to true, however shorter sounds, this should not be streamed.

Once you load the sound, you can then attach to the root node, and then either play it using play() or playInstance():

rootNode.attachChild(nodey);
/** Repeat playing if sound is ambient (Waterfall, wind etc.) [Note: nodey.setLooping(true) should be called before adding to the root node if the sound will loop] */
nodey.play();
/** Play as instance (Footstep, Gunshot, etc.) */
nodey.playInstance();

For playback, a "listener" object must be created, and said "listeners" proprieties should be updated as the camera moves.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.