Tie the SoundGroup to the listener (not really necessary in this case but it provides a good hint) and call the soundmanager update after setting the position and orientation to activate the repositioning. This wil make the first sample to be heard immidiately.

This commit is contained in:
Erik Hofman
2022-09-23 11:53:01 +02:00
parent 3ffbec41ee
commit 9e20d853f7
2 changed files with 13 additions and 1 deletions

View File

@@ -25,7 +25,10 @@ int main( int argc, char *argv[] ) {
smgr->bind();
smgr->init();
sgr = smgr->find("default", true);
sgr->tie_to_listener();
smgr->set_volume(0.9);
smgr->activate();
@@ -33,9 +36,12 @@ int main( int argc, char *argv[] ) {
smgr->set_position( SGVec3d(0, 0, 0), SGGeod::fromDegFt(0, 0, 0) );
smgr->set_orientation( SGQuatd::fromYawPitchRollDeg(0, 0, 0) );
// Move the samples to the listener
smgr->update(0.0);
SGPath srcDir(SRC_DIR);
SGSoundSample *sample1 = new SGSoundSample("jet.wav", srcDir);
SGSoundSample *sample1 = new SGSoundSample("jet_ulaw.wav", srcDir);
sample1->set_volume(1.0);
sample1->set_pitch(1.0);
sample1->play_looped();

View File

@@ -24,7 +24,10 @@ int main( int argc, char *argv[] ) {
smgr->bind();
smgr->init();
sgr = smgr->find("default", true);
sgr->tie_to_listener();
smgr->set_volume(0.9);
smgr->activate();
@@ -34,6 +37,9 @@ int main( int argc, char *argv[] ) {
smgr->set_position( SGVec3d(0, 0, 0), SGGeod::fromDegFt(0, 0, 0) );
smgr->set_orientation( SGQuatd::fromYawPitchRollDeg(0, 0, 0) );
// Move the samples to the listenee
smgr->update(0.0);
printf("default position and orientation\n");
SGSoundSample *sample1 = new SGSoundSample("jet.wav", srcDir);
sample1->set_volume(1.0);