Play fmod event sounds in 3D
I have an event called Numbers. In Fmod Designer the event plays different numbers depending on listenerAngle. I want to be able to hear the different sounds when I position this event in a 3D space. This is the code I have at the moment. It only plays one of the numbers in my app. Am I missing something?
FMOD_RESULT result = FMOD_OK;
FMOD_VECTOR listenerpos;
FMOD_VECTOR forward = { 0.0f, 0.0f, 1.0f };
FMOD_VECTO开发者_JAVA百科R up = { 0.0f, 1.0f, 0.0f };
FMOD_VECTOR vel = { 0.0f, 0.0f, 0.0f };
result = group->getEvent("Numbers", FMOD_EVENT_DEFAULT, &event);
ERRCHECK(result);
listenerpos.x = 0.436243;
listenerpos.y = -0.43643;
listenerpos.z = -6;
result = eventSystem->set3DListenerAttributes(0, &listenerpos, &vel, &forward, &up);
ERRCHECK(result);
Help is very much appreciated! Thanks!
Perhaps your "Numbers" event is 2D? Can you check and ensure it's 3D.
I added some lines and got it working. I had to place out the event in the 3D world.
FMOD_RESULT result = FMOD_OK;
FMOD_VECTOR listenerpos = { 0.0f, 0.0f, 1.0f };
FMOD_VECTOR eventpos = { 0.0f, 0.0f, 1.0f };
float DISTANCEFACTOR = 2.0f;
result = group->getEvent("Numbers", FMOD_EVENT_DEFAULT, &event);
ERRCHECK(result);
listenerpos.x = 0;
listenerpos.y = 0;
listenerpos.z = 0;
result = eventSystem->set3DListenerAttributes(0, &listenerpos,NULL,NULL,NULL);
ERRCHECK(result);
eventpos.x = xPos; // Object's x position on iPhone I move around
eventpos.z = yPos;
result = event->set3DAttributes(&eventpos2,&vel);
ERRCHECK(result);
result = eventSystem->update();
ERRCHECK(result);
result = ballEvent->start();
ERRCHECK(result);
精彩评论