Preparations:
1. Write an ogre program that can run correctly. The simpler the program, the better. I use baseapplication.
2. download and install the fmod sound engine. The downloaded version is fmod ex programmers API and the current stable version is 4.38.01.
3. Download The soundmanager example that combines ogre and fmod on the official website.
4. add files to the program, such as D: \ Program Files \ fmod soundsystem \ fmod programmers api windows \ API, fmod in the fmod installation path. h, fmod. HPP, fmod_codec.h, fmod_dsp.h, fmod_erros.h, fmod_memoryinfo.h, fmod_output.h. The examples include soundmanager. h and soundmanager. cpp. You can put these files in a specified folder, such as fmod, and then include the folder path.
5. Put fmodex_vc.lib in the project Lib folder and in the Lib folder under the fmod installation path. After adding the file, add the file in the project properties → configuration → linker → input column.
6. Add the corresponding link library fmodex. dll and fmodexl. DLL to the ogre target file to generate the folder release.
7. Open the resource. cfg file and add the folder where the sound file is located, such as filesystem = ../Media/sound.
8. The soundmanager example is written earlier and functions are updated, as shown in figure
result = system->setFileSystem(&fmodFileOpenCallback, &fmodFileCloseCallback, &fmodFileReadCallback, &fmodFileSeekCallback, 2048);
In the old version, five parameters are received, and an error occurs during compilation. You can modify the parameters to the following according to the new function definition in fmod. HPP:
result = system->setFileSystem(&fmodFileOpenCallback, &fmodFileCloseCallback, &fmodFileReadCallback, &fmodFileSeekCallback, &fmodFileAsyncReadCallback, &fmodFileAsyncCancelCallback, 2048);
Refer to the function declaration in fmod. h file and add the function definition in soundmanager. cpp, as shown below:
FMOD_RESULT SoundManager::fmodFileAsyncReadCallback(FMOD_ASYNCREADINFO *info, void *userdata){ return FMOD_OK;}FMOD_RESULT SoundManager::fmodFileAsyncCancelCallback(void *handle, void *userdata){ return FMOD_OK;}
In this example, the node location function is
node->getWorldPosition();
In ogre 1.7, functions are defined
node->getPosition();
The above is the necessary preparation work, and there should be no errors during compilation. The next article will introduce an example for use.
This article is a reference to the Sina Blog of guihai.
2011-12-18 update:
When modifying the resource folder in step 2, pay attention to the resource group name. The default value is general. Therefore, if you want to add filesystem = ../Media/sound to [general] and add it to the [popular] Name, the file cannot be found.
If there is still no sound, check the ogre. log file. An error message is displayed.