Positional audio in FMOD
Using positional audio in FMOD is not too different from what we have done so far. In fact, we have already used all the classes required for positional audio on the previous chapters; the FMOD::Channel
class already works as an audio source, while the FMOD::System
class controls all the audio listeners in the scene. Let us break down the entire process into steps.
Creating an audio source
The first point that we have to remember is to create our sounds using the FMOD_3D
flag; otherwise, the 3D audio engine will not process them:
system->createSound("explosion.wav", FMOD_3D, 0, &sound);
Then we simply need to play the sounds as usual, storing a reference to the channel handle so that we can modify the 3D properties of the sound.
Setting the audio source's position and velocity
Once we play the sound and get back a channel handle, we can use it to set the position and velocity of the audio source with the set3DAttributes
method:
FMOD_VECTOR position = { 3.0f, 4.0f...