Hi. I was using the CDSourceWrapper class to change the gain of a sound. What I wanted to do is a fade, so I needed the current gain, and then in a loop change that value to 0. But checking the code, the current gain value comes from a stored variable in CDSourceWrapper, rather than the actual value from the source.
//alGetSource does not appear to work for pitch, pan and gain values
//So we just remember the last value set
- (float) pitch {
/*
//This does not work on simulator or device
ALfloat pitchVal;
alGetSourcef(sourceId, AL_PITCH, &pitchVal);
return pitchVal;
*/
return lastPitch;
}
- (float) pan {
return lastPan;
}
- (float) gain {
//return lastGain;
ALfloat tempGain;
alGetSourcef(sourceId, AL_GAIN, &tempGain); //this is what I changed
return tempGain;
}
Can I use the alGetSourcef function?. When doing my tests, I can get the correct gain value from the alGetSourcef function. Could there be another issue later?
Thanks.