0
0

Just fail if quietest is not working correctly if the two sounds doesn’t change position but only the listener does. Sound A is always played and never stolen, sound B never starts, even if I am right next to it (and distance to sound A is greater than distance to sound B)

Version: 4.40.10
MaxPlaybacks = 1
MaxPlaybacksBehavior = just fail if quietest

These were the actual positions of my test map but I get the error also at different positions
Sound A pos: 9527 / 7006 -744
Sound B pos: 9515 / 5662 / -733

When I start the map, the sound that is closer to the camera pos (my listener object) starts and the other is silent (as expected). When I now move to the other sound nothing happens (it is expected to start as soon as I am closer to the other sound than to the original started sound).

In the code I get an INFOONLY event first, set the position and then get the normal event, as the docu and example advices.
[code:2609do8u]
char * name = "...";
FMOD_VECTOR position;
FMOD::Event *event
getEvent(name, FMOD_EVENT_INFOONLY, &event);
event->set3DAttributes(&pos, NULL, NULL)
getEvent(name, FMOD_EVENT_DEFAULT, &event);
[/code:2609do8u]1st getEvent and set3DAttributes return FMOD_OK; 2nd getEvent returns FMOD_ERR_EVENT_FAILED

Now I found a workaround: Adding a very little random float to the positions z variable:
[code:2609do8u]
char * name = ...;
FMOD_VECTOR position = ...;
FMOD::Event *event
getEvent(name, FMOD_EVENT_INFOONLY, &event);

float r = (float)rand() / (float)RAND_MAX / 10.0f;
pos.z += r;

event->set3DAttributes(&pos, NULL, NULL)
getEvent(name, FMOD_EVENT_DEFAULT, &event);
[/code:2609do8u]Everything returns FMOD_OK

It looks like you’re caching the [color=#FF0000:2609do8u][b:2609do8u]position[/b:2609do8u][/color:2609do8u] for your [color=#FF0000:2609do8u][b:2609do8u]distance->volume[/b:2609do8u][/color:2609do8u] calculation instead of the real [color=#FF0000:2609do8u][b:2609do8u]sound-listener distance[/b:2609do8u][/color:2609do8u]; that would be wrong if only the listener but not the sound object moves.

Can you please confirm this as a fmod bug or is there anything wrong at my example I am not aware of?

Best wishes,
…Joerg

  • You must to post comments
0
0

Hi Joerg,
Ok I have tried to reproduce this but am having trouble. I use the ‘3ddemo’ example in the example folder with some modifications.

first lets just use 1 sound instead of 7, we want just the donut in the middle of the spinning platform. Thats event 1.

[code:3t9coltw]
void initObjects()
{
FMOD_RESULT result;

//result = fmodEventGroup->getEvent("3DSoundEmit", FMOD_EVENT_DEFAULT, &objects[0].event);
//ERRCHECK(result);

result = fmodEventGroup->getEvent("3DSoundEmit", FMOD_EVENT_DEFAULT, &objects[1].event);
ERRCHECK(result);

//result = fmodEventGroup->getEvent("3DSoundEmit", FMOD_EVENT_DEFAULT, &objects[2].event);
//ERRCHECK(result);

//result = fmodEventGroup->getEvent("3DSoundEmit", FMOD_EVENT_DEFAULT, &objects[3].event);
//ERRCHECK(result);

//result = fmodEventGroup->getEvent("3DSoundEmit", FMOD_EVENT_DEFAULT, &objects[4].event);
//ERRCHECK(result);

//result = fmodEventGroup->getEvent("3DSoundEmit", FMOD_EVENT_DEFAULT, &objects[5].event);
//ERRCHECK(result);

//result = fmodEventGroup->getEvent("3DSoundEmit", FMOD_EVENT_DEFAULT, &objects[6].event);
//ERRCHECK(result);

[/code:3t9coltw]

Also go to the FDP in designer for the examples, and edit the 3dSoundEmit event, change steal mode to just fail if quietest, and max playbacks = 1.

Next – lets try to reproduce the behaviour. When you hit ‘t’ (for test) it will spawn a new instance right next to the listener.
[code:3t9coltw]
void keyboardFunc(unsigned char key, int x, int y)
...
case ‘t’:
{
FMOD_RESULT result;
FMOD_VECTOR pos = { xListenerPos + 1, yListenerPos, zListenerPos };

        result = fmodEventGroup->getEvent("3DSoundEmit", FMOD_EVENT_INFOONLY, &objects[1].event);
        ERRCHECK(result);

        objects[1].event->set3DAttributes(&pos,0,0);

        result = fmodEventGroup->getEvent("3DSoundEmit", FMOD_EVENT_DEFAULT, &objects[1].event);
        ERRCHECK(result);

        objects[1].event->start();
        break;
    }
}

[/code:3t9coltw]

When I do this, the new instance always plays, and doesn’t fail. Can you show me how you would make it fail?

  • You must to post comments
0
0

Ok, I can provide you a (non)working example. I used the max_playbacks example as base and modified it, here is the complete main.cpp source:

[code:3ugiqbum]/*=============================================================================
Max Playbacks Example
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.

Demonstrates basic usage of event max playbacks behaviour.
=============================================================================*/

include "../../api/inc/fmod_event.hpp"

include "../../api/inc/fmod_errors.h"

include <windows.h>

include <stdio.h>

include <stdlib.h>

include <conio.h>

include <math.h>

const char *MEDIA_PATH = "..\media\";

void ERRCHECK(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
exit(-1);
}
}

FMOD::EventSystem *eventsystem;
FMOD::EventGroup *eventgroup;
FMOD_VECTOR listener = { 2, 0, 0};

FMOD::Event * startEvent(FMOD_VECTOR pos)
{
FMOD_RESULT result;
FMOD::Event *event;

// get the info-only event to set up for volume calculation
ERRCHECK(result = eventsystem-&gt;getEvent(&quot;examples/FeatureDemonstration/MaxPlayback/MaxPlay-JustFailIfQuietest&quot;, FMOD_EVENT_INFOONLY, &amp;event));

// set pos
ERRCHECK(result = event-&gt;set3DAttributes(&amp;pos, 0, 0));

// attempt to get a real event instance
result = eventsystem-&gt;getEvent(&quot;examples/FeatureDemonstration/MaxPlayback/MaxPlay-JustFailIfQuietest&quot;, FMOD_EVENT_DEFAULT, &amp;event);
if (result == FMOD_OK)
{
    printf(&quot;startEvent at pos: %f succeeded   listener: %f   distance: %f\n&quot;, pos.x, listener.x, abs(pos.x - listener.x));

    ERRCHECK(result = event-&gt;start());
    return event;
}
else
{
    printf(&quot;startEvent at pos: %f failed      listener: %f   distance: %f\n&quot;, pos.x, listener.x, abs(pos.x - listener.x));
    return NULL;
}

}

int main(int argc, char *argv[])
{
FMOD_RESULT result;
FMOD::Event *event1;
FMOD::Event *event2;
int key;

FMOD_VECTOR pos1     = {  0, 0, 0};
FMOD_VECTOR pos2     = { 10, 0, 0};
FMOD_VECTOR forward  =  { 0,-1, 0};
FMOD_VECTOR up       =  { 0, 0, 1};

ERRCHECK(result = FMOD::EventSystem_Create(&amp;eventsystem));
ERRCHECK(result = eventsystem-&gt;init(64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL));
ERRCHECK(result = eventsystem-&gt;setMediaPath((char *)MEDIA_PATH));
ERRCHECK(result = eventsystem-&gt;load(&quot;examples.fev&quot;, 0, 0));
ERRCHECK(result = eventsystem-&gt;getGroup(&quot;examples/FeatureDemonstration/MaxPlayback&quot;, FMOD_EVENT_DEFAULT, &amp;eventgroup));
ERRCHECK(result);

printf(&quot;======================================================================\n&quot;);
printf(&quot;Max Playbacks Example.  Copyright (c) Firelight Technologies 2004-2011.\n&quot;);
printf(&quot;----------------------------------------------------------------------\n&quot;);
printf(&quot;Press '1'   start event 1 at {  0, 0, 0}\n&quot;);
printf(&quot;Press '2'   start event 2 at { 10, 0, 0}\n&quot;);
printf(&quot;Press '3'   stop event 1\n&quot;);
printf(&quot;Press '4'   stop event 2\n&quot;);
printf(&quot;Press 's'   to stop all events\n&quot;);
printf(&quot;Press '&gt;'   move cam to +x\n&quot;);
printf(&quot;Press '&lt;'   move cam to -x\n&quot;);
printf(&quot;Press ESC to quit\n&quot;);
printf(&quot;======================================================================\n&quot;);


key = 0;
do
{
    if (_kbhit())
    {
        key = _getch();

        switch(key)
        {
            case '1' : // start event 1 at {  0, 0, 0}

                event1 = startEvent(pos1);
                break;

            case '2' : // start event 2 at { 10, 0, 0}
                event2 = startEvent(pos2);
                break;

            case '3' : // stop event 1
                ERRCHECK(event1-&gt;stop());
                break;

            case '4' : // stop event 2
                ERRCHECK(event2-&gt;stop());
                break;

            case 's' :
                ERRCHECK(eventgroup-&gt;freeEventData());
                break;

            case '&gt;' : case '.' :
                ++listener.x;
                if (listener.x &gt; 9) listener.x = 9;
                break;

            case '&lt;' : case ',' :
                --listener.x;
                if (listener.x &lt; 1) listener.x = 1;
                break;
        }

        eventsystem-&gt;set3DListenerAttributes(0, &amp;listener, NULL, &amp;forward, &amp;up);

        printf(&quot;listener.x: %f   Distance: event1: %f   event2: %f\n&quot;, listener.x, abs(pos1.x - listener.x), abs(pos2.x - listener.x));
    }

    ERRCHECK(result = eventsystem-&gt;update());
    Sleep(10);

} while (key != 27);

ERRCHECK(result = eventsystem-&gt;unload());
ERRCHECK(result = eventsystem-&gt;release());
return 0;

}
[/code:3ugiqbum]

You also have to modify example.fdp: FeatureDemonstration/MaxPlayback/MaxPlay-JustFailIfQuietest
* set Max Playbacks to 1
* Add 3D distance parameter
* set distance parameter properties to min value: 0.0 and max value 10.0
* Add Volume effect (set curve to linear, -0 db at pos 0.0 and -inf db at 10.0)
* Set 3D Rolloff to Custom

Now start the example and reproduce the error:
* key -> expected result -> what really happens
* 2 -> sound (right) starts (not loud) -> ok
* 1 -> sound (left) starts (louder) -> ok
* 2 -> nothing -> ok

  • > -> sound (left) gets quieter -> ok
  • 2 -> nothing

repeat the last two steps until distance to even2 (right) is less than 5
* 2 -> sound (right) should start -> sound (right) doesn’t start

When I try to start event 1 (left) in between it works, therefore my assumption that it has anything to do with you caching volume calculation based on event position instead of event distance…

  • You must to post comments
0
0

thanks for that repro, i’ve found the issue and applied a patch for the next release. It is specific to having a distance parameter in this case.

  • You must to post comments
0
0

Thank you.

  • You must to post comments
0
0

I’ve got this issue on Stable 4.44.14 !

And a workaround described above resolves this issue.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.