3D sound stops playing after a few updates

#1

After doing all these steps that to me look correct, the sound playes for like 3 updates and then just stops…
I debugged it and the channel and the sound seem to be right, fmod system gets updated correctly after I update all the 3d parameters and I also tried to set the 3d mode on the sound instead of the channel and also on both.
I’m not playing any other sound and even though I’m creating a 2D one.
Has anyone got any idea? Am I missing something here? (see code extracted from wrapping classes)

  • Created fmod system

  • Created fmod sound

  • Playing the sound, so that I can retrieve the channel

  • setting the volume

  • setting 3D parameters

  • updating them each loop

  • updating system.

    auto result = FMOD::System_Create(&m_fmodSystem);
    if(!FmodErrorCheck(result))
    return false;

    // Initialise the system
    result = m_fmodSystem->init(32, FMOD_INIT_NORMAL, nullptr);
    if(!FmodErrorCheck(result))
    return false;

    //somewhere else

    // creating sound with some parameters
    AudioManager::GetSystem()->createSound(filePath.c_str(), FMOD_DEFAULT | (FMOD_LOOP_OFF + loop), nullptr, &m_sound);

    // setting the volume
    AudioManager::GetSystem()->playSound(m_sound, nullptr, false, &m_channel);

    // setting the mode to 3d
    m_channel->setMode(FMOD_3D);

    // setting distance rolloff and initial potition and velocity
    m_channel->set3DMinMaxDistance(s_minDist, s_maxDist);
    m_channel->set3DAttributes(&m_position, &m_velocity);

    // then each application update I update sound source values and system.
    m_channel->set3DAttributes(&m_position, &m_velocity);
    m_fmodSystem->update();

I noticed that the sound stops as soon as the window pops up, but I believe it’s just a coincidence or bad timing.

0 Likes

#2

And clearly there’s a bug in the text formatting…

0 Likes

#3

All the FMOD functions should return FMOD_RESULT, checking that those are all fine would be a good place to start.

Do you get any errors or warnings?

0 Likes