0
0

Hello everybody. I am currently working on a project for school to demonstrate 3D sound and I’m having trouble incorporating movement for my sounds. I know that calling set3Dattributes will set the position/velocity for the sound but I am unsure if just calling update for the FMOD::System object will automatically adjust this based on the velocity it was given or do I need to call set3Dattributes() every time I update fmod as well. I have 3D sound working fine if the object stays still so I’m not really sure if I’m doing something wrong or if I’m just missing a step. Any help would be appreciates thanks!! ๐Ÿ˜€

  • You must to post comments
0
0

Since you question relates to the EventSystem it’s probably more suited to the FMOD Designer section of the forum, but I can see why you chose to post it here.

[quote:233qjin2]And yes. I do call eventSystem->Update() every frame with correct parameters for set3DListenerAttributes().[/quote:233qjin2]
Damn, that was the first thing i was going to ask.

You should [i:233qjin2]not[/i:233qjin2] be calling event start every frame. Is it possible that the event is getting stolen by another instance and calling start() every frame is masking the problem? Try increasing the ‘Max playbacks’ property for the event.

  • You must to post comments
0
0

If i understand it correctly, then events can be stolen only if the same event is requested and not the other. Right? For example if i have max. playbacks for "wind" sound event set to 10 and requested all of them, and then request "shoot" sound event, this won’t steal one of "wind" events. Correct? I’m asking because i’m not completely sure about this. But max. playbacks was already set to 200 (just for testing).
I’ll try to clarify one thing. The "fly" event IS playing but it’s positions are not altered. So it plays at it’s first set position.

  • You must to post comments
0
0

[quote="RS543":fv1w3bqf]Hello everybody. I am currently working on a project for school to demonstrate 3D sound and I’m having trouble incorporating movement for my sounds. I know that calling set3Dattributes will set the position/velocity for the sound but I am unsure if just calling update for the FMOD::System object will automatically adjust this based on the velocity it was given or do I need to call set3Dattributes() every time I update fmod as well. I have 3D sound working fine if the object stays still so I’m not really sure if I’m doing something wrong or if I’m just missing a step. Any help would be appreciates thanks!! :D[/quote:fv1w3bqf]

it’s a little tricky. Here is the set of functions that handle listener movement and channel movement in my wrapper dll

This sets the world scale… 1 = 1 meter per unit
[code:fv1w3bqf]
float worldscale = 1;
export double FMODSetWorldScale(double scale)
{

//FMODASSERT(FMOD_System_Set3DSettings(mainsystem, 1,scale,1));
worldscale = scale;
return (double) 1;

}
[/code:fv1w3bqf]

This adjusts the setup based on your frames per second
[code:fv1w3bqf]
float deltatime = 0;
export double FMODSetDopplerFPS(double fps)
{
if(!inited) {{FMODASSERT(FMOD_ERR_INITIALIZATION);}}
deltatime = 0;
if(fps==0) return (double) 1;
deltatime = 1/fps * 1000;
deltatime = 1000/deltatime;
return (double) 1;
}
[/code:fv1w3bqf]

This sets the listener position and calculates velocity from the previous position
[code:fv1w3bqf]
export double FMODListenerSet3dPosition(double number, double x, double y, double z)
{
if(number <1 || number > 4) {{FMODASSERT(FMOD_ERR_INVALID_PARAM);}}
FMOD_VECTOR pos = {0,0,0};

FMOD_VECTOR forward        = { 0.0f, 0.0f, -1.0f };
FMOD_VECTOR up             = { 0.0f, -1.0f, 0.0f };
if(distanceonly[(int)number-1]) up.y = 0;
FMOD_VECTOR vel = {  0.0f, 0.0f, 0.0f };
if(deltatime)
{
    FMODASSERT(FMOD_System_Get3DListenerAttributes(mainsystem,(int)number-1,&amp;pos,0,0,0));
    vel.x = (x-pos.x)*worldscale * deltatime;
    vel.y = (y-pos.y)*worldscale * deltatime;
    vel.z = (z-pos.z)*worldscale * deltatime;
}
pos.x = x;//* worldscale;
pos.y = y;//* worldscale;
pos.z = z;//* worldscale;

FMODASSERT(FMOD_System_Set3DListenerAttributes(mainsystem, (int)number-1,&amp;pos,&amp;vel,&amp;forward,&amp;up));
return (double) 1;

}
[/code:fv1w3bqf]

Same deal as listener but for a channel
[code:fv1w3bqf]
export double FMODInstanceSet3dPosition(double channel,double x,double y,double z)
{
if(!inited) {{FMODASSERT(FMOD_ERR_INITIALIZATION);}}
if(!(channel>0)){{FMODASSERT(FMOD_ERR_INVALID_HANDLE);}}
FMOD_VECTOR pos = {0,0,0};

FMOD_VECTOR vel = {  0.0f, 0.0f, 0.0f };
if(deltatime)
{
    FMODASSERT(FMOD_Channel_Get3DAttributes((FMOD_CHANNEL*)(DWORD)channel,&amp;pos,0));
    vel.x = (x-pos.x)*worldscale * deltatime;
    vel.y = (y-pos.y)*worldscale * deltatime;
    vel.z = (z-pos.z)*worldscale * deltatime;
}
pos.x = x;//* worldscale;
pos.y = y;//* worldscale;
pos.z = z;//* worldscale;
FMODASSERT(FMOD_Channel_Set3DAttributes((FMOD_CHANNEL*)(DWORD)channel,&amp;pos,&amp;vel));

return (double) 1;

}
[/code:fv1w3bqf]

So, when your games starts, you set the scale and the fps.
You set listener position and set channel (instance in my wrapper) position every step
You call System update and the sounds should now play according to position and velocity.

deltatime 0 means no doppler effect
watch my reference to the listener id (I use a 1-4 value)
My wrapper is for a game engine that only allows doubles for external function, so ignore that…
And I used the c api, you should not have any trouble grabing what you need and converting it the c++ if you need.
Hope this helps

  • You must to post comments
0
0

That’s the most common way for stealing to occur, but there are others as well. There is also channel stealing based on priority/audibility in that order so it could be related to that.

[quote:1zkojf38]The "fly" event IS playing but it’s positions are not altered. So it plays at it’s first set position.[/quote:1zkojf38]
If the event is audible but just not getting positioned correctly then the problem isn’t stealing. Can you confirm that set3DAttributes is returning FMOD_OK? It sounds like you have an invalid handle.

  • You must to post comments
0
0

Thanks I really appreciate the help. I implemented all that stuff and it works fine but then I found my problem I think. Everytime I call get3Dattributes() on my channel the position is always set to 0. I double checked to make sure I wasn’t calling set3Dattributes() somewhere else and I’m not so I’m clueless as to why its always 0. Any ideas? ๐Ÿ˜ฎ

  • You must to post comments
0
0

Oopss…. ๐Ÿ˜ณ
Terribly sorry for missleading info. Apparently our sound designer already corrected this issue in FMOD Designer. Don’t know what he changed, but i wasn’t informed of this. Seems that sound was to short to hear that position is updated. Perhaps he just looped the sound and it worked like a charm!
Thank you for helping! And sorry again… ๐Ÿ˜ณ

  • You must to post comments
0
0

It sounds like you don’t have a valid channel handle, are you checking the FMOD_RESULT that is being returned?

[quote:2j0hkao3]do I need to call set3Dattributes() every time I update fmod[/quote:2j0hkao3]
Yes, you need to update the position of 3D channels every frame. The velocity value is used for the doppler effect and is not needed for 3D positioning.

-Pete

  • You must to post comments
0
0

Not a problem. Just glad to hear it is resolved. :)

  • You must to post comments
0
0

yep I totally was….the one thing I didn’t error check!! Totally pointed me in the right direction so my problem is fixed thanks! ๐Ÿ˜›

  • You must to post comments
0
0

Glad to hear that you got it working.

  • You must to post comments
0
0

@icuurd12b42

your velocity calculation looks wrong:

[code:1dxkub0g]vel.x = (x-pos.x)*worldscale * deltatime; [/code:1dxkub0g]

shouldn’t you be dividing the distance by the time taken?

  • You must to post comments
0
0

Also the worldscale is handled internally so it isn’t needed in the velocity calculation. It’s also worth noting that the primary danger with auto-calculating the velocity is that if something teleports, there will be an audio glitch caused by the extremely large velocity. It’s good practice to sanity check the magnitude of the velocity before passing it into FMOD.

  • You must to post comments
0
0

yeah, you guys may be right. I wrote this a while ago. I’m not sure if the vector is right… It sounds right or close enough possibly. I never notice the sounds not doppler properly, except yes, if you make a huge jump. Not sure if it’s worth taking a second go at it though… your thoughts?

  • You must to post comments
0
0

Sorry for hijacking this thread, but my question is somehow related to this problem and i thought it’s better not to spawn another one.
So here is the problem.
In our project we have a cannon that shoots a roundball. What we want is this roundball to produce some sort of a flying sound. So when it passes the camera, it could be heard.
Seting positions and velocities with orientations is not a problem. What i realy don’t understand is should i call event->start() every frame for my "fly sound" or just once? I update position and velocity every frame. But if i call event-start() only once, they don’t get updated. So i’m calling it every frame, but i’m not sure if this is the right way to do it.
And yes. I do call eventSystem->Update() every frame with correct parameters for set3DListenerAttributes().

  • You must to post comments
Showing 14 results
Your Answer

Please first to submit.