Updates to the test utilies.

This commit is contained in:
ehofman
2009-10-21 16:52:02 +00:00
committed by Tim Moore
parent feba9024eb
commit ea513d392e
5 changed files with 37 additions and 31 deletions

View File

@@ -18,21 +18,22 @@ libsgsound_a_SOURCES = \
soundmgr_openal.cxx \
xmlsound.cxx
#noinst_PROGRAMS = openal_test1 openal_test2
check_PROGRAMS = openal_test1 openal_test2
#openal_test1_SOURCES = openal_test1.cxx
#openal_test2_SOURCES = openal_test2.cxx
openal_test1_SOURCES = openal_test1.cxx
openal_test2_SOURCES = openal_test2.cxx
#openal_test1_LDADD = \
# $(top_builddir)/simgear/debug/libsgdebug.a \
# $(openal_LIBS)
openal_test1_LDADD = \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(openal_LIBS)
#openal_test2_LDADD = \
# libsgsound.a \
# $(top_builddir)/simgear/structure/libsgstructure.a \
# $(top_builddir)/simgear/timing/libsgtiming.a \
# $(top_builddir)/simgear/debug/libsgdebug.a \
# $(top_builddir)/simgear/misc/libsgmisc.a \
# $(openal_LIBS)
openal_test2_LDADD = \
libsgsound.a \
$(top_builddir)/simgear/structure/libsgstructure.a \
$(top_builddir)/simgear/timing/libsgtiming.a \
$(top_builddir)/simgear/debug/libsgdebug.a \
$(top_builddir)/simgear/misc/libsgmisc.a \
$(top_builddir)/simgear/math/libsgmath.a \
$(openal_LIBS)
INCLUDES = -I$(top_srcdir) -DSRC_DIR=\"$(top_srcdir)/simgear/sound\"

View File

@@ -50,6 +50,8 @@ int main( int argc, char *argv[] ) {
ALCdevice *dev;
ALCcontext *context;
sglog().setLogLevels( SG_ALL, SG_ALERT );
// initialize OpenAL
if ( (dev = alcOpenDevice( NULL )) != NULL
&& ( context = alcCreateContext( dev, NULL )) != NULL ) {

View File

@@ -21,15 +21,16 @@ int main( int argc, char *argv[] ) {
smgr->bind();
smgr->init();
smgr->set_volume(0.9);
sgr = smgr->find("default", true);
smgr->set_volume(0.9);
smgr->activate();
SGSoundSample *sample1 = new SGSoundSample( SRC_DIR, "jet.wav" );
sample1->set_volume(1.0);
sample1->set_pitch(1.0);
sample1->play_looped();
sgr->add(sample1, "sound1");
smgr->update(1.0);
smgr->update_late(1.0);
printf("playing sample1\n");
sleep(1);
@@ -38,7 +39,7 @@ int main( int argc, char *argv[] ) {
sample2->set_pitch(0.4);
sample2->play_looped();
sgr->add(sample2, "sound2");
smgr->update(1.0);
smgr->update_late(1.0);
printf("playing sample2\n");
sleep(1);
@@ -47,7 +48,7 @@ int main( int argc, char *argv[] ) {
sample3->set_pitch(0.8);
sample3->play_looped();
sgr->add(sample3, "sound3");
smgr->update(1.0);
smgr->update_late(1.0);
printf("playing sample3\n");
sleep(1);
@@ -56,7 +57,7 @@ int main( int argc, char *argv[] ) {
sample4->set_pitch(1.2);
sample4->play_looped();
sgr->add(sample4, "sound4");
smgr->update(1.0);
smgr->update_late(1.0);
printf("playing sample4\n");
sleep(1);
@@ -65,7 +66,7 @@ int main( int argc, char *argv[] ) {
sample5->set_pitch(1.6);
sample5->play_looped();
sgr->add(sample5, "sound5");
smgr->update(1.0);
smgr->update_late(1.0);
printf("playing sample5\n");
sleep(1);
@@ -74,24 +75,24 @@ int main( int argc, char *argv[] ) {
sample6->set_pitch(2.0);
sample6->play_looped();
sgr->add(sample6, "sound6");
smgr->update(1.0);
smgr->update_late(1.0);
printf("playing sample6\n");
sleep(1);
for (int i=0; i<10; i++) {
sleep(1);
smgr->update(1);
smgr->update_late(1);
}
sgr->stop("sound1");
sgr->stop("sound2");
sgr->stop("sound3");
sleep(0.5);
sgr->update(0.5);
smgr->update_late(0.5);
sgr->stop("sound4");
sgr->stop("sound5");
sgr->stop("sound6");
sgr->update(1);
smgr->update_late(1);
sleep(1);
smgr->unbind();

View File

@@ -183,9 +183,11 @@ void SGSoundSample::set_position( const SGGeod& pos ) {
void SGSoundSample::update_absolute_position() {
SGQuatd orient = SGQuatd::fromLonLat(_base_pos) * _orientation;
_orivec = -toVec3f(orient.rotate(_direction));
printf("ori: %f %f %f\n", _orivec[0], _orivec[1], _orivec[2]);
orient = SGQuatd::fromRealImag(0, _relative_pos) * _orientation;
orient = SGQuatd::fromRealImag(0, _relative_pos) * _orientation;
_absolute_pos = -SGVec3d::fromGeod(_base_pos); // -orient.rotate(SGVec3d::e1());
printf("pos: %f %f %f\n", _absolute_pos[0], _absolute_pos[1], _absolute_pos[2]);
}
string SGSoundSample::random_string() {

View File

@@ -171,7 +171,7 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node,
}
float reference_dist = node->getDoubleValue("reference-dist", 500.0);
float reference_dist = node->getDoubleValue("reference-dist", 50.0);
float max_dist = node->getDoubleValue("max-dist", 3000.0);
//
@@ -241,9 +241,9 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node,
// Orientation
//
SGVec3d dir = SGVec3d::zeros();
float inner, outer, outer_gain;
inner = outer = 360.0;
outer_gain = 0.0;
float inner = 360.0;
float outer = 360.0;
float outer_gain = 0.0;;
prop = node->getChild("orientation");
if ( prop != NULL ) {
dir = SGVec3d(-prop->getDoubleValue("x", 0.0),
@@ -261,11 +261,11 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node,
_sample = new SGSoundSample( path.c_str(), node->getStringValue("path", ""));
_sample->set_relative_position( offset_pos );
_sample->set_direction( dir );
_sample->set_audio_cone(inner, outer, outer_gain);
_sample->set_audio_cone( inner, outer, outer_gain );
_sample->set_reference_dist( reference_dist );
_sample->set_max_dist( max_dist );
_sample->set_volume(v);
_sample->set_pitch(p);
_sample->set_volume( v );
_sample->set_pitch( p );
_sgrp->add( _sample, _name );
}