I need some help if anyone has any insight.
I’m making a wrapper for a windows based game using c++.
I thought all my functions were working properly, but I’m having problems playing sounds loaded from memory. I am using a file packing system to store all my files in one large file. When I call FMOD’s load sound it pulls the info from the pack file. I have multiple sounds playing and this is where the problem comes in. All sounds will play fine for the first 5 or 6 calls to the play sound function, but then sounds stop playing because I get invalid file parameters causing the channel to become null, thus not playing sound anymore. This is the FMResult I get. FMOD_ERR_OUTPUT_DRIVERCALL
bool CDTI_FMOD_Wrapper::PlaySound(int nID, FMOD_MODE mode)
// Error check and make sure the system has been initialized
if (!m_dsObject) return false;
// Make sure ID is valid. if (nID < 0 || nID >= (signed)FMODSoundList.size()) return false; if (mode == FMOD_LOOP_OFF) m_FMresult = m_FMsystem->playSound(FMOD_CHANNEL_FREE, FMODSoundList[nID].sound, false, &m_Channel1); else m_FMresult = m_FMsystem->playSound(FMOD_CHANNEL_FREE, FMODSoundList[nID].sound, false, &m_Channel2); return true;
That is my function call, I am using 2 differen’t channels because I want one channel to loop by default, and the other to only play once. I’m sure there is a better way, but that was the way I found.
If anyone can help me out, I would appreciate it. Thanks
- JonMiller asked 11 years ago
So yeah I fixed my problem. It turns out that when I set my max channels, I set it to 100. When I played each sound effect I was using the FMOD_CHANNEL_FREE flag which would use up a new channel each time. Once I hit the 100th channel apparently FMOD didn’t have any channels left to play on, so when I used FMOD_CHANNEL_REUSE that enabled me to play my effects as many times as I wanted. Hope that helps someone else that might have similar problems.
- JonMiller answered 11 years ago
Please login first to submit.