How To Use Irr Klang With Irrlicht

irrKlang is a free 3D sound engine which is also based on the same interfaces as Irrlicht, so integration with Irrlicht is not that difficult. But there is also an irrKlang scene node available now, which makes it even easier.

Just download the scene node source code from ambiera.com: http://www.ambiera.com/download/irrKlangSceneNode.zip

Then, just use code like this to create a irrKlang scene node:

irr::audio::ISoundEngine* soundEngine = irr::audio::createIrrKlangDevice();
IrrlichtDevice* device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480), 16, false);
scene::ISceneManager* smgr = device->getSceneManager();

// .. other code here

CIrrKlangSceneNode* soundNode = 
  new CIrrKlangSceneNode(soundEngine, smgr->getRootSceneNode(), smgr, 666);

  soundNode->setSoundFileName("yourfile.wav");
  soundNode->setMinMaxSoundDistance(30.0f); // influences the distance where the sound can be heard
  soundNode->setRandomMode(1000, 5000); // plays sound multiple times with random interval

  // other modes would be:
  // soundNode->setLoopingStreamMode() 
  // or
  // soundNode->setPlayOnceMode();

  soundNode->drop();

That's it.