Note that there are some explanatory texts on larger screens.

plurals
  1. POFMOD playSound throws an error about invalid parameter
    text
    copied!<p>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.</p> <p>An invalid parameter was passed to this function.</p> <p>This is exactly what an errorcheck output gives me.</p> <p>Code...let's get from start:</p> <pre><code>typedef std::map&lt;std::string, FMOD::Sound*&gt; SoundPool; SoundPool m_sounds; FMOD::Channel* m_soundChannels[MAX_SOUNDS]; FMOD::System* m_soundSystem; </code></pre> <p>and then:</p> <pre><code>FMOD::System_Create(&amp;m_soundSystem); m_soundSystem-&gt;init(32, FMOD_INIT_NORMAL, NULL); for(int i = 0; i &lt; MAX_SOUNDS; i++) m_soundChannels[i] = 0; </code></pre> <p>and later:</p> <pre><code>void CResourceManager::PlaySound(std::string filename, float volume) { for(int i = 0; i &lt; MAX_SOUNDS; i++) { if(m_soundChannels[i] == 0) { if(volume &gt; 1.0f) volume = 1.0f; FMOD_RESULT result = m_soundSystem-&gt;playSound(FMOD_CHANNEL_FREE, m_sounds[filename], false, &amp;m_soundChannels[i]); if(result != FMOD_OK) { std::cout &lt;&lt; FMOD_ErrorString(result); //// here's the error } m_soundChannels[i]-&gt;setVolume(volume); break; } } } void CResourceManager::Update() { m_soundSystem-&gt;update(); for(int i = 0; i &lt; MAX_SOUNDS; i++) { if(m_soundChannels[i] != 0) { bool playing; m_soundChannels[i]-&gt;isPlaying(&amp;playing); if(!playing) m_soundChannels[i] = 0; } } } bool CResourceManager::AddSound( std::string filename ) { FMOD_RESULT result = m_soundSystem-&gt;createSound(filename.c_str(), FMOD_LOOP_NORMAL, NULL, &amp;m_sounds[filename]); if(result == FMOD_OK) return true; return false; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload