Sound effect changes from David Megginson.
This commit is contained in:
parent
2a00ebf9b4
commit
5cf725035f
1 changed files with 4 additions and 97 deletions
|
@ -90,6 +90,7 @@
|
||||||
#include <Scenery/tilemgr.hxx>
|
#include <Scenery/tilemgr.hxx>
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
# include <Sound/soundmgr.hxx>
|
# include <Sound/soundmgr.hxx>
|
||||||
|
# include <Sound/fg_fx.hxx>
|
||||||
# include <Sound/morse.hxx>
|
# include <Sound/morse.hxx>
|
||||||
#endif
|
#endif
|
||||||
#include <Time/event.hxx>
|
#include <Time/event.hxx>
|
||||||
|
@ -160,13 +161,6 @@ static long global_multi_loop;
|
||||||
// forward declaration
|
// forward declaration
|
||||||
void fgReshape( int width, int height );
|
void fgReshape( int width, int height );
|
||||||
|
|
||||||
// Global structures for the Audio library
|
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
|
||||||
static FGSimpleSound *s1;
|
|
||||||
static FGSimpleSound *s2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// ssg variables
|
// ssg variables
|
||||||
ssgRoot *scene = NULL;
|
ssgRoot *scene = NULL;
|
||||||
ssgBranch *terrain = NULL;
|
ssgBranch *terrain = NULL;
|
||||||
|
@ -1207,7 +1201,7 @@ static void fgMainLoop( void ) {
|
||||||
if ( global_multi_loop > 0 ) {
|
if ( global_multi_loop > 0 ) {
|
||||||
fgUpdateTimeDepCalcs();
|
fgUpdateTimeDepCalcs();
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_ALL, SG_INFO,
|
SG_LOG( SG_ALL, SG_DEBUG,
|
||||||
"Elapsed time is zero ... we're zinging" );
|
"Elapsed time is zero ... we're zinging" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1228,72 +1222,8 @@ static void fgMainLoop( void ) {
|
||||||
|
|
||||||
// Run audio scheduler
|
// Run audio scheduler
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
static bool bCranking;
|
|
||||||
if ( fgGetBool("/sim/sound") && globals->get_soundmgr()->is_working() ) {
|
if ( fgGetBool("/sim/sound") && globals->get_soundmgr()->is_working() ) {
|
||||||
if ( fgGetString("/sim/aircraft") == "c172" ) {
|
globals->get_fx()->update();
|
||||||
if(fgGetBool("/engines/engine[0]/running")) {
|
|
||||||
// pitch corresponds to rpm
|
|
||||||
// volume corresponds to manifold pressure
|
|
||||||
|
|
||||||
// cout << "AUDIO working = "
|
|
||||||
// << globals->get_soundmgr()->is_working() << endl;
|
|
||||||
|
|
||||||
double rpm_factor;
|
|
||||||
if ( cur_fdm_state->get_engine(0) != NULL ) {
|
|
||||||
rpm_factor = cur_fdm_state->get_engine(0)->get_RPM() / 2500.0;
|
|
||||||
} else {
|
|
||||||
rpm_factor = 1.0;
|
|
||||||
}
|
|
||||||
// cout << "rpm = " << cur_fdm_state->get_engine(0)->get_RPM()
|
|
||||||
// << endl;
|
|
||||||
|
|
||||||
double pitch = 0.3 + rpm_factor * 3.0;
|
|
||||||
|
|
||||||
// don't run at absurdly slow rates -- not realistic
|
|
||||||
// and sounds bad to boot. :-)
|
|
||||||
if (pitch < 0.7) { pitch = 0.7; }
|
|
||||||
if (pitch > 5.0) { pitch = 5.0; }
|
|
||||||
|
|
||||||
double mp_factor;
|
|
||||||
if ( cur_fdm_state->get_engine(0) != NULL ) {
|
|
||||||
mp_factor = cur_fdm_state->get_engine(0)->get_Manifold_Pressure() / 100;
|
|
||||||
} else {
|
|
||||||
mp_factor = 0.3;
|
|
||||||
}
|
|
||||||
/* cout << "mp = "
|
|
||||||
<< cur_fdm_state->get_engine(0)->get_Manifold_Pressure()
|
|
||||||
<< endl; */
|
|
||||||
|
|
||||||
double volume = 0.15 + mp_factor / 2.0;
|
|
||||||
|
|
||||||
if ( volume < 0.15 ) { volume = 0.15; }
|
|
||||||
if ( volume > 0.5 ) { volume = 0.5; }
|
|
||||||
// cout << "volume = " << volume << endl;
|
|
||||||
|
|
||||||
s1->set_pitch( pitch );
|
|
||||||
s1->set_volume( volume );
|
|
||||||
} else {
|
|
||||||
s1->set_pitch(0.0);
|
|
||||||
s1->set_volume(0.0);
|
|
||||||
}
|
|
||||||
if(fgGetBool("/engines/engine[0]/cranking")) {
|
|
||||||
if(!bCranking) {
|
|
||||||
globals->get_soundmgr()->play_looped("cranking");
|
|
||||||
bCranking = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(bCranking) {
|
|
||||||
globals->get_soundmgr()->stop("cranking");
|
|
||||||
bCranking = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // Not C172
|
|
||||||
double param
|
|
||||||
= globals->get_controls()->get_throttle( 0 ) * 2.0 + 1.0;
|
|
||||||
s1->set_pitch( param );
|
|
||||||
s1->set_volume( param );
|
|
||||||
}
|
|
||||||
|
|
||||||
globals->get_soundmgr()->update();
|
globals->get_soundmgr()->update();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1341,30 +1271,6 @@ static void fgIdleFunction ( void ) {
|
||||||
}
|
}
|
||||||
#endif // !WIN32
|
#endif // !WIN32
|
||||||
|
|
||||||
FGSoundMgr *soundmgr = new FGSoundMgr;
|
|
||||||
globals->set_soundmgr( soundmgr );
|
|
||||||
|
|
||||||
if ( fgGetBool("/sim/sound") ) {
|
|
||||||
globals->get_soundmgr()->init();
|
|
||||||
|
|
||||||
s1 = new FGSimpleSound( fgGetString("/sim/sounds/engine",
|
|
||||||
"Sounds/wasp.wav") );
|
|
||||||
globals->get_soundmgr()->add( s1, "engine loop" );
|
|
||||||
globals->get_soundmgr()->play_looped( "engine loop" );
|
|
||||||
SG_LOG( SG_GENERAL, SG_INFO,
|
|
||||||
"Rate = " << s1->get_sample()->getRate()
|
|
||||||
<< " Bps = " << s1->get_sample()->getBps()
|
|
||||||
<< " Stereo = " << s1->get_sample()->getStereo() );
|
|
||||||
|
|
||||||
// s2 = new FGSimpleSound( "Sounds/corflaps.wav" );
|
|
||||||
// s2->set_volume( 0.3 );
|
|
||||||
// globals->get_soundmgr()->add( s2, "flaps" );
|
|
||||||
s2 = new FGSimpleSound( fgGetString("/sim/sounds/engine",
|
|
||||||
"Sounds/cranking.wav") );
|
|
||||||
globals->get_soundmgr()->add( s2, "cranking" );
|
|
||||||
s2->set_pitch(1.5);
|
|
||||||
s2->set_volume(0.25);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
idle_state++;
|
idle_state++;
|
||||||
|
@ -1540,6 +1446,7 @@ int fgGlutInitEvents( void ) {
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
int mainLoop( int argc, char **argv ) {
|
int mainLoop( int argc, char **argv ) {
|
||||||
|
|
||||||
#if defined( macintosh )
|
#if defined( macintosh )
|
||||||
freopen ("stdout.txt", "w", stdout );
|
freopen ("stdout.txt", "w", stdout );
|
||||||
freopen ("stderr.txt", "w", stderr );
|
freopen ("stderr.txt", "w", stderr );
|
||||||
|
|
Loading…
Add table
Reference in a new issue