1

I've tried building some sort of audio manager after openAL failed to deliver on certain machines so I found out about fmod. However after few hours of changes in code nothing really works. My playSound call seems to be bugging.

An invalid parameter was passed to this function.

This is exactly what an errorcheck output gives me.

Code...let's get from start:

typedef std::map<std::string, FMOD::Sound*> SoundPool; 
SoundPool m_sounds;
FMOD::Channel* m_soundChannels[MAX_SOUNDS];
FMOD::System* m_soundSystem;

and then:

FMOD::System_Create(&m_soundSystem);
m_soundSystem->init(32, FMOD_INIT_NORMAL, NULL);
for(int i = 0; i < MAX_SOUNDS; i++)
    m_soundChannels[i] = 0;

and later:

void CResourceManager::PlaySound(std::string filename, float volume)
{
    for(int i = 0; i < MAX_SOUNDS; i++)
    {
        if(m_soundChannels[i] == 0)
        {
            if(volume > 1.0f) volume = 1.0f;
            FMOD_RESULT result = m_soundSystem->playSound(FMOD_CHANNEL_FREE,
                                 m_sounds[filename], false, &m_soundChannels[i]);
            if(result != FMOD_OK)
            {
                std::cout << FMOD_ErrorString(result); //// here's the error 
            }
            m_soundChannels[i]->setVolume(volume);
            break;
       }
   }
}

void CResourceManager::Update()
{
    m_soundSystem->update();

    for(int i = 0; i < MAX_SOUNDS; i++)
    {
        if(m_soundChannels[i] != 0)
        {
            bool playing;
            m_soundChannels[i]->isPlaying(&playing);

            if(!playing)
                m_soundChannels[i] = 0;
        }
    }
}

bool CResourceManager::AddSound( std::string filename )
{
    FMOD_RESULT result = m_soundSystem->createSound(filename.c_str(),
                            FMOD_LOOP_NORMAL, NULL, &m_sounds[filename]);

    if(result == FMOD_OK)
        return true;

    return false;
}
Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
user1255410
  • 856
  • 1
  • 9
  • 15
  • Have you tried linking with the logging version of FMOD? It might give you a better idea of what is going wrong. Also can you confirm System::init is not returning an error? – Mathew Block Mar 07 '12 at 23:11
  • It is initing fine. Also I can't really use that logging version, where is the output coming? Can't seem to find it. – user1255410 Mar 08 '12 at 08:31
  • All right. I tracked the bug in the logging section. If in playSound function I use newly created sound - it works. If from std::map it doesn't... Any ideas? – user1255410 Mar 08 '12 at 08:41
  • Solved, I kept loading files with \\ and accessing them with /. That's what bugged it : – user1255410 Mar 08 '12 at 13:28

0 Answers0