0
0

I hear nothing, if the source of a sound is located on the listener’s line of sight. Why it can occur?

[code:3k76iqqz]
initialize()
{
FMOD_RESULT result;

result = FMOD::System_Create(&m_fmodSystem);
if (result != FMOD_OK)
{
return false;
}

unsigned int version;
result = m_fmodSystem->getVersion(&version);
if (result != FMOD_OK)
{
return false;
}

if (version < FMOD_VERSION)
{
return false;
}

FMOD_CAPS caps;
FMOD_SPEAKERMODE speakermode;

m_fmodSystem->getDriverCaps(0, &caps, 0, 0, &speakermode);

m_fmodSystem->setSpeakerMode(speakermode);

char name[256];

m_fmodSystem->getDriverInfo(0, name, 256, 0);

if (strstr(name, "SigmaTel"))
{
m_fmodSystem->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0,0
, FMOD_DSP_RESAMPLER_LINEAR);
}

m_fmodSystem->init(m_numChannel, FMOD_INIT_WASAPI_EXCLUSIVE | FMOD_INIT_3D_RIGHTHANDED
| FMOD_INIT_SOFTWARE_OCCLUSION | FMOD_INIT_SOFTWARE_HRTF, 0);

if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)
{
m_fmodSystem->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);

m_fmodSystem-&gt;init(m_numChannel, FMOD_INIT_NORMAL, 0);

}
[/code:3k76iqqz]

[code:3k76iqqz]
int mode = FMOD_HARDWARE | FMOD_3D_LINEARROLLOFF | FMOD_LOOP_NORMAL | FMOD_3D | FMOD_3D_WORLDRELATIVE;

result = audio->getFMOD()->createSound(name.c_str(), mode, 0, &m_sound);
....
playSound(FMOD_CHANNEL_FREE, &m_sound, true, &m_channel);
[/code:3k76iqqz]

  • You must to post comments
0
0

Where is your main loop the sets the listener’s position and calls system::Update?

And where is the code that sets the channel’s 3d position?

  • You must to post comments
0
0

not sound: posSource 0,0,0
posListener 0,0,-10

enable sound: posSource 5,0,0
posListener 0,0,-10

  • You must to post comments
0
0

not sound:
[code:3bswcg4t]
/*===============================================================================================
3d Example
Copyright (c), Firelight Technologies Pty, Ltd 2004-2008.

This example shows how to basic 3d positioning
===============================================================================================*/

include <windows.h>

include <stdio.h>

include <conio.h>

include <math.h>

include "../../api/inc/fmod.h"

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

define INTERFACE_UPDATETIME 50 // 50ms update for interface

define DISTANCEFACTOR 1.0f // Units per meter. I.e feet would = 3.28. centimeters would = 100.

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

int main(int argc, char *argv[])
{
FMOD_SYSTEM *system;
FMOD_SOUND *sound1, *sound2, *sound3;
FMOD_CHANNEL *channel1 = 0, *channel2 = 0, *channel3 = 0;
FMOD_RESULT result;
int key;
int listenerflag = TRUE;
FMOD_VECTOR listenerpos = { 0.0f, 0.0f, -10.0f * DISTANCEFACTOR };
unsigned int version;
FMOD_SPEAKERMODE speakermode;
FMOD_CAPS caps;
char name[256];

printf(&quot;===============================================================\n&quot;);
printf(&quot;3d Example.  Copyright (c) Firelight Technologies 2004-2008.\n&quot;);
printf(&quot;===============================================================\n&quot;);
printf(&quot;This example plays 2 3D sounds in hardware.  Optionally you can\n&quot;);
printf(&quot;play a 2D hardware sound as well.\n&quot;);
printf(&quot;===============================================================\n\n&quot;);

/*
    Create a System object and initialize.
*/
result = FMOD_System_Create(&amp;system);
ERRCHECK(result);

result = FMOD_System_GetVersion(system, &amp;version);
ERRCHECK(result);

if (version &lt; FMOD_VERSION)
{
    printf(&quot;Error!  You are using an old version of FMOD %08x.  This program requires %08x\n&quot;, version, FMOD_VERSION);
    return 0;
}

result = FMOD_System_GetDriverCaps(system, 0, &amp;caps, 0, 0, &amp;speakermode);
ERRCHECK(result);

result = FMOD_System_SetSpeakerMode(system, speakermode);       /* Set the user selected speaker mode. */
ERRCHECK(result);

if (caps &amp; FMOD_CAPS_HARDWARE_EMULATED)             /* The user has the 'Acceleration' slider set to off!  This is really bad for latency!. */
{                                                   /* You might want to warn the user about this. */
    result = FMOD_System_SetDSPBufferSize(system, 1024, 10);
    ERRCHECK(result);
}

result = FMOD_System_GetDriverInfo(system, 0, name, 256, 0);
ERRCHECK(result);

if (strstr(name, &quot;SigmaTel&quot;))   /* Sigmatel sound devices crackle for some reason if the format is PCM 16bit.  PCM floating point output seems to solve it. */
{
    result = FMOD_System_SetSoftwareFormat(system, 48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0,0, FMOD_DSP_RESAMPLER_LINEAR);
    ERRCHECK(result);
}

result = FMOD_System_Init(system, 100, FMOD_INIT_NORMAL, 0);
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)         /* Ok, the speaker mode selected isn't supported by this soundcard.  Switch it back to stereo... */
{
    result = FMOD_System_SetSpeakerMode(system, FMOD_SPEAKERMODE_STEREO);
    ERRCHECK(result);

    result = FMOD_System_Init(system, 100, FMOD_INIT_NORMAL, 0);/* ... and re-init. */
    ERRCHECK(result);
}

/*
    Set the distance units. (meters/feet etc).
*/
result = FMOD_System_Set3DSettings(system, 1.0, DISTANCEFACTOR, 1.0f);
ERRCHECK(result);

/*
    Load some sounds
*/
result = FMOD_System_CreateSound(system, &quot;../media/drumloop.wav&quot;, FMOD_HARDWARE | FMOD_3D, 0, &amp;sound1);
ERRCHECK(result);
result = FMOD_Sound_Set3DMinMaxDistance(sound1, 2.0f * DISTANCEFACTOR, 10000.0f * DISTANCEFACTOR);
ERRCHECK(result);
result = FMOD_Sound_SetMode(sound1, FMOD_LOOP_NORMAL);
ERRCHECK(result);

result = FMOD_System_CreateSound(system, &quot;../media/jaguar.wav&quot;, FMOD_HARDWARE | FMOD_3D, 0, &amp;sound2);
ERRCHECK(result);
result = FMOD_Sound_Set3DMinMaxDistance(sound2, 2.0f * DISTANCEFACTOR, 10000.0f * DISTANCEFACTOR);
ERRCHECK(result);
result = FMOD_Sound_SetMode(sound2, FMOD_LOOP_NORMAL);
ERRCHECK(result);

result = FMOD_System_CreateSound(system, &quot;../media/swish.wav&quot;, FMOD_HARDWARE | FMOD_2D, 0, &amp;sound3);
ERRCHECK(result);

/*
    Play sounds at certain positions
*/
{
 //   FMOD_VECTOR pos = { -10.0f * DISTANCEFACTOR, 0.0f, 0.0f };
    FMOD_VECTOR pos = { 0.0f, 0.0f, 0.0f };
    FMOD_VECTOR vel = {  0.0f, 0.0f, 0.0f };

    result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &amp;channel1);
    ERRCHECK(result);
    result = FMOD_Channel_Set3DAttributes(channel1, &amp;pos, &amp;vel);
    ERRCHECK(result);
    result = FMOD_Channel_SetPaused(channel1, FALSE);
    ERRCHECK(result);
}

{
    //FMOD_VECTOR pos = { 15.0f * DISTANCEFACTOR, 0.0f, 0.0f };
    FMOD_VECTOR pos = { 0.0f, 0.0f, 0.0f };
    FMOD_VECTOR vel = {  0.0f,  0.0f,  0.0f };

    result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound2, TRUE, &amp;channel2);
    ERRCHECK(result);
    result = FMOD_Channel_Set3DAttributes(channel2, &amp;pos, &amp;vel);
    ERRCHECK(result);
    result = FMOD_Channel_SetPaused(channel2, FALSE);
    ERRCHECK(result);
}

/*
    Display help
*/
{
    int num3d = 0, num2d = 0;

    result = FMOD_System_GetHardwareChannels(system, &amp;num2d, &amp;num3d, 0);
    ERRCHECK(result);

    printf(&quot;Hardware 2D channels : %d\n&quot;, num2d);
    printf(&quot;Hardware 3D channels : %d\n&quot;, num3d);
}

printf(&quot;=========================================================================\n&quot;);
printf(&quot;Press 1        Pause/Unpause 16bit 3D sound at any time\n&quot;);
printf(&quot;      2        Pause/Unpause 8bit 3D sound at any time\n&quot;);
printf(&quot;      3        Play 16bit STEREO 2D sound at any time\n&quot;);
printf(&quot;      &lt;        Move listener left (in still mode)\n&quot;);
printf(&quot;      &gt;        Move listener right (in still mode)\n&quot;);
printf(&quot;      SPACE    Stop/Start listener automatic movement\n&quot;);
printf(&quot;      ESC      Quit\n&quot;);
printf(&quot;=========================================================================\n&quot;);

/*
    Main loop
*/
do
{
    if (kbhit())
    {
        key = getch();

        if (key == '1') 
        {
            int paused;
            FMOD_Channel_GetPaused(channel1, &amp;paused);
            FMOD_Channel_SetPaused(channel1, !paused);
        }

        if (key == '2') 
        {
            int paused;
            FMOD_Channel_GetPaused(channel2, &amp;paused);
            FMOD_Channel_SetPaused(channel2, !paused);
        }

        if (key == '3') 
        {
            result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound3, FALSE, &amp;channel3);
            ERRCHECK(result);
        }

        if (key == ' ')
        {
            listenerflag = !listenerflag;
        }

        if (!listenerflag)
        {
            if (key == '&lt;') 
            {
         /*       listenerpos.x -= 1.0f * DISTANCEFACTOR;
                if (listenerpos.x &lt; -35 * DISTANCEFACTOR)
                {
                    listenerpos.x = -35 * DISTANCEFACTOR;
                }*/
            }
            if (key == '&gt;') 
            {
             /*   listenerpos.x += 1.0f * DISTANCEFACTOR;
                if (listenerpos.x &gt; 36 * DISTANCEFACTOR)
                {
                    listenerpos.x = 36 * DISTANCEFACTOR;
                }*/
            }
        }
    }

    // ==========================================================================================
    // UPDATE THE LISTENER
    // ==========================================================================================
    {
        static float t = 0;
        static FMOD_VECTOR lastpos = { 0.0f, 0.0f, 0.0f };
        FMOD_VECTOR forward        = { 0.0f, 0.0f, 1.0f };
        FMOD_VECTOR up             = { 0.0f, 1.0f, 0.0f };
        FMOD_VECTOR vel;

        if (listenerflag)
        {
            //listenerpos.x = (float)sin(t * 0.05f) * 33.0f * DISTANCEFACTOR; // left right pingpong
        }

        // ********* NOTE ******* READ NEXT COMMENT!!!!!
        // vel = how far we moved last FRAME (m/f), then time compensate it to SECONDS (m/s).
        vel.x = (listenerpos.x - lastpos.x) * (1000 / INTERFACE_UPDATETIME);
        vel.y = (listenerpos.y - lastpos.y) * (1000 / INTERFACE_UPDATETIME);
        vel.z = (listenerpos.z - lastpos.z) * (1000 / INTERFACE_UPDATETIME);

        // store pos for next time
        lastpos = listenerpos;

        result = FMOD_System_Set3DListenerAttributes(system, 0, &amp;listenerpos, &amp;vel, &amp;forward, &amp;up);
        ERRCHECK(result);

        t += (30 * (1.0f / (float)INTERFACE_UPDATETIME));    // t is just a time value .. it increments in 30m/s steps in this example

        // print out a small visual display
        {
            char s[80];

            sprintf(s, &quot;|.......................&lt;1&gt;......................&lt;2&gt;....................|&quot;);

            s[(int)(listenerpos.x / DISTANCEFACTOR) + 35] = 'L';                
            printf(&quot;%s\r&quot;, s);
        }            
    }

    FMOD_System_Update(system);

    Sleep(INTERFACE_UPDATETIME - 1);

} while (key != 27);

printf(&quot;\n&quot;);

/*
    Shut down
*/
result = FMOD_Sound_Release(sound1);
ERRCHECK(result);
result = FMOD_Sound_Release(sound2);
ERRCHECK(result);
result = FMOD_Sound_Release(sound3);
ERRCHECK(result);

result = FMOD_System_Close(system);
ERRCHECK(result);
result = FMOD_System_Release(system);
ERRCHECK(result);

return 0;

}
[/code:3bswcg4t]

  • You must to post comments
0
0

Hi,
The first possibility that springs to mind is that you have 5.1 or 7.1 mode selected in your Windows sound settings, but be using a stereo output (e.g. headphones).

If this is the case, FMOD will be initialised in e.g. 5.1 mode and try to pan the sound into the centre speaker. Since you don’t have a centre speaker, you hear nothing.

Can you check if this is the problem?

If this is not the case, can you see what the speaker mode gets set to? Just call FMOD_System_GetSpeakerMode at the end of your initialisation code.

Thanks,
Ben

  • You must to post comments
0
0

check problem
thank you !!!

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.