Hi there!
Can anybody help me with the usage of BGameSound (and its derived BFileGameSound)? I’d like to mute a sound and think that’s done by using SetGain(0). But for some reason, the played back sound is always the same volume, no matter what’s the gain set to.
I tried with a little test app:
#include <FileGameSound.h>
#include <stdio.h>
int
main()
{
BFileGameSound* player = new BFileGameSound("/boot/home/_test.wav", false);
if (player->InitCheck() != B_OK)
return 1;
player->Preload();
printf("0) Gain() = %f\n", player->Gain());
player->StartPlaying();
snooze(1000000 * 3); // wait 3 sec
player->SetGain(0.0);
printf("1.1) Gain set to 0.0 (Gain() = %f)\n", player->Gain());
player->StartPlaying();
printf("1.2) Gain() = %f\n", player->Gain());
snooze(1000000 * 3); // wait 3 sec
player->SetGain(1);
printf("2.1) Gain set to 1 (Gain() = %f)\n", player->Gain());
player->StartPlaying();
printf("2.2) Gain() = %f\n", player->Gain());
snooze(1000000 * 3); // wait 3 sec
return 0;
}
The output is:
0) Gain() = 1.000000
1.1) Gain set to 0.0 (Gain() = 0.000000)
1.2) Gain() = 0.000000
2.1) Gain set to 1 (Gain() = 1.000000)
2.2) Gain() = 1.000000
So the gain get set alright, but the playback volume is unaffected. Any ideas what goes wrong?