Ogre Tutorial 2: Sound with OpenAL

This tutorial describes how to add sound to your Ogre project using OpenAL. It is assumed that you have the Ogre Tutorial 1: Creating a sample application working.

  • Install OpenAL on your system (already installed on DJCO computers) (you might also need these libraries)
  • Add OpenAL to your project properties
    • In C++ → General → Additional Include Directories, add the OpenAl include directory
    • In Linker → General → Additional Include Directories, add the OpenAl lib directory
    • In Linker → Input → Additional Dependencies, add OpenAL32.lib and alut.lib
  • Copy the alut.dll file from OpenAL to the directory where your executable will be (or make sure alut.dll's directory is in the PATH)
  • Get the code for the SoundManager class here and add the files to your project.
  • In your GameApplication
    • Include SoundManager.h
    • Create member pointer to a SoundManager instance.
	SoundManager * soundMgr;
  • Create a setupSound method to set up sound and play a sample, looping
	void setupSound()
	{
		soundMgr = SoundManager::createManager();
 
		std::cout << soundMgr->listAvailableDevices();
 
		soundMgr->init();
		soundMgr->setAudioPath( (char*) ".\\" );
 
                // Just for testing
		unsigned int audioId;
		soundMgr->loadAudio( "Explosion.wav", &audioId, true);
                soundMgr->playAudio( audioId, false );
	}
  • Call setupSound in the createScene method
  • Place a .wav file called “Explosion.wav” on the same folder as your executable

If you compile and run your project at this point, you should have your sound playing in a loop. If you run into any problems, check that you followed correctly the steps referred above.