For my current project I need to keep track of the time my music file has been playing. I have tested FMOD_Channel_GetPosition with a .ogg and a .wav file. Both kept throwing error 37:
An invalid parameter was passed to this function.
This code should return the current time, but position stays null all the time.
[code:348y2ojz] unsigned int * position = 0;
result = FMOD_Channel_GetPosition(m_musicChannel, position, (FMOD_TIMEUNIT)FMOD_TIMEUNIT_MS);
return * position;[/code:348y2ojz]
I am out of ideas about what the problem is. Any help or ideas would be most appreciated.
Thanks in advance,
- Dysprosium asked 8 years ago
I am now working on another part, which is supposed to alter the frequency of the music, but throws me the same error.
[code:ovj2z4hc] result = FMOD_System_PlaySound(m_system, FMOD_CHANNEL_FREE, m_music, 0, &m_musicChannel);
result = FMOD_Channel_GetFrequency(m_musicChannel, musicFrequency);
cout << m_musicChannel << endl;
result = FMOD_Channel_SetChannelGroup(m_musicChannel, musicGroup);
[b:ovj2z4hc] result = FMOD_Channel_GetFrequency(m_musicChannel, musicFrequency);
That is the part that throws the exception.
m_musicChannel is not null; I have tested that.
musicFrequency is a pointer to a float.
I still don’t get what I am doing wrong here. I suppose my best shot is getting some sleep and praying tomorrow will bring me some answers.
You’re not calling the functions in the correct way. You need to pass in the address of an [b:1zhiss2d]existing [/b:1zhiss2d]float or int. You’re getting INVALID_PARAM because you’re passing in a null pointer.
The code inside those functions dereferences the pointer and assigns a value to it. If the passed in value is 0 it will throw an error.
They need to look like this:
[code:1zhiss2d]unsigned int position = 0;
result = FMOD_Channel_GetPosition(m_musicChannel, &position, (FMOD_TIMEUNIT)FMOD_TIMEUNIT_MS);
The same is probably true for musicFrequency.
- Dogbert answered 8 years ago
Please login first to submit.