From 9e20d853f781c8099679698fed0537bd59c46af5 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Fri, 23 Sep 2022 11:53:01 +0200 Subject: [PATCH] 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. --- simgear/sound/soundmgr_test.cxx | 8 +++++++- simgear/sound/soundmgr_test2.cxx | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/simgear/sound/soundmgr_test.cxx b/simgear/sound/soundmgr_test.cxx index c08b8a54..63ea5339 100644 --- a/simgear/sound/soundmgr_test.cxx +++ b/simgear/sound/soundmgr_test.cxx @@ -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(); diff --git a/simgear/sound/soundmgr_test2.cxx b/simgear/sound/soundmgr_test2.cxx index e874d1b1..e58de235 100644 --- a/simgear/sound/soundmgr_test2.cxx +++ b/simgear/sound/soundmgr_test2.cxx @@ -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);